made changes to timer
This commit is contained in:
parent
bbf662fb6d
commit
b8053dc9e8
1 changed files with 29 additions and 22 deletions
51
index.html
51
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;
|
||||
|
|
Loading…
Reference in a new issue