芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/cansahcab.gob.mx/media/system/js/fields/passwordstrength.min.js
class PasswordStrength{constructor(t){this.lowercase=parseInt(t.lowercase,10)||0,this.uppercase=parseInt(t.uppercase,10)||0,this.numbers=parseInt(t.numbers,10)||0,this.special=parseInt(t.special,10)||0,this.length=parseInt(t.length,10)||12}getScore(t){let e=0,r=0;return["lowercase","uppercase","numbers","special","length"].forEach((t=>{this[t]>0&&(r+=1)})),e+=this.constructor.calc(t,/[a-z]/g,this.lowercase,r),e+=this.constructor.calc(t,/[A-Z]/g,this.uppercase,r),e+=this.constructor.calc(t,/[0-9]/g,this.numbers,r),e+=this.constructor.calc(t,/[\$\!\#\?\=\;\:\*\-\_\€\%\&\(\)\`\´]/g,this.special,r),e+=1===r?t.length>this.length?100:100/this.length*t.length:t.length>this.length?100/r:100/r/this.length*t.length,e}static calc(t,e,r,s){const a=t.match(e);return a&&a.length>r&&0!==r?100/s:a&&r>0?100/s/r*a.length:0}}((t,e)=>{e.addEventListener("DOMContentLoaded",(()=>{const r=[].slice.call(e.querySelectorAll(".js-password-strength"));r.forEach(((r,s)=>{let a="";r.value.length||(a=0);const n=e.createElement("meter");n.setAttribute("id",`progress-${s}`),n.setAttribute("min",0),n.setAttribute("max",100),n.setAttribute("low",40),n.setAttribute("high",99),n.setAttribute("optimum",100),n.value=a;const i=e.createElement("div");i.setAttribute("class","text-center"),i.setAttribute("id",`password-${s}`),i.setAttribute("aria-live","polite"),r.parentNode.insertAdjacentElement("afterEnd",i),r.parentNode.insertAdjacentElement("afterEnd",n),r.value.length>0&&r.setAttribute("required",!0),r.addEventListener("keyup",(({target:r})=>{(r=>{const s=e.querySelector("meter"),a=r.getAttribute("data-min-length"),n=r.getAttribute("data-min-integers"),i=r.getAttribute("data-min-symbols"),l=r.getAttribute("data-min-uppercase"),c=r.getAttribute("data-min-lowercase"),u=new PasswordStrength({lowercase:c||0,uppercase:l||0,numbers:n||0,special:i||0,length:a||12}).getScore(r.value),o=s.getAttribute("id").replace(/^\D+/g,""),g=r.parentNode.parentNode.querySelector(`#password-${o}`);g.innerText=100===u?t.Text._("JFIELD_PASSWORD_INDICATE_COMPLETE"):t.Text._("JFIELD_PASSWORD_INDICATE_INCOMPLETE"),s.value=u,r.value.length||(g.innerText="",r.setAttribute("required",""))})(r)}))})),r[0]&&e.formvalidator.setHandler("password-strength",(t=>{const r=e.querySelectorAll(".js-password-strength"),s=r[0].getAttribute("data-min-length"),a=r[0].getAttribute("data-min-integers"),n=r[0].getAttribute("data-min-symbols"),i=r[0].getAttribute("data-min-uppercase"),l=r[0].getAttribute("data-min-lowercase");return 100===new PasswordStrength({lowercase:l||0,uppercase:i||0,numbers:a||0,special:n||0,length:s||12}).getScore(t)}))}))})(Joomla,document);