1 2function checkPasswordStrength( $pass1, 3 $pass2, 4 $strengthResult, 5 $submitButton, 6 blacklistArray ) { 7 var pass1 = $pass1.val(); 8 var pass2 = $pass2.val(); 9 10 // Reset the form & meter 11 12 $strengthResult.removeClass( 'short bad good strong' ); 13 14 // Extend our blacklist array with those from the inputs & site data 15 blacklistArray = blacklistArray.concat( wp.passwordStrength.userInputBlacklist() ) 16 17 // Get the password strength 18 var strength = wp.passwordStrength.meter( pass1, blacklistArray, pass2 ); 19 20 // Add the strength meter results 21 switch ( strength ) { 22 23 case 2: 24 $strengthResult.addClass( 'bad' ).html( pwsL10n.bad ); 25 break; 26 27 case 3: 28 $strengthResult.addClass( 'good' ).html( pwsL10n.good ); 29 break; 30 31 case 4: 32 $strengthResult.addClass( 'strong' ).html( pwsL10n.strong ); 33 break; 34 35 case 5: 36 $strengthResult.addClass( 'short' ).html( pwsL10n.mismatch ); 37 break; 38 39 default: 40 $strengthResult.addClass( 'short' ).html( pwsL10n.short ); 41 42 } 43 44 // The meter function returns a result even if pass2 is empty, 45 // enable only the submit button if the password is strong and 46 // both passwords are filled up 47 48 return strength; 49} 50 51jQuery( document ).ready( function( $ ) { 52 // Binding to trigger checkPasswordStrength 53 $( 'body' ).on( 'keyup', 'input[name=pass1], input[name=pass2]', 54 function( event ) { 55 checkPasswordStrength( 56 $('input[name=pass1]'), // First password field 57 $('input[name=pass2]'), // Second password field 58 $('#pass-strength-result'), // Strength meter 59 $('input[type=submit]'), // Submit button 60 ['black', 'listed', 'word'] // Blacklisted words 61 ); 62 } 63 ); 64});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.