http: adds scripts

This commit is contained in:
2026-06-04 15:15:02 +01:00
parent fac1199cd6
commit 813836fbba
7 changed files with 320 additions and 0 deletions
@@ -0,0 +1,32 @@
/** @typedef {import("./selectors.js").Selectors} Selectors */
/** @typedef {{ resendButtonInterval: NodeJS.Timeout | undefined }} Result */
/**
* @param {Selectors} selectors
* @param {NodeJS.Timeout | undefined} resetButtonInterval
* @returns {Result}
*/
export function resetResendButton({ otpDialog }, resendButtonInterval) {
clearInterval(resendButtonInterval);
const resendButton = otpDialog.resendButton();
if (resendButton) {
resendButton.setAttribute("data-countdown", "60");
resendButton.setAttribute("disabled", "");
resendButtonInterval = setInterval(() => {
const countdown = +(resendButton.getAttribute("data-countdown") ?? 1) - 1;
resendButton.setAttribute("data-countdown", countdown.toString());
resendButton.textContent = `Resend (${countdown}s)`;
}, 1000);
setTimeout(() => {
clearInterval(resendButtonInterval);
resendButton.textContent = "Resend";
resendButton.removeAttribute("disabled");
}, 1000 * 60);
}
return { resendButtonInterval };
}