function passwordWarning(text, score) {
var html = '';
switch (text) {
case 'Common names and surnames are easy to guess':
html = "The password you chose appears to be similar to a common name or surname.";
break;
case 'This is a top-10 common password':
html = "The password you chose is one of the 10 most common passwords that other people choose.";
break;
case 'This is a top-100 common password':
html = "The password you chose is one of the 100 most common passwords that other people choose.";
break;
case 'This is a very common password':
html = "The password you chose is very common.";
break;
case 'This is similar to a commonly used password':
html = "The password you chose is similar to a commonly used password.";
break;
}
if (score === 4) {
$("#password_feedback")
.removeClass('passwordBad')
.removeClass('passwordAcceptable')
.addClass('passwordGood');
html = 'Good password, as long as it\'s unique!<br />If you\'re not already, consider using a password manager such as <a target="_blank" href="https://github.com/keepassx/keepassx/" rel="noopener noreferrer">KeePassX</a>.';
} else if (score === 3) {
$("#password_feedback")
.addClass('passwordBad')
.removeClass('passwordAcceptable')
.removeClass('passwordGood');
html += "<br />If you use this password, it might be guessable by criminals. Please make your administrator account password more secure.";
} else if (score === 2) {
$("#password_feedback")
.addClass('passwordBad')
.removeClass('passwordAcceptable')
.removeClass('passwordGood');
html += "<br />If you use this password, it will be easily guessable by criminals. Please make your administrator account password more secure.";
} else {
$("#password_feedback")
.addClass('passwordBad')
.removeClass('passwordAcceptable')
.removeClass('passwordGood');
html += "<br />If you use this password, it will be <em>very</em> easily guessable by criminals. Please make your administrator account password more secure.";
}
$("#password_feedback").html(html);
}
$(document).ready(function() {
$("#passphrase").change(function() {
var zx = zxcvbn($("#passphrase").val());
console.log(JSON.stringify(zx));
passwordWarning(zx.feedback.warning, zx.score);
});
});
|