About page: Cache our zxcvbn calls and limit the variation of the animation.
Diff is mostly whitespace. props jorbin, azaozz. fixes #25603. git-svn-id: https://develop.svn.wordpress.org/trunk@25884 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
1d33726b1a
commit
ed15997210
@ -2,10 +2,19 @@
|
||||
var password = 'Gosh, WordPress is grand.',
|
||||
$input = $('#pass'),
|
||||
shouldAnimate = true,
|
||||
timesForAnimation = [280, 300, 305, 310, 315, 325, 330, 345, 360, 370, 380, 400, 450, 500, 600],
|
||||
resultsCache = {},
|
||||
indicatorString = $('#pass-strength-result').text();
|
||||
|
||||
function updateResult(){
|
||||
var strength = wp.passwordStrength.meter($input.val(), [], $input.val());
|
||||
var strength;
|
||||
|
||||
if ( typeof( resultsCache[ $input.val() ]) === 'undefined') {
|
||||
strength = wp.passwordStrength.meter($input.val(), [], $input.val());
|
||||
resultsCache[ $input.val() ] = strength;
|
||||
} else {
|
||||
strength = resultsCache[ $input.val() ];
|
||||
}
|
||||
|
||||
$('#pass-strength-result').removeClass('short bad good strong');
|
||||
switch ( strength ) {
|
||||
@ -34,13 +43,18 @@
|
||||
if ($input.val().length < password.length){
|
||||
$input.val( password.substr(0, $input.val().length + 1) );
|
||||
updateResult();
|
||||
|
||||
// Look like real typing by changing the speed new letters are added each time
|
||||
setTimeout( animate, ( timesForAnimation[ Math.floor( Math.random() * timesForAnimation.length ) ] ) );
|
||||
} else {
|
||||
resetMeter();
|
||||
|
||||
// When we reset, let's wait a bit longer than normal to start again
|
||||
setTimeout(animate, 700);
|
||||
}
|
||||
// Look like real typing by changing the speed new letters are added each time
|
||||
setTimeout(animate, 220 + Math.floor(Math.random() * ( 800 - 220)) );
|
||||
|
||||
}
|
||||
//
|
||||
|
||||
function begin(){
|
||||
// we async load zxcvbn, so we need to make sure it's loaded before starting
|
||||
if (typeof(zxcvbn) !== 'undefined')
|
||||
|
Loading…
Reference in New Issue
Block a user