1(function ($) { 2 var checkPasswordStrength = function ( 3 $pass1, 4 $pass2, 5 $strengthResult, 6 $submitButton, 7 blacklistArray 8 ) { 9 var pass1 = $pass1.val(); 10 var pass2 = $pass2.val(); 11 12 var minimumStrength = 4; 13 if (window.password_strength_meter.minimum) { 14 minimumStrength = parseInt(window.password_strength_meter.minimum); 15 } 16 17 if (pass1 === "") { 18 $submitButton.removeAttr("disabled"); 19 $strengthResult.removeClass("short bad good strong"); 20 } else { 21 // Reset the form & meter 22 $submitButton.attr("disabled", "disabled"); 23 $strengthResult.removeClass("short bad good strong"); 24 25 // Extend our blacklist array with those from the inputs & site data 26 blacklistArray = blacklistArray.concat( 27 wp.passwordStrength.userInputDisallowedList() 28 ); 29 30 // Get the password strength 31 var strength = wp.passwordStrength.meter( 32 pass1, 33 blacklistArray, 34 pass2 35 ); 36 37 // Add the strength meter results 38 switch (strength) { 39 case 2: 40 $strengthResult.addClass("bad").html(pwsL10n.bad); 41 break; 42 43 case 3: 44 $strengthResult.addClass("good").html(pwsL10n.good); 45 break; 46 47 case 4: 48 $strengthResult.addClass("strong").html(pwsL10n.strong); 49 break; 50 51 case 5: 52 $strengthResult.addClass("short").html(pwsL10n.mismatch); 53 break; 54 55 default: 56 $strengthResult.addClass("short").html(pwsL10n.short); 57 } 58 59 // The meter function returns a result even if pass2 is empty, 60 // enable only the submit button if the password is strong and 61 // both passwords are filled up 62 if (strength >= minimumStrength && pass1.trim() === pass2.trim()) { 63 $submitButton.removeAttr("disabled"); 64 } 65 } 66 return strength; 67 }; 68 69 $(document).ready(function ($) { 70 if ( 71 window.password_strength_meter && 72 window.password_strength_meter.password && 73 window.password_strength_meter.password_confirm 74 ) { 75 if (!$(window.password_strength_meter.password).length) { 76 window.console.warn( 77 "Password strength meter - window.password_strength_meter.password element â" + 78 window.password_strength_meter.password + 79 "â is unavailable" 80 ); 81 } else if ( 82 !$(window.password_strength_meter.password_confirm).length 83 ) { 84 window.console.warn( 85 "Password strength meter - window.password_strength_meter.password_confirm element â" + 86 window.password_strength_meter.password_confirm + 87 "â is unavailable" 88 ); 89 } else { 90 $("body").on( 91 "keyup", 92 window.password_strength_meter.password + 93 ", " + 94 window.password_strength_meter.password_confirm, 95 function (event) { 96 checkPasswordStrength( 97 $(window.password_strength_meter.password), // First password field 98 $(window.password_strength_meter.password_confirm), // Second password field 99 $( 100 "[data-password-strength-meter]", 101 $(this).closest(".acf-form") 102 ), 103 $("input[type=submit]"), // Submit button 104 [] // Blacklisted words 105 ); 106 } 107 ); 108 } 109 } 110 }); 111})(jQuery);
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.