2 var password = 'Gosh, WordPress is grand.',
5 timesForAnimation = [280, 300, 305, 310, 315, 325, 330, 345, 360, 370, 380, 400, 450, 500, 600],
7 indicatorString = $('#pass-strength-result').text();
9 function updateResult(){
12 if ( typeof( resultsCache[ $input.val() ]) === 'undefined') {
13 strength = wp.passwordStrength.meter($input.val(), [], $input.val());
14 resultsCache[ $input.val() ] = strength;
16 strength = resultsCache[ $input.val() ];
19 $('#pass-strength-result').removeClass('short bad good strong');
22 $('#pass-strength-result').addClass('bad').html( pwsL10n['bad'] );
25 $('#pass-strength-result').addClass('good').html( pwsL10n['good'] );
28 $('#pass-strength-result').addClass('strong').html( pwsL10n['strong'] );
31 $('#pass-strength-result').addClass('short').html( pwsL10n['short'] );
34 function resetMeter(){
36 $('#pass-strength-result').text(indicatorString);
37 $('#pass-strength-result').removeClass('short bad good strong');
41 if (shouldAnimate === false)
43 if ($input.val().length < password.length){
44 $input.val( password.substr(0, $input.val().length + 1) );
47 // Look like real typing by changing the speed new letters are added each time
48 setTimeout( animate, ( timesForAnimation[ Math.floor( Math.random() * timesForAnimation.length ) ] ) );
52 // When we reset, let's wait a bit longer than normal to start again
53 setTimeout(animate, 700);
59 // we async load zxcvbn, so we need to make sure it's loaded before starting
60 if (typeof(zxcvbn) !== 'undefined')
63 setTimeout(begin,800);
66 // Turn off the animation on focus
67 $input.on('focus', function(){
68 shouldAnimate = false;
72 // Act like a normal password strength meter
73 $input.on('keyup', function(){
77 // Start the animation