diff --git a/public/site_assets/mpos/js/pwcheck.js b/public/site_assets/mpos/js/pwcheck.js new file mode 100644 index 00000000..5433d012 --- /dev/null +++ b/public/site_assets/mpos/js/pwcheck.js @@ -0,0 +1,78 @@ +function scorePassword(pass) { + var score = 0; + if (!pass) + return score; + var letters = new Object(); + for (var i=0; i= 80) + return "Excellent"; + if (score >= 70) + return "Strong"; + if (score >= 50) + return "Good"; + if (score >= 40) + return "Weak"; + if (score >= 10) + return "Very weak"; + if (score < 10 && score > 1) + return "Extremely weak"; + return ""; +} +function getStrengthColor(pass) { + var score = scorePassword(pass) + if (score >= 80) + return "#390" + if (score >= 70) + return "#3C0" + if (score >= 50) + return "#399" + if (score >= 40) + return "#F60" + if (score >= 10) + return "#E00" + if (score < 10) + return "#C00" + return "#999" +} +function checkIfPasswordsMatch() { + var pwMatch = document.getElementById('pw_match'); + var field1 = document.getElementById('pw_field').value; + var field2 = document.getElementById('pw_field2').value; + if (field1 == field2 && field1 !== "" && field2 !== "") { + pwMatch.innerHTML = "Passwords match!"; + pwMatch.style.color = "#390"; + } else if (field1 == "" || field2 == ""){ + pwMatch.innerHTML = ""; + } else { + pwMatch.innerHTML = "Passwords don't match!"; + pwMatch.style.color = "#399"; + } +} +$(document).ready(function() { + $("#pw_field,#pw_field2").on("keypress keyup keydown", function() { + var fieldValue = document.getElementById('pw_field').value; + var pwStrength = document.getElementById('pw_strength'); + pwStrength.innerHTML = checkPassStrength(fieldValue); + pwStrength.style.color = getStrengthColor(fieldValue); + checkIfPasswordsMatch(); + }); +}); \ No newline at end of file diff --git a/public/templates/mpos/master.tpl b/public/templates/mpos/master.tpl index c20a966b..13159ce9 100644 --- a/public/templates/mpos/master.tpl +++ b/public/templates/mpos/master.tpl @@ -29,7 +29,7 @@ - + {if $GLOBAL.statistics.analytics.enabled} {$GLOBAL.statistics.analytics.code nofilter} {/if} diff --git a/public/templates/mpos/register/default.tpl b/public/templates/mpos/register/default.tpl index bea79a6f..eabec47f 100644 --- a/public/templates/mpos/register/default.tpl +++ b/public/templates/mpos/register/default.tpl @@ -14,10 +14,12 @@
- - + +

Strength

+ - +

+