CoreFiles by mySites.guru
passwordstrength.es6.min.js1 lines, 2,885 bytes, from Joomla_4.0.0-beta3-Beta-Full_Package.zip
Raw History Compare with 4.0.0-beta2
md5
8be42b9e6e3860d4195397150ec5f3fd
sha1
c8675c443c56edc6a9d2f252f4b8a892be81f33a
sha256
047f708d9b70a5304bf4190a7a70e4e4857eb962b31a3219f3fa19477a8bf23c
class PasswordStrength{constructor(a){this.lowercase=parseInt(a.lowercase,10)||0,this.uppercase=parseInt(a.uppercase,10)||0,this.numbers=parseInt(a.numbers,10)||0,this.special=parseInt(a.special,10)||0,this.length=parseInt(a.length,10)||4}getScore(a){let b=0,c=0;return["lowercase","uppercase","numbers","special","length"].forEach(a=>{0<this[a]&&(c+=1)}),b+=this.constructor.calc(a,/[a-z]/g,this.lowercase,c),b+=this.constructor.calc(a,/[A-Z]/g,this.uppercase,c),b+=this.constructor.calc(a,/[0-9]/g,this.numbers,c),b+=this.constructor.calc(a,/[\$\!\#\?\=\;\:\*\-\_\€\%\&\(\)\`\´]/g,this.special,c),b+=1===c?a.length>this.length?100:100/this.length*a.length:a.length>this.length?100/c:100/c/this.length*a.length,b}static calc(a,b,c,d){const e=a.match(b);return e&&e.length>c&&0!==c?100/d:e&&0<c?100/d/c*e.length:0}}((a,b)=>{const c=c=>{const d=b.querySelector("meter"),e=c.getAttribute("data-min-length"),f=c.getAttribute("data-min-integers"),g=c.getAttribute("data-min-symbols"),h=c.getAttribute("data-min-uppercase"),j=c.getAttribute("data-min-lowercase"),k=new PasswordStrength({lowercase:j||0,uppercase:h||0,numbers:f||0,special:g||0,length:e||4}),l=k.getScore(c.value),m=d.getAttribute("id").replace(/^\D+/g,""),i=c.parentNode.parentNode.querySelector(`#password-${m}`);79<l&&(i.innerText=a.JText._("JFIELD_PASSWORD_INDICATE_COMPLETE")),64<l&&80>l&&(i.innerText=a.JText._("JFIELD_PASSWORD_INDICATE_INCOMPLETE")),50<l&&65>l&&(i.innerText=a.JText._("JFIELD_PASSWORD_INDICATE_INCOMPLETE")),40<l&&51>l&&(i.innerText=a.JText._("JFIELD_PASSWORD_INDICATE_INCOMPLETE")),41>l&&(i.innerText=a.JText._("JFIELD_PASSWORD_INDICATE_INCOMPLETE")),d.value=l,c.value.length||(i.innerText="",c.setAttribute("required",""))};b.addEventListener("DOMContentLoaded",()=>{const a=[].slice.call(b.querySelectorAll(".js-password-strength"));a.forEach((a,d)=>{let e="";a.value.length||(e=0);const f=b.createElement("meter");f.setAttribute("id",`progress-${d}`),f.setAttribute("min",0),f.setAttribute("max",100),f.setAttribute("low",40),f.setAttribute("high",60),f.setAttribute("optimum",80),f.value=e;const g=b.createElement("div");g.setAttribute("class","text-center"),g.setAttribute("id",`password-${d}`),g.setAttribute("aria-live","polite"),a.parentNode.insertAdjacentElement("afterEnd",g),a.parentNode.insertAdjacentElement("afterEnd",f),0<a.value.length&&a.setAttribute("required",!0),a.addEventListener("keyup",({target:a})=>{c(a)})}),a[0]&&b.formvalidator.setHandler("password-strength",a=>{const c=b.querySelectorAll(".js-password-strength"),d=c[0].getAttribute("data-min-length"),e=c[0].getAttribute("data-min-integers"),f=c[0].getAttribute("data-min-symbols"),g=c[0].getAttribute("data-min-uppercase"),h=c[0].getAttribute("data-min-lowercase"),i=new PasswordStrength({lowercase:h||0,uppercase:g||0,numbers:e||0,special:f||0,length:d||4}),j=i.getScore(a);return!(100!==j)})})})(Joomla,document);

The same content is in 3 releases, Joomla 4.0.0-beta to 4.0.0-beta3. See them all, or every version of this file.