This commit has been accessed 571 times via Git panel.
commit e0d6b4d84ca8446a2c98e174aacea7760e648bba
tree 36876c8e5853991e45464b09004086c043ad7726
parent 643ebb1b10f1fdc74e418c4bec3bec4a1832e3d6
author Engels Antonio <engels@majcms.org> 1343124006 +0800
committer Engels Antonio <engels@majcms.org> 1343124006 +0800
Consolidate password checking scripts in core.js
diff --git a/kartero-zxcvbn.js b/core.js
similarity index 99%
rename from kartero-zxcvbn.js
rename to core.js
index 3326efa..97e5ee1 100644
--- a/kartero-zxcvbn.js
+++ b/core.js
@@ -41,4 +41,5 @@ null,null],r:"cC,9(,0),lL,nN,tT".split(","),s:"nN,lL,/?,-_,zZ,vV".split(","),t:"
null,null,"-","9"],"+":["6","9","-",null,null,null,null,"3"],"-":["9","/","*",null,null,null,"+","6"],".":["0","2","3",null,null,null,null,null],"/":["=",null,null,null,"*","-","9","8"],"0":[null,"1","2","3",".",null,null,null],1:[null,null,"4","5","2","0",null,null],2:["1","4","5","6","3",".","0",null],3:["2","5","6","+",null,null,".","0"],4:[null,null,"7","8","5","2","1",null],5:"4,7,8,9,6,3,2,1".split(","),6:["5","8","9","-","+",null,"3","2"],7:[null,null,null,"=","8","5","4",null],8:["7",null,
"=","/","9","6","5","4"],9:"8,=,/,*,-,+,6,5".split(","),"=":[null,null,null,null,"/","9","8","7"]}};p=function(b){var a,d,c,e,f;a=0;for(c in b)f=b[c],a+=function(){var a,b,c;c=[];a=0;for(b=f.length;a<b;a++)(e=f[a])&&c.push(e);return c}().length;return a/=function(){var a;a=[];for(d in b)a.push(d);return a}().length};pa=p(E);ra=p(F);oa=function(){var b;b=[];for(v in E)b.push(v);return b}().length;qa=function(){var b;b=[];for(v in F)b.push(v);return b}().length;I=function(){return(new Date).getTime()};
window.zxcvbn=function(b,a){var d,c,e;c=I();if(null!=a){d=0;for(e=a.length;0<=e?d<e:d>e;0<=e?d++:d--)H[a[d]]=d+1}d=R(b);d=ja(b,d);d.calc_time=I()-c;return d};"function"===typeof zxcvbn_load_hook&&zxcvbn_load_hook()})();
-function eval(a){var b=zxcvbn(a);var c=b.score/4*392;if(a.length==0){document.getElementById("mtr").style.display="none";document.getElementById("ctd").innerHTML=""}else{document.getElementById("mtr").style.width=c+"px";document.getElementById("mtr").style.display="block";document.getElementById("ctd").innerHTML="<nobr>new password estimated crack time: <b>"+b.crack_time_display+"</b></nobr>"}if(b.score<3){document.getElementById("mtr").style.color="#ff6666";document.getElementById("mtr").style.border="#ff6666 solid 1px";document.getElementById("mtr").style.background="#ffbbbb";document.getElementById("mtr").style.boxShadow="inset 0 0 3px #ff6666, 0 0 1px #777";document.getElementById("mtr").style.MozBoxShadow="inset 0 0 3px #ff6666, 0 0 1px #777";document.getElementById("mtr").style.KhtmlBoxShadow="inset 0 0 3px #ff6666, 0 0 1px #777";document.getElementById("mtr").style.WebkitBoxShadow="inset 0 0 3px #ff6666, 0 0 1px #777"}else{document.getElementById("mtr").style.color="#74ae0b";document.getElementById("mtr").style.border="#74ae0b solid 1px";document.getElementById("mtr").style.background="#cde2a7";document.getElementById("mtr").style.boxShadow="inset 0 0 2px #74ae0b, 0 0 1px #777";document.getElementById("mtr").style.MozBoxShadow="inset 0 0 2px #74ae0b, 0 0 1px #777";document.getElementById("mtr").style.KhtmlBoxShadow="inset 0 0 2px #74ae0b, 0 0 1px #777";document.getElementById("mtr").style.WebkitBoxShadow="inset 0 0 2px #74ae0b, 0 0 1px #777"}}
+function eval(a){document.getElementById('usr_pw3').value="";document.getElementById('pmc1').innerHTML="new password";document.getElementById('pmc2').innerHTML="new password";var b=zxcvbn(a);var c=b.score/4*392;if(a.length==0){document.getElementById("mtr").style.display="none";document.getElementById("ctd").innerHTML=""}else{document.getElementById("mtr").style.width=c+"px";document.getElementById("mtr").style.display="block";document.getElementById("ctd").innerHTML="<nobr>new password estimated crack time: <b>"+b.crack_time_display+"</b></nobr>"}if(b.score<3){document.getElementById("mtr").style.color="#ff6666";document.getElementById("mtr").style.border="#ff6666 solid 1px";document.getElementById("mtr").style.background="#ffbbbb";document.getElementById("mtr").style.boxShadow="inset 0 0 3px #ff6666, 0 0 1px #777";document.getElementById("mtr").style.MozBoxShadow="inset 0 0 3px #ff6666, 0 0 1px #777";document.getElementById("mtr").style.KhtmlBoxShadow="inset 0 0 3px #ff6666, 0 0 1px #777";document.getElementById("mtr").style.WebkitBoxShadow="inset 0 0 3px #ff6666, 0 0 1px #777"}else{document.getElementById("mtr").style.color="#74ae0b";document.getElementById("mtr").style.border="#74ae0b solid 1px";document.getElementById("mtr").style.background="#cde2a7";document.getElementById("mtr").style.boxShadow="inset 0 0 2px #74ae0b, 0 0 1px #777";document.getElementById("mtr").style.MozBoxShadow="inset 0 0 2px #74ae0b, 0 0 1px #777";document.getElementById("mtr").style.KhtmlBoxShadow="inset 0 0 2px #74ae0b, 0 0 1px #777";document.getElementById("mtr").style.WebkitBoxShadow="inset 0 0 2px #74ae0b, 0 0 1px #777"}}
+function same(a){var b=document.getElementById("usr_pw2").value;if(b!=a){document.getElementById("pmc1").innerHTML="new passwords do not match";document.getElementById("pmc2").innerHTML="new passwords do not match"}else{document.getElementById("pmc1").innerHTML="new password";document.getElementById("pmc2").innerHTML="new password"}}
diff --git a/index.php b/index.php
index 7666bc1..420a52b 100644
--- a/index.php
+++ b/index.php
@@ -1245,7 +1245,7 @@ echo "</tr>";
echo "</td></tr></table>";
echo "</div>";
- echo "<script type=\"text/javascript\" src=\"kartero-zxcvbn.js\" async></script>";
+ echo "<script type=\"text/javascript\" src=\"core.js\" async></script>";
echo "<style> @-webkit-keyframes strength { 0% { width: 0; } } @-moz-keyframes strength { 0% { width: 0; height: 11px; } } #mtr { width: 0; height: 11px; padding: 0; margin: 0; -webkit-animation-name: strength; -moz-animation-name: strength; -webkit-animation-duration: 1s; -moz-animation-duration: 1s; -webkit-animation-iteration-count: 1; -moz-animation-iteration-count: 1; -webkit-animation-timing-function: ease; -moz-animation-timing-function: ease; } </style>";
@@ -1265,7 +1265,7 @@ echo "</tr>";
echo "<tr bgcolor=\"#ffffff\"><td><table border=\"0\" cellspacing=\"1\" cellpadding=\"2\" bgcolor=\"#cccccc\" width=\"100%\"><tr bgcolor=\"#ffffff\"><td height=\"17\"><div id=\"mtr\" style=\"display: none;\"></div></td></tr></table></td><td id=\"ctd\"></td></tr>";
- echo "<tr bgcolor=\"#ffffff\"><td><input class=\"input\" type=\"password\" name=\"usr_pw2\" autocomplete=\"off\" maxlength=\"64\" onkeyup=\"eval(this.value)\"></td><td><nobr>new password";
+ echo "<tr bgcolor=\"#ffffff\"><td><input class=\"input\" type=\"password\" name=\"usr_pw2\" autocomplete=\"off\" maxlength=\"64\" onkeyup=\"eval(this.value)\" id=\"usr_pw2\"></td><td id=\"pmc1\"><nobr>new password";
if (isset($_POST['usr_pw1']) and !empty($_POST['usr_pw1']) and isset($_POST['usr_pw2']) and (strlen($_POST['usr_pw2']) < 8)) {
echo " <font color=\"red\">too short</font>";
@@ -1273,7 +1273,7 @@ echo "</tr>";
echo "</nobr></td></tr>";
- echo "<tr bgcolor=\"#ffffff\"><td><input class=\"input\" type=\"password\" name=\"usr_pw3\" autocomplete=\"off\" maxlength=\"64\"></td><td><nobr>new password";
+ echo "<tr bgcolor=\"#ffffff\"><td><input class=\"input\" type=\"password\" name=\"usr_pw3\" autocomplete=\"off\" maxlength=\"64\" onkeyup=\"same(this.value)\" id=\"usr_pw3\"></td><td id=\"pmc2\"><nobr>new password";
if (isset($_POST['usr_pw1']) and !empty($_POST['usr_pw1']) and isset($_POST['usr_pw3']) and (strlen($_POST['usr_pw3']) < 8)) {
echo " <font color=\"red\">too short</font>";
tree 36876c8e5853991e45464b09004086c043ad7726
parent 643ebb1b10f1fdc74e418c4bec3bec4a1832e3d6
author Engels Antonio <engels@majcms.org> 1343124006 +0800
committer Engels Antonio <engels@majcms.org> 1343124006 +0800
Consolidate password checking scripts in core.js
diff --git a/kartero-zxcvbn.js b/core.js
similarity index 99%
rename from kartero-zxcvbn.js
rename to core.js
index 3326efa..97e5ee1 100644
--- a/kartero-zxcvbn.js
+++ b/core.js
@@ -41,4 +41,5 @@ null,null],r:"cC,9(,0),lL,nN,tT".split(","),s:"nN,lL,/?,-_,zZ,vV".split(","),t:"
null,null,"-","9"],"+":["6","9","-",null,null,null,null,"3"],"-":["9","/","*",null,null,null,"+","6"],".":["0","2","3",null,null,null,null,null],"/":["=",null,null,null,"*","-","9","8"],"0":[null,"1","2","3",".",null,null,null],1:[null,null,"4","5","2","0",null,null],2:["1","4","5","6","3",".","0",null],3:["2","5","6","+",null,null,".","0"],4:[null,null,"7","8","5","2","1",null],5:"4,7,8,9,6,3,2,1".split(","),6:["5","8","9","-","+",null,"3","2"],7:[null,null,null,"=","8","5","4",null],8:["7",null,
"=","/","9","6","5","4"],9:"8,=,/,*,-,+,6,5".split(","),"=":[null,null,null,null,"/","9","8","7"]}};p=function(b){var a,d,c,e,f;a=0;for(c in b)f=b[c],a+=function(){var a,b,c;c=[];a=0;for(b=f.length;a<b;a++)(e=f[a])&&c.push(e);return c}().length;return a/=function(){var a;a=[];for(d in b)a.push(d);return a}().length};pa=p(E);ra=p(F);oa=function(){var b;b=[];for(v in E)b.push(v);return b}().length;qa=function(){var b;b=[];for(v in F)b.push(v);return b}().length;I=function(){return(new Date).getTime()};
window.zxcvbn=function(b,a){var d,c,e;c=I();if(null!=a){d=0;for(e=a.length;0<=e?d<e:d>e;0<=e?d++:d--)H[a[d]]=d+1}d=R(b);d=ja(b,d);d.calc_time=I()-c;return d};"function"===typeof zxcvbn_load_hook&&zxcvbn_load_hook()})();
-function eval(a){var b=zxcvbn(a);var c=b.score/4*392;if(a.length==0){document.getElementById("mtr").style.display="none";document.getElementById("ctd").innerHTML=""}else{document.getElementById("mtr").style.width=c+"px";document.getElementById("mtr").style.display="block";document.getElementById("ctd").innerHTML="<nobr>new password estimated crack time: <b>"+b.crack_time_display+"</b></nobr>"}if(b.score<3){document.getElementById("mtr").style.color="#ff6666";document.getElementById("mtr").style.border="#ff6666 solid 1px";document.getElementById("mtr").style.background="#ffbbbb";document.getElementById("mtr").style.boxShadow="inset 0 0 3px #ff6666, 0 0 1px #777";document.getElementById("mtr").style.MozBoxShadow="inset 0 0 3px #ff6666, 0 0 1px #777";document.getElementById("mtr").style.KhtmlBoxShadow="inset 0 0 3px #ff6666, 0 0 1px #777";document.getElementById("mtr").style.WebkitBoxShadow="inset 0 0 3px #ff6666, 0 0 1px #777"}else{document.getElementById("mtr").style.color="#74ae0b";document.getElementById("mtr").style.border="#74ae0b solid 1px";document.getElementById("mtr").style.background="#cde2a7";document.getElementById("mtr").style.boxShadow="inset 0 0 2px #74ae0b, 0 0 1px #777";document.getElementById("mtr").style.MozBoxShadow="inset 0 0 2px #74ae0b, 0 0 1px #777";document.getElementById("mtr").style.KhtmlBoxShadow="inset 0 0 2px #74ae0b, 0 0 1px #777";document.getElementById("mtr").style.WebkitBoxShadow="inset 0 0 2px #74ae0b, 0 0 1px #777"}}
+function eval(a){document.getElementById('usr_pw3').value="";document.getElementById('pmc1').innerHTML="new password";document.getElementById('pmc2').innerHTML="new password";var b=zxcvbn(a);var c=b.score/4*392;if(a.length==0){document.getElementById("mtr").style.display="none";document.getElementById("ctd").innerHTML=""}else{document.getElementById("mtr").style.width=c+"px";document.getElementById("mtr").style.display="block";document.getElementById("ctd").innerHTML="<nobr>new password estimated crack time: <b>"+b.crack_time_display+"</b></nobr>"}if(b.score<3){document.getElementById("mtr").style.color="#ff6666";document.getElementById("mtr").style.border="#ff6666 solid 1px";document.getElementById("mtr").style.background="#ffbbbb";document.getElementById("mtr").style.boxShadow="inset 0 0 3px #ff6666, 0 0 1px #777";document.getElementById("mtr").style.MozBoxShadow="inset 0 0 3px #ff6666, 0 0 1px #777";document.getElementById("mtr").style.KhtmlBoxShadow="inset 0 0 3px #ff6666, 0 0 1px #777";document.getElementById("mtr").style.WebkitBoxShadow="inset 0 0 3px #ff6666, 0 0 1px #777"}else{document.getElementById("mtr").style.color="#74ae0b";document.getElementById("mtr").style.border="#74ae0b solid 1px";document.getElementById("mtr").style.background="#cde2a7";document.getElementById("mtr").style.boxShadow="inset 0 0 2px #74ae0b, 0 0 1px #777";document.getElementById("mtr").style.MozBoxShadow="inset 0 0 2px #74ae0b, 0 0 1px #777";document.getElementById("mtr").style.KhtmlBoxShadow="inset 0 0 2px #74ae0b, 0 0 1px #777";document.getElementById("mtr").style.WebkitBoxShadow="inset 0 0 2px #74ae0b, 0 0 1px #777"}}
+function same(a){var b=document.getElementById("usr_pw2").value;if(b!=a){document.getElementById("pmc1").innerHTML="new passwords do not match";document.getElementById("pmc2").innerHTML="new passwords do not match"}else{document.getElementById("pmc1").innerHTML="new password";document.getElementById("pmc2").innerHTML="new password"}}
diff --git a/index.php b/index.php
index 7666bc1..420a52b 100644
--- a/index.php
+++ b/index.php
@@ -1245,7 +1245,7 @@ echo "</tr>";
echo "</td></tr></table>";
echo "</div>";
- echo "<script type=\"text/javascript\" src=\"kartero-zxcvbn.js\" async></script>";
+ echo "<script type=\"text/javascript\" src=\"core.js\" async></script>";
echo "<style> @-webkit-keyframes strength { 0% { width: 0; } } @-moz-keyframes strength { 0% { width: 0; height: 11px; } } #mtr { width: 0; height: 11px; padding: 0; margin: 0; -webkit-animation-name: strength; -moz-animation-name: strength; -webkit-animation-duration: 1s; -moz-animation-duration: 1s; -webkit-animation-iteration-count: 1; -moz-animation-iteration-count: 1; -webkit-animation-timing-function: ease; -moz-animation-timing-function: ease; } </style>";
@@ -1265,7 +1265,7 @@ echo "</tr>";
echo "<tr bgcolor=\"#ffffff\"><td><table border=\"0\" cellspacing=\"1\" cellpadding=\"2\" bgcolor=\"#cccccc\" width=\"100%\"><tr bgcolor=\"#ffffff\"><td height=\"17\"><div id=\"mtr\" style=\"display: none;\"></div></td></tr></table></td><td id=\"ctd\"></td></tr>";
- echo "<tr bgcolor=\"#ffffff\"><td><input class=\"input\" type=\"password\" name=\"usr_pw2\" autocomplete=\"off\" maxlength=\"64\" onkeyup=\"eval(this.value)\"></td><td><nobr>new password";
+ echo "<tr bgcolor=\"#ffffff\"><td><input class=\"input\" type=\"password\" name=\"usr_pw2\" autocomplete=\"off\" maxlength=\"64\" onkeyup=\"eval(this.value)\" id=\"usr_pw2\"></td><td id=\"pmc1\"><nobr>new password";
if (isset($_POST['usr_pw1']) and !empty($_POST['usr_pw1']) and isset($_POST['usr_pw2']) and (strlen($_POST['usr_pw2']) < 8)) {
echo " <font color=\"red\">too short</font>";
@@ -1273,7 +1273,7 @@ echo "</tr>";
echo "</nobr></td></tr>";
- echo "<tr bgcolor=\"#ffffff\"><td><input class=\"input\" type=\"password\" name=\"usr_pw3\" autocomplete=\"off\" maxlength=\"64\"></td><td><nobr>new password";
+ echo "<tr bgcolor=\"#ffffff\"><td><input class=\"input\" type=\"password\" name=\"usr_pw3\" autocomplete=\"off\" maxlength=\"64\" onkeyup=\"same(this.value)\" id=\"usr_pw3\"></td><td id=\"pmc2\"><nobr>new password";
if (isset($_POST['usr_pw1']) and !empty($_POST['usr_pw1']) and isset($_POST['usr_pw3']) and (strlen($_POST['usr_pw3']) < 8)) {
echo " <font color=\"red\">too short</font>";