From 9f5d23410f36ebf08f0c933b9d91fe2dc69d10db Mon Sep 17 00:00:00 2001 From: Jasmin Savard Date: Sat, 11 Jan 2025 04:47:00 -0500 Subject: [PATCH] Rename to password-strenght.ts --- .../{strength.ts => password-strength.ts} | 19 ++++++++----------- .../OrchardCore.Setup/Assets/ts/setup.ts | 2 +- 2 files changed, 9 insertions(+), 12 deletions(-) rename src/Frontend/components/{strength.ts => password-strength.ts} (91%) diff --git a/src/Frontend/components/strength.ts b/src/Frontend/components/password-strength.ts similarity index 91% rename from src/Frontend/components/strength.ts rename to src/Frontend/components/password-strength.ts index 9179ccf22aa..bcc448fcb15 100644 --- a/src/Frontend/components/strength.ts +++ b/src/Frontend/components/password-strength.ts @@ -14,7 +14,7 @@ * @param {string} options.target - CSS selector for the element where the strength progress bar is displayed. * @param {string} options.style - CSS style string for the progress bar. */ -export default function strength(element: HTMLInputElement, options: any) { +export default (element: HTMLInputElement, options: any) => { const settings = Object.assign({ requiredLength: 8, @@ -38,12 +38,9 @@ export default function strength(element: HTMLInputElement, options: any) { let valid = false; - function getPercentage(a: number, b: number) { - return (b / a) * 100; - } - - function getLevel(value: number) { + const getPercentage = (a: number, b: number) => (b / a) * 100; + const getLevel = (value: number) => { if (value >= 100) { return "bg-success"; } @@ -57,9 +54,9 @@ export default function strength(element: HTMLInputElement, options: any) { } return "bg-danger"; - } + }; - function checkStrength(value: string) { + const checkStrength = (value: string) => { const minLength = value.length >= settings.requiredLength ? 1 : 0; capitalletters = !settings.requireUppercase || value.match(upperCase) ? 1 : 0; @@ -73,9 +70,9 @@ export default function strength(element: HTMLInputElement, options: any) { valid = percentage >= 100; createProgressBar(percentage, getLevel(percentage)); - } + }; - function createProgressBar(percentage: string | number, level: string) { + const createProgressBar = (percentage: string | number, level: string) => { const el = document.createElement("div"); el.className = "progress"; el.setAttribute("value", percentage.toString()); @@ -89,7 +86,7 @@ export default function strength(element: HTMLInputElement, options: any) { const target = document.querySelector(settings.target); target.innerHTML = ""; target.appendChild(el); - } + }; element.addEventListener("keyup", () => checkStrength(element.value)); element.addEventListener("keydown", () => checkStrength(element.value)); diff --git a/src/OrchardCore.Modules/OrchardCore.Setup/Assets/ts/setup.ts b/src/OrchardCore.Modules/OrchardCore.Setup/Assets/ts/setup.ts index 4e73a259403..17a3407482e 100644 --- a/src/OrchardCore.Modules/OrchardCore.Setup/Assets/ts/setup.ts +++ b/src/OrchardCore.Modules/OrchardCore.Setup/Assets/ts/setup.ts @@ -1,4 +1,4 @@ -import strenght from "@orchardcore/frontend/components/strength"; +import strenght from "@orchardcore/frontend/components/password-strength"; // Show or hide the connection string or table prefix section when the database provider is selected const toggleConnectionStringAndPrefix = () => {