Changeset 9276
- Timestamp:
- 10/22/2008 04:20:50 AM (16 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/js/password-strength-meter.js
r8722 r9276 1 1 // Password strength meter 2 // This jQuery plugin is written by firas kassem [2007.04.05]3 // Firas Kassem phiras.wordpress.com || phiras at gmail {dot} com4 // for more information : http://phiras.wordpress.com/2007/04/08/password-strength-meter-a-jquery-plugin/5 2 6 3 function passwordStrength(password,username) { 7 var shortPass = 1, badPass = 2, goodPass = 3, strongPass = 4 , score = 0, d, s, u, l;4 var shortPass = 1, badPass = 2, goodPass = 3, strongPass = 4; 8 5 9 6 //password < 4 10 7 if (password.length < 4 ) { return shortPass }; 11 8 … … 13 10 if (password.toLowerCase()==username.toLowerCase()) return badPass; 14 11 15 //password length 16 score += password.length * 4; 17 score += ( checkRepetition(1,password).length - password.length ) * 1; 18 score += ( checkRepetition(2,password).length - password.length ) * 1; 19 score += ( checkRepetition(3,password).length - password.length ) * 1; 20 score += ( checkRepetition(4,password).length - password.length ) * 1; 21 22 d = password.match(/\d/g); 23 s = password.match(/[^\d\w]/g); 24 u = password.match(/[A-Z]/g); 25 l = password.match(/[a-z]/g); 26 27 //password has 3 numbers 28 if ( d && d.length > 2 ) score += 5; 29 30 //password has 2 sybols 31 if ( s && s.length > 1 ) score += 10; 32 33 //password has Upper and Lower chars 34 if ( u && l ) score += 10; 35 36 //password has number and chars 37 if ( u && l && d ) score += 15; 38 // 39 //password has number and symbol 40 if ( s && d ) score += 15; 41 42 //password has Upper char and symbol 43 if ( u && s ) score += 15; 44 45 //password is just a nubers or chars 46 if ( ! s ) score -= 10; 47 48 //verifing 0 < score < 100 49 if ( score < 0 ) score = 0; 50 if ( score > 100 ) score = 100; 51 52 if ( score < 34 ) return badPass; 53 if ( score < 68 || password.length < 7 ) return goodPass; 12 var symbolSize = 0; 13 if (password.match(/[0-9]/)) symbolSize +=10; 14 if (password.match(/[a-z]/)) symbolSize +=26; 15 if (password.match(/[A-Z]/)) symbolSize +=26; 16 if (password.match(/[^a-zA-Z0-9]/)) symbolSize +=31; 17 18 var natLog = Math.log( Math.pow(symbolSize,password.length) ); 19 var score = natLog / Math.LN2; 20 if (score < 40 ) return badPass 21 if (score < 56 ) return goodPass 54 22 return strongPass; 55 23 } 56 57 58 // checkRepetition(1,'aaaaaaabcbc') = 'abcbc'59 // checkRepetition(2,'aaaaaaabcbc') = 'aabc'60 // checkRepetition(2,'aaaaaaabcdbcd') = 'aabcd'61 62 function checkRepetition(pLen,str) {63 res = ""64 for ( i=0; i<str.length ; i++ ) {65 repeated=true66 for (j=0;j < pLen && (j+i+pLen) < str.length;j++)67 repeated=repeated && (str.charAt(j+i)==str.charAt(j+i+pLen))68 if (j<pLen) repeated=false69 if (repeated) {70 i+=pLen-171 repeated=false72 }73 else {74 res+=str.charAt(i)75 }76 }77 return res78 }79 -
trunk/wp-includes/script-loader.php
r9243 r9276 148 148 $scripts->add( 'admin-tags', '/wp-admin/js/tags.js', array('wp-lists', 'columns', 'settings-box'), '20080925' ); 149 149 $scripts->add( 'admin-custom-fields', '/wp-admin/js/custom-fields.js', array('wp-lists'), '20070823' ); 150 $scripts->add( 'password-strength-meter', '/wp-admin/js/password-strength-meter.js', array('jquery'), '2008 0824' );150 $scripts->add( 'password-strength-meter', '/wp-admin/js/password-strength-meter.js', array('jquery'), '20081021' ); 151 151 $scripts->localize( 'password-strength-meter', 'pwsL10n', array( 152 152 'empty' => __('Strength indicator'),
Note: See TracChangeset
for help on using the changeset viewer.