i18n fixes from nbachiyski. fixes #6226

git-svn-id: http://svn.automattic.com/wordpress/trunk@7302 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-03-14 20:17:17 +00:00
parent fdda0c30d3
commit fb488bb835
2 changed files with 8 additions and 90 deletions

View File

@ -3,15 +3,13 @@
// Firas Kassem phiras.wordpress.com || phiras at gmail {dot} com
// for more information : http://phiras.wordpress.com/2007/04/08/password-strength-meter-a-jquery-plugin/
var shortPass = 'Too short'
var badPass = 'Bad'
var goodPass = 'Good'
var strongPass = 'Strong'
var shortPass = pwsL10n.short
var badPass = pwsL10n.bad
var goodPass = pwsL10n.good
var strongPass = pwsL10n.strong
function passwordStrength(password,username)
{
function passwordStrength(password,username) {
score = 0
//password < 4
@ -79,84 +77,4 @@ function checkRepetition(pLen,str) {
}
return res
}
// Password strength meter
// This jQuery plugin is written by firas kassem [2007.04.05]
// Firas Kassem phiras.wordpress.com || phiras at gmail {dot} com
// for more information : http://phiras.wordpress.com/2007/04/08/password-strength-meter-a-jquery-plugin/
var shortPass = 'Too short'
var badPass = 'Bad'
var goodPass = 'Good'
var strongPass = 'Strong'
function passwordStrength(password,username)
{
score = 0
//password < 4
if (password.length < 4 ) { return shortPass }
//password == username
if (password.toLowerCase()==username.toLowerCase()) return badPass
//password length
score += password.length * 4
score += ( checkRepetition(1,password).length - password.length ) * 1
score += ( checkRepetition(2,password).length - password.length ) * 1
score += ( checkRepetition(3,password).length - password.length ) * 1
score += ( checkRepetition(4,password).length - password.length ) * 1
//password has 3 numbers
if (password.match(/(.*[0-9].*[0-9].*[0-9])/)) score += 5
//password has 2 sybols
if (password.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/)) score += 5
//password has Upper and Lower chars
if (password.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)) score += 10
//password has number and chars
if (password.match(/([a-zA-Z])/) && password.match(/([0-9])/)) score += 15
//
//password has number and symbol
if (password.match(/([!,@,#,$,%,^,&,*,?,_,~])/) && password.match(/([0-9])/)) score += 15
//password has char and symbol
if (password.match(/([!,@,#,$,%,^,&,*,?,_,~])/) && password.match(/([a-zA-Z])/)) score += 15
//password is just a nubers or chars
if (password.match(/^\w+$/) || password.match(/^\d+$/) ) score -= 10
//verifing 0 < score < 100
if ( score < 0 ) score = 0
if ( score > 100 ) score = 100
if (score < 34 ) return badPass
if (score < 68 ) return goodPass
return strongPass
}
// checkRepetition(1,'aaaaaaabcbc') = 'abcbc'
// checkRepetition(2,'aaaaaaabcbc') = 'aabc'
// checkRepetition(2,'aaaaaaabcdbcd') = 'aabcd'
function checkRepetition(pLen,str) {
res = ""
for ( i=0; i<str.length ; i++ ) {
repeated=true
for (j=0;j < pLen && (j+i+pLen) < str.length;j++)
repeated=repeated && (str.charAt(j+i)==str.charAt(j+i+pLen))
if (j<pLen) repeated=false
if (repeated) {
i+=pLen-1
repeated=false
}
else {
res+=str.charAt(i)
}
}
return res
}

View File

@ -22,15 +22,15 @@ function profile_js ( ) {
jQuery(res).removeClass('short bad good strong');
if ( strength == 'Bad' ) {
if ( strength == pwsL10n.bad ) {
jQuery(res).addClass('bad');
jQuery(res).html( pwsL10n.bad );
}
else if ( strength == 'Good' ) {
else if ( strength == pwsL10n.good ) {
jQuery(res).addClass('good');
jQuery(res).html( pwsL10n.good );
}
else if ( strength == 'Strong' ) {
else if ( strength == pwsL10n.strong ) {
jQuery(res).addClass('strong');
jQuery(res).html( pwsL10n.strong );
}