June 25 - Optimize codes

This commit is contained in:
2026-06-25 16:40:10 -04:00
parent b4cb292afa
commit ea3648ad90
10 changed files with 85 additions and 56 deletions
+2 -18
View File
@@ -46,23 +46,7 @@
</p>
</div>
<script>
(function() {
var input = document.getElementById('password');
var fill = document.getElementById('pw-fill');
var lbl = document.getElementById('pw-label');
var map = ['pw-weak','pw-weak','pw-fair','pw-strong','pw-great','pw-great'];
var lbls = ['Weak','Weak','Fair','Strong','Very strong','Very strong'];
input.addEventListener('input', function() {
if (!this.value) { fill.className='pw-strength-fill'; lbl.className='pw-strength-label'; lbl.textContent=''; return; }
var pw=this.value, s=0;
if (pw.length>=8) s++; if (pw.length>=12) s++;
if (/[A-Z]/.test(pw)) s++; if (/[0-9]/.test(pw)) s++; if (/[^A-Za-z0-9]/.test(pw)) s++;
fill.className='pw-strength-fill '+map[s];
lbl.className='pw-strength-label '+map[s];
lbl.textContent=lbls[s];
});
}());
</script>
<script src="{{ url_for('static', filename='js/pw-strength.js') }}"></script>
<script>attachPasswordStrength('password', 'pw-fill', 'pw-label');</script>
</body>
</html>