Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added password strength meter and generator for the CMS
- Loading branch information
Semias
committed
May 29, 2012
1 parent
65c9b62
commit 05343f9
Showing
11 changed files
with
488 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
(function (A) { | ||
A.extend(A.fn, { | ||
pstrength: function (B) { | ||
var B = A.extend({ | ||
verdects: ["Very weak", "Weak", "Medium", "Strong", "Very strong", "Unsafe password word!", "Too short", "Minimum number of characters is"], | ||
colors: ["#f00", "#c06", "#f60", "#3c0", "#3f0"], | ||
scores: [10, 15, 30, 40], | ||
common: ["password", "123456", "123", "qwerty"], | ||
minchar: 6 | ||
}, B); | ||
return this.each(function () { | ||
var C = A(this).attr("id"); | ||
$("#dialoglink").after("<div class=\"pstrength-minchar\" id=\"" + C + "_minchar\">" + B.verdects[7] + " " + B.minchar + "</div>"); | ||
$("#dialoglink").after("<div class=\"pstrength-info\" id=\"" + C + "_text\"></div>"); | ||
$("#dialoglink").after("<div style=\"width: " + (A(this).outerWidth()-1) + "px;\"><div class=\"pstrength-bar\" id=\"" + C + "_bar\" style=\"border: 1px solid white; font-size: 1px; height: 5px; width: 0px;\"></div></div>"); | ||
A(this).keyup(function () { | ||
A.fn.runPassword(A(this).val(), C, B) | ||
}); | ||
A.fn.runPassword(A(this).val(), C, B); | ||
}) | ||
}, | ||
runPassword: function (D, F, C) { | ||
nPerc = A.fn.checkPassword(D, C); | ||
var B = "#" + F + "_bar"; | ||
var E = "#" + F + "_text"; | ||
if (nPerc == -200) { | ||
strColor = "#f00"; | ||
strText = C.verdects[5]; | ||
A(B).css({ | ||
width: "0%" | ||
}) | ||
} else { | ||
if (nPerc < 0 && nPerc > -199) { | ||
strColor = "#ccc"; | ||
strText = C.verdects[6]; | ||
A(B).css({ | ||
width: "5%" | ||
}) | ||
} else { | ||
if (nPerc <= C.scores[0]) { | ||
strColor = C.colors[0]; | ||
strText = C.verdects[0]; | ||
A(B).css({ | ||
width: "10%" | ||
}) | ||
} else { | ||
if (nPerc > C.scores[0] && nPerc <= C.scores[1]) { | ||
strColor = C.colors[1]; | ||
strText = C.verdects[1]; | ||
A(B).css({ | ||
width: "25%" | ||
}) | ||
} else { | ||
if (nPerc > C.scores[1] && nPerc <= C.scores[2]) { | ||
strColor = C.colors[2]; | ||
strText = C.verdects[2]; | ||
A(B).css({ | ||
width: "50%" | ||
}) | ||
} else { | ||
if (nPerc > C.scores[2] && nPerc <= C.scores[3]) { | ||
strColor = C.colors[3]; | ||
strText = C.verdects[3]; | ||
A(B).css({ | ||
width: "75%" | ||
}) | ||
} else { | ||
strColor = C.colors[4]; | ||
strText = C.verdects[4]; | ||
A(B).css({ | ||
width: "100%" | ||
}) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
A(B).css({ | ||
backgroundColor: strColor | ||
}); | ||
A(E).html("<span style='color: " + strColor + ";'>" + strText + "</span>") | ||
}, | ||
checkPassword: function (C, B) { | ||
var F = 0; | ||
var E = B.verdects[0]; | ||
if (C.length < B.minchar) { | ||
F = (F - 100) | ||
} else { | ||
if (C.length >= B.minchar && C.length <= (B.minchar + 2)) { | ||
F = (F + 6) | ||
} else { | ||
if (C.length >= (B.minchar + 3) && C.length <= (B.minchar + 4)) { | ||
F = (F + 12) | ||
} else { | ||
if (C.length >= (B.minchar + 5)) { | ||
F = (F + 18) | ||
} | ||
} | ||
} | ||
} | ||
if (C.match(/[a-z]/)) { | ||
F = (F + 1) | ||
} | ||
if (C.match(/[A-Z]/)) { | ||
F = (F + 5) | ||
} | ||
if (C.match(/\d+/)) { | ||
F = (F + 5) | ||
} | ||
if (C.match(/(.*[0-9].*[0-9].*[0-9])/)) { | ||
F = (F + 7) | ||
} | ||
if (C.match(/.[!,@,#,$,%,^,&,*,?,_,~]/)) { | ||
F = (F + 5) | ||
} | ||
if (C.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/)) { | ||
F = (F + 7) | ||
} | ||
if (C.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)) { | ||
F = (F + 2) | ||
} | ||
if (C.match(/([a-zA-Z])/) && C.match(/([0-9])/)) { | ||
F = (F + 3) | ||
} | ||
if (C.match(/([a-zA-Z0-9].*[!,@,#,$,%,^,&,*,?,_,~])|([!,@,#,$,%,^,&,*,?,_,~].*[a-zA-Z0-9])/)) { | ||
F = (F + 3) | ||
} | ||
for (var D = 0; D < B.common.length; D++) { | ||
if (C.toLowerCase() == B.common[D]) { | ||
F = -200 | ||
} | ||
} | ||
return F | ||
} | ||
}) | ||
})(jQuery) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* Z-index of #mask must lower than #boxes .window */ | ||
#mask { | ||
position:absolute; | ||
z-index:9000; | ||
background-color:#000; | ||
display:none; | ||
top:0; | ||
left: 0; | ||
} | ||
|
||
#boxes .window { | ||
position:absolute; | ||
width:440px; | ||
height:200px; | ||
display:none; | ||
z-index:9999; | ||
padding:20px; | ||
} | ||
|
||
|
||
/* Customize your modal window here, you can add background image too */ | ||
#boxes #dialog { | ||
width:475px; | ||
height:280px; | ||
background-color: #ffffff; | ||
} | ||
#boxes #dialog #passgen { | ||
margin-top: 10px; | ||
} |
Oops, something went wrong.