Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
SixiS committed Jan 22, 2010
0 parents commit 94a7c27
Show file tree
Hide file tree
Showing 10 changed files with 284 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.rdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is the readme :>
19 changes: 19 additions & 0 deletions example/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script src="../javascripts/jquery.js" type="text/javascript" charset="utf-8"></script>
<script src="../javascripts/naked_password.js" type="text/javascript" charset="utf-8"></script>

<script type="text/javascript">
$(document).ready(function() {
$("input:password").nakedPassword({path: "../images/"});
});
</script>

</head>
<body>
<h1>Naked Password</h1>
<input type="password" id="test" style="font-size: 50px">
</body>
</html>

Binary file added images/0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/girl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
151 changes: 151 additions & 0 deletions javascripts/jquery.js

Large diffs are not rendered by default.

113 changes: 113 additions & 0 deletions javascripts/naked_password.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
jQuery.fn.nakedPassword = function (options) {
return this.each (function () {

var settings = {path : "images/"}
var settings = $.extend(settings, options);


var prev_password_level = 0;

var trigger = function(e) {
var forward = false
password_level = getPasswordStrength($(this).val());
if(prev_password_level <= password_level){
forward = true;
}

switch(password_level){
case 0:
$("#pic0").fadeIn();
$("#pic1").fadeOut();
$("#pic2").fadeOut();
$("#pic3").fadeOut();
$("#pic4").fadeOut();
break;

case 1:
$("#pic0").fadeOut();
$("#pic1").fadeIn();
$("#pic2").fadeOut();
$("#pic3").fadeOut();
$("#pic4").fadeOut();
break;

case 2:
$("#pic0").fadeOut();
$("#pic1").fadeOut();
$("#pic2").fadeIn();
$("#pic3").fadeOut();
$("#pic4").fadeOut();
break;

case 3:
$("#pic0").fadeOut();
$("#pic1").fadeOut();
$("#pic2").fadeOut();
$("#pic3").fadeIn();
$("#pic4").fadeOut();
break;

case 4:
$("#pic0").fadeOut();
$("#pic1").fadeOut();
$("#pic2").fadeOut();
$("#pic3").fadeOut();
$("#pic4").fadeIn();
break;

case 5:
$("#pic0").fadeOut();
$("#pic1").fadeOut();
$("#pic2").fadeOut();
$("#pic3").fadeOut();
$("#pic4").fadeIn();
break;

}

prev_password_level = password_level;

}//end trigger

function getPasswordStrength(password){
var score = 0;

//if password bigger than 4 give 1 point
if (password.length > 4) score++;

//if password has both lower and uppercase characters give 1 point
if ( ( password.match(/[a-z]/) ) && ( password.match(/[A-Z]/) ) ) score++;

//if password has at least one number give 1 point
if (password.match(/\d+/)) score++;

//if password has at least one special caracther give 1 point
if ( password.match(/.[!,@,#,$,%,^,&,*,?,_,~,-,(,)]/) ) score++;

//if password bigger than 12 give another 1 point
if (password.length > 8) score++;

return score;
}



position = $(this).position();
height = $(this).outerHeight();
width = $(this).outerWidth();

pic_width = (((height-6)/28)*30);
pic_height = height - 6;



$(this).after("<div id='pic0' style='position:absolute; left:" + (position.left + width - (pic_width+3)) + "; top:" + (position.top + 3) + ";'><img src='" + settings.path + "0.png' width='" + pic_width + "' height='" + pic_height + "px' /></div>");
$(this).after("<div id='pic1' style='display:none; position:absolute; left:" + (position.left + width - (pic_width+3)) + "; top:" + (position.top + 3) + ";'><img src='" + settings.path + "1.png' width='" + pic_width + "' height='" + pic_height + "px' /></div>");
$(this).after("<div id='pic2' style='display:none; position:absolute; left:" + (position.left + width - (pic_width+3)) + "; top:" + (position.top + 3) + ";'><img src='" + settings.path + "2.png' width='" + pic_width + "' height='" + pic_height + "px' /></div>");
$(this).after("<div id='pic3' style='display:none; position:absolute; left:" + (position.left + width - (pic_width+3)) + "; top:" + (position.top + 3) + ";'><img src='" + settings.path + "3.png' width='" + pic_width + "' height='" + pic_height + "px' /></div>");
$(this).after("<div id='pic4' style='display:none; position:absolute; left:" + (position.left + width - (pic_width+3)) + "; top:" + (position.top + 3) + ";'><img src='" + settings.path + "4.png' width='" + pic_width + "' height='" + pic_height + "px' /></div>");


$(this).bind('keyup', trigger).bind('blur', trigger);
});
}

0 comments on commit 94a7c27

Please sign in to comment.