// 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 = `the password must have a length greater than six characters` $("#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 = `${passwordFeedback[num_score].feedback}` return mappingResult; }; });