From b8053dc9e83b49f1f4dce9b642d6f56ecd1c9b8c Mon Sep 17 00:00:00 2001 From: Michael Maurakis Date: Mon, 20 Jan 2025 02:30:36 -0600 Subject: [PATCH] made changes to timer --- index.html | 51 +++++++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/index.html b/index.html index fda48b4..5c0f1a3 100644 --- a/index.html +++ b/index.html @@ -215,7 +215,9 @@ } let lastFumbleTime = 0; - const cooldownPeriod = 5000; // 5 seconds cooldown + const cooldownPeriod = 2000; // Reduce to 2 seconds cooldown + const warningThreshold = 3; // Number of quick fumbles before warning + let quickFumbleCount = 0; let cooldownTimer = null; const fumble = () => { @@ -223,31 +225,36 @@ const timeSinceLastFumble = currentTime - lastFumbleTime; if (timeSinceLastFumble < cooldownPeriod) { - // Show warning modal - const warningModal = document.getElementById("warningModal"); - const cooldownSeconds = document.getElementById("cooldownSeconds"); - const closeBtn = document.getElementById("warningCloseBtn"); - warningModal.classList.add("show"); - closeBtn.disabled = true; + quickFumbleCount++; + if (quickFumbleCount >= warningThreshold) { + // Show warning modal + const warningModal = document.getElementById('warningModal'); + const cooldownSeconds = document.getElementById('cooldownSeconds'); + const closeBtn = document.getElementById('warningCloseBtn'); + warningModal.classList.add('show'); + closeBtn.disabled = true; - // Update countdown timer - let remainingTime = 5; // 5 second countdown for closing - cooldownSeconds.textContent = remainingTime; + // Update countdown timer + let remainingTime = 3; // Reduce to 3 second countdown for closing + cooldownSeconds.textContent = remainingTime; - if (cooldownTimer) clearInterval(cooldownTimer); - cooldownTimer = setInterval(() => { - remainingTime--; + if (cooldownTimer) clearInterval(cooldownTimer); + cooldownTimer = setInterval(() => { + remainingTime--; - if (remainingTime <= 0) { - cooldownSeconds.textContent = "0"; - closeBtn.disabled = false; - clearInterval(cooldownTimer); - } else { - cooldownSeconds.textContent = remainingTime; + if (remainingTime <= 0) { + cooldownSeconds.textContent = '0'; + closeBtn.disabled = false; + clearInterval(cooldownTimer); + quickFumbleCount = 0; // Reset counter after warning + } else { + cooldownSeconds.textContent = remainingTime; + } + }, 1000); + return; } - }, 1000); - - return; + } else { + quickFumbleCount = 0; // Reset counter if enough time has passed } lastFumbleTime = currentTime;