made changes to timer

This commit is contained in:
Michael Andrew Maurakis 2025-01-20 02:30:36 -06:00
parent bbf662fb6d
commit b8053dc9e8

View file

@ -215,7 +215,9 @@
} }
let lastFumbleTime = 0; 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; let cooldownTimer = null;
const fumble = () => { const fumble = () => {
@ -223,15 +225,17 @@
const timeSinceLastFumble = currentTime - lastFumbleTime; const timeSinceLastFumble = currentTime - lastFumbleTime;
if (timeSinceLastFumble < cooldownPeriod) { if (timeSinceLastFumble < cooldownPeriod) {
quickFumbleCount++;
if (quickFumbleCount >= warningThreshold) {
// Show warning modal // Show warning modal
const warningModal = document.getElementById("warningModal"); const warningModal = document.getElementById('warningModal');
const cooldownSeconds = document.getElementById("cooldownSeconds"); const cooldownSeconds = document.getElementById('cooldownSeconds');
const closeBtn = document.getElementById("warningCloseBtn"); const closeBtn = document.getElementById('warningCloseBtn');
warningModal.classList.add("show"); warningModal.classList.add('show');
closeBtn.disabled = true; closeBtn.disabled = true;
// Update countdown timer // Update countdown timer
let remainingTime = 5; // 5 second countdown for closing let remainingTime = 3; // Reduce to 3 second countdown for closing
cooldownSeconds.textContent = remainingTime; cooldownSeconds.textContent = remainingTime;
if (cooldownTimer) clearInterval(cooldownTimer); if (cooldownTimer) clearInterval(cooldownTimer);
@ -239,16 +243,19 @@
remainingTime--; remainingTime--;
if (remainingTime <= 0) { if (remainingTime <= 0) {
cooldownSeconds.textContent = "0"; cooldownSeconds.textContent = '0';
closeBtn.disabled = false; closeBtn.disabled = false;
clearInterval(cooldownTimer); clearInterval(cooldownTimer);
quickFumbleCount = 0; // Reset counter after warning
} else { } else {
cooldownSeconds.textContent = remainingTime; cooldownSeconds.textContent = remainingTime;
} }
}, 1000); }, 1000);
return; return;
} }
} else {
quickFumbleCount = 0; // Reset counter if enough time has passed
}
lastFumbleTime = currentTime; lastFumbleTime = currentTime;
const frame = document.getElementById("contentFrame"); const frame = document.getElementById("contentFrame");