aboutsummaryrefslogtreecommitdiff
path: root/gn2/wqflask/static/new/javascript/password_strength.js
diff options
context:
space:
mode:
Diffstat (limited to 'gn2/wqflask/static/new/javascript/password_strength.js')
-rw-r--r--gn2/wqflask/static/new/javascript/password_strength.js57
1 files changed, 57 insertions, 0 deletions
diff --git a/gn2/wqflask/static/new/javascript/password_strength.js b/gn2/wqflask/static/new/javascript/password_strength.js
new file mode 100644
index 00000000..a8a45f7d
--- /dev/null
+++ b/gn2/wqflask/static/new/javascript/password_strength.js
@@ -0,0 +1,57 @@
+// Generated by CoffeeScript 1.8.0
+
+$(function() {
+ var word_score;
+ $("#password").keyup(function() {
+ var crack_time, display, passtext, result, word;
+ passtext = $(this).val();
+ result = zxcvbn(passtext);
+ if (passtext.length < 6) {
+ let error_message = `<strong style="color:red;">the password must have a length greater than six characters</strong>`
+ $("#password_strength").html(error_message);
+ return $("#password_alert").fadeIn();
+ } else {
+ word = word_score(result.score);
+ crack_time = result.crack_times_display.online_throttling_100_per_hour;
+ if (crack_time === "instant") {
+ crack_time = "a second";
+ }
+ display = `This is ${word} password.`
+ $("#password_strength").html(display);
+ return $("#password_alert").fadeIn();
+ }
+ });
+ return word_score = function(num_score) {
+ num_score = parseInt(num_score);
+ console.log("num_score is:", num_score);
+
+ let passwordFeedback = {
+ 0:{
+ color:"#cc1818",
+ feedback:"a weak"
+ },
+
+ 1:{
+ color:"#cc1818",
+ feedback:"a bad"
+ },
+
+ 2:{
+ color:"#f59105",
+ feedback:"a mediocre"
+ },
+
+ 3:{
+ color:"#44ba34",
+ feedback:"a strong"
+ },
+ 4:{
+ color:"green",
+ feedback:"a stronger"
+ }
+ }
+
+ let mappingResult = `<strong style="color:${passwordFeedback[num_score].color};">${passwordFeedback[num_score].feedback}</strong>`
+ return mappingResult;
+ };
+});