From 97b3f8a830821829c1a2b56b4e8c82ceec7a668c Mon Sep 17 00:00:00 2001 From: lesion Date: Sat, 11 Aug 2018 01:41:17 +0200 Subject: [PATCH] rifiniture --- views/password.pug | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/views/password.pug b/views/password.pug index 2e7cd4e..698e0ea 100644 --- a/views/password.pug +++ b/views/password.pug @@ -2,15 +2,31 @@ extends layout block content p. - Bla bla bla qui devi scegliere una password + Bla bla bla qui devi scegliere una buona password input#password(type="password", name="password") p#crackTime + p#feedback + p#sequence + + a#vinto(style="visibility: hidden") vinto script(src="/js/zxcvbn.js") script. var crackTime = document.getElementById('crackTime') + var feedback = document.getElementById('feedback') + var sequence = document.getElementById('sequence') + var vinto = document.getElementById('vinto') + document.getElementById('password').oninput = function(ev, t) { var ret = zxcvbn(this.value) - crackTime.innerHTML = ret.crack_times_display.offline_fast_hashing_1e10_per_second; - } \ No newline at end of file + console.log(ret) + crackTime.innerHTML = 'A craccarla ci metto circa ' + ret.crack_times_display.offline_slow_hashing_1e4_per_second; + feedback.innerHTML = ret.feedback.suggestions.join(', ') + sequence.innerHTML = ret.sequence.map(s => s.pattern).join(' ,') + if (ret.score === 4){ + vinto.style.visibility = 'visible'; + } else { + vinto.style.visibility = 'hidden'; + } + }