window.ds=window.ds||{};ds.password={defaults:{displayMinChar:false,minChar:8,minCharText:"You must enter a minimum of %d characters",colors:["#f00","#c06","#f60","#3c0","#3f0"],scores:[20,30,43,50],verdicts:[_lg("Faible"),_lg("Normal"),_lg("Moyen"),_lg("Fort"),_lg("Très fort")],raisePower:1.4,contenant:null,debug:false},ruleScores:{length:0,lowercase:1,uppercase:3,one_number:3,three_numbers:5,one_special_char:3,two_special_char:5,upper_lower_combo:2,letter_number_combo:2,letter_number_char_combo:2},rules:{length:true,lowercase:true,uppercase:true,one_number:true,three_numbers:true,one_special_char:true,two_special_char:true,upper_lower_combo:true,letter_number_combo:true,letter_number_char_combo:true},validationRules:{length:function(C,D){ds.password.tooShort=false;var A=C.length,B=Math.pow(A,ds.password.options.raisePower);if(A<ds.password.options.minChar){B=(B-100);ds.password.tooShort=true}return B},lowercase:function(A,B){return A.match(/[a-z]/)&&B},uppercase:function(A,B){return A.match(/[A-Z]/)&&B},one_number:function(A,B){return A.match(/\d+/)&&B},three_numbers:function(A,B){return A.match(/(.*[0-9].*[0-9].*[0-9])/)&&B},one_special_char:function(A,B){return A.match(/.[!,@,#,$,%,\^,&,*,?,_,~]/)&&B},two_special_char:function(A,B){return A.match(/(.*[!,@,#,$,%,\^,&,*,?,_,~].*[!,@,#,$,%,\^,&,*,?,_,~])/)&&B},upper_lower_combo:function(A,B){return A.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)&&B},letter_number_combo:function(A,B){return A.match(/([a-zA-Z])/)&&A.match(/([0-9])/)&&B},letter_number_char_combo:function(A,B){return A.match(/([a-zA-Z0-9].*[!,@,#,$,%,\^,&,*,?,_,~])|([!,@,#,$,%,\^,&,*,?,_,~].*[a-zA-Z0-9])/)&&B}},attachWidget:function(C){var B=ds.password,A=['<div class="password-strength">'];if(B.options.displayMinChar&&!B.tooShort){A.push('<span class="password-min-char">'+B.options.minCharText.replace("%d",B.options.minChar)+"</span>")}A.push('<span class="password-strength-bar"></span>');A.push("</div>");A=A.join("");if(B.options.contenant){B.options.contenant.html(A)}else{jQuery(C).after(A)}},debugOutput:function(A){if(typeof console.log==="function"){console.log(ds.password)}else{alert(ds.password)}},addRule:function(B,E,D,C){var A=ds.password;A.rules[B]=C;A.ruleScores[B]=D;A.validationRules[B]=E;return true},init:function(C,B){var A=ds.password;A.options=jQuery.extend({},A.defaults,B);A.attachWidget(C);jQuery(C).keyup(function(){A.calculateScore(jQuery(this).val())});if(A.options.debug){A.debugOutput()}},calculateScore:function(D){var B=ds.password;B.totalscore=0;B.width=0;for(var C in B.rules){if(B.rules.hasOwnProperty(C)){if(B.rules[C]===true){var E=B.ruleScores[C];var A=B.validationRules[C](D,E);if(A){B.totalscore+=A}}if(B.totalscore<=B.options.scores[0]){B.strColor=B.options.colors[0];B.strText=B.options.verdicts[0];B.width="1"}else{if(B.totalscore>B.options.scores[0]&&B.totalscore<=B.options.scores[1]){B.strColor=B.options.colors[1];B.strText=B.options.verdicts[1];B.width="25"}else{if(B.totalscore>B.options.scores[1]&&B.totalscore<=B.options.scores[2]){B.strColor=B.options.colors[2];B.strText=B.options.verdicts[2];B.width="50"}else{if(B.totalscore>B.options.scores[2]&&B.totalscore<=B.options.scores[3]){B.strColor=B.options.colors[3];B.strText=B.options.verdicts[3];B.width="75"}else{B.strColor=B.options.colors[4];B.strText=B.options.verdicts[4];B.width="99"}}}}jQuery(".password-strength-bar").stop();if(B.options.displayMinChar&&!B.tooShort){jQuery(".password-min-char").hide()}else{jQuery(".password-min-char").show()}jQuery(".password-strength-bar").css({display:"block","border-color":B.strColor,width:B.width+"%"}).text(B.strText)}}}};jQuery.extend(jQuery.fn,{pstrength:function(A){return this.each(function(){ds.password.init(this,A)})}});jQuery.extend(jQuery.fn.pstrength,{addRule:function(A,D,C,B){ds.password.addRule(A,D,C,B);return true},changeScore:function(A,B){ds.password.ruleScores[A]=B;return true},ruleActive:function(B,A){ds.password.rules[B]=A;return true}});
