Skip to content

Commit

Permalink
Merge pull request #2 from RandomArray/patch-1
Browse files Browse the repository at this point in the history
Wait until all keyup events are done before scoring password.
  • Loading branch information
davidstutz committed Jul 22, 2016
2 parents d04b4e9 + 4b731fc commit ade959f
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions dist/js/bootstrap-strength-meter.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
var template = '<div class="progress"><div class="progress-bar" role="progressbar"></div></div>';
var progress;
var progressBar;

var passcheckTimeout;
var core = {

/**
Expand All @@ -51,10 +51,21 @@
input.on('keyup', core.keyup)
.keyup();
},
queue: function(event){
var password = $(event.target).val();
var value = 0;

if (password.length > 0) {
var score = new Score(password);
value = score.calculateEntropyScore(settings.passwordScore.options, settings.passwordScore.append);
}

core.update(value);
},

/**
* Update progress bar.
*
*
* @param {string} value
*/
update: function(value) {
Expand All @@ -80,25 +91,19 @@

/**
* Event binding on password input.
*
*
* @param {Object} event
*/
keyup: function(event) {
var password = $(event.target).val();
var value = 0;

if (password.length > 0) {
var score = new Score(password);
value = score.calculateEntropyScore(settings.passwordScore.options, settings.passwordScore.append);
}

core.update(value);
if(passcheckTimeout)clearTimeout(passcheckTimeout);
passcheckTimeout = setTimeout( function(){
core.queue(event);
},500);
}
};

core.init();
},

text: function(input, options) {

var defaults = {
Expand Down Expand Up @@ -135,7 +140,7 @@

/**
* Update text element.
*
*
* @param {string} value
*/
update: function(value) {
Expand All @@ -153,7 +158,7 @@

/**
* Event binding on input element.
*
*
* @param {Object} event
*/
keyup: function(event) {
Expand Down Expand Up @@ -212,7 +217,7 @@

/**
* Update tooltip.
*
*
* @param {string} value
*/
update: function(value) {
Expand All @@ -228,7 +233,7 @@

/**
* Event binding on input element.
*
*
* @param {Object} event
*/
keyup: function(event) {
Expand Down

0 comments on commit ade959f

Please sign in to comment.