diff options
author | Alexander_Kabui | 2024-01-02 13:21:07 +0300 |
---|---|---|
committer | Alexander_Kabui | 2024-01-02 13:21:07 +0300 |
commit | 70c4201b332e0e2c0d958428086512f291469b87 (patch) | |
tree | aea4fac8782c110fc233c589c3f0f7bd34bada6c /gn2/wqflask/static/new/javascript/password_strength.js | |
parent | 5092eb42f062b1695c4e39619f0bd74a876cfac2 (diff) | |
parent | 965ce5114d585624d5edb082c710b83d83a3be40 (diff) | |
download | genenetwork2-70c4201b332e0e2c0d958428086512f291469b87.tar.gz |
merge changes
Diffstat (limited to 'gn2/wqflask/static/new/javascript/password_strength.js')
-rw-r--r-- | gn2/wqflask/static/new/javascript/password_strength.js | 57 |
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; + }; +}); |