CoreFiles by mySites.guru
passwordstrength.min.js4 lines, 2,750 bytes, from Joomla_6.1.0-Stable-Full_Package.zip
Raw History Compare with 6.0.4
md5
89ae4619020cfcbe10fbb0362800a6bf
sha1
e1dbaec29a416bc4736d1f373c078116918f0d45
sha256
ba9b9bf4d2a0ccb718ad407262d5d25b5312860e038bdadf490c28a6a3c89026
class PasswordStrength{constructor(e){this.lowercase=parseInt(e.lowercase,10)||0,this.uppercase=parseInt(e.uppercase,10)||0,this.numbers=parseInt(e.numbers,10)||0,this.special=parseInt(e.special,10)||0,this.length=parseInt(e.length,10)||12}getScore(e){let a=0,t=0;return["lowercase","uppercase","numbers","special","length"].forEach(r=>{this[r]>0&&(t+=1)}),a+=this.constructor.calc(e,/[a-z]/g,this.lowercase,t),a+=this.constructor.calc(e,/[A-Z]/g,this.uppercase,t),a+=this.constructor.calc(e,/[0-9]/g,this.numbers,t),a+=this.constructor.calc(e,/[@$!#?=;:*\-_€%&()`´+[\]{}'"\\|,.<>/~^]/g,this.special,t),t===1?a+=e.length>this.length?100:100/this.length*e.length:a+=e.length>this.length?100/t:100/t/this.length*e.length,a}static calc(e,a,t,s){const r=e.match(a);return r&&r.length>t&&t!==0?100/s:r&&t>0?100/s/t*r.length:0}}/**
 * @copyright  (C) 2020 Open Source Matters, Inc. <https://www.joomla.org>
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */((u,e)=>{const a=t=>{const s=e.querySelector("meter"),r=t.getAttribute("data-min-length"),c=t.getAttribute("data-min-integers"),n=t.getAttribute("data-min-symbols"),i=t.getAttribute("data-min-uppercase"),o=t.getAttribute("data-min-lowercase"),h=new PasswordStrength({lowercase:o||0,uppercase:i||0,numbers:c||0,special:n||0,length:r||12}).getScore(t.value),p=s.getAttribute("id").replace(/^\D+/g,""),l=t.parentNode.parentNode.querySelector(`#password-${p}`);l&&(h===100?l.innerText=u.Text._("JFIELD_PASSWORD_INDICATE_COMPLETE"):l.innerText=u.Text._("JFIELD_PASSWORD_INDICATE_INCOMPLETE"),s.value=h,t.value.length||(l.innerText="",t.setAttribute("required","")))};e.addEventListener("DOMContentLoaded",()=>{const t=e.querySelectorAll(".js-password-strength");t.forEach((s,r)=>{let c="";s.value.length||(c=0);const n=e.createElement("meter");n.setAttribute("id",`progress-${r}`),n.setAttribute("min",0),n.setAttribute("max",100),n.setAttribute("low",40),n.setAttribute("high",99),n.setAttribute("optimum",100),n.value=c;const i=e.createElement("output");i.setAttribute("id",`password-${r}`),i.setAttribute("for",s.id),s.parentNode.insertAdjacentElement("afterEnd",i),s.parentNode.insertAdjacentElement("afterEnd",n),s.value.length>0&&s.setAttribute("required",!0),s.addEventListener("keyup",({target:o})=>a(o))}),t[0]&&e.formvalidator.setHandler("password-strength",s=>{const r=e.querySelectorAll(".js-password-strength"),c=r[0].getAttribute("data-min-length"),n=r[0].getAttribute("data-min-integers"),i=r[0].getAttribute("data-min-symbols"),o=r[0].getAttribute("data-min-uppercase"),g=r[0].getAttribute("data-min-lowercase");return new PasswordStrength({lowercase:g||0,uppercase:o||0,numbers:n||0,special:i||0,length:c||12}).getScore(s)===100})})})(Joomla,document);

The same content is in 12 releases, Joomla 6.1.0-alpha2 to 6.2.0-alpha1. See them all, or every version of this file.