From bcdf8372a41cd80c0853e7eedf1005a8883c838b Mon Sep 17 00:00:00 2001 From: Geoffrey Wu Date: Fri, 5 Jul 2024 14:07:40 +0100 Subject: [PATCH] fix #295, #298: timer bugs --- client/scripts/Timer.js | 2 +- client/singleplayer/tossups.js | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/client/scripts/Timer.js b/client/scripts/Timer.js index d2714a22..69b2bfb7 100644 --- a/client/scripts/Timer.js +++ b/client/scripts/Timer.js @@ -11,7 +11,7 @@ export default class Timer { return this.tenthsRemaining % 10; } - pauseTimer () { + stopTimer () { clearInterval(this.timerInterval); } diff --git a/client/singleplayer/tossups.js b/client/singleplayer/tossups.js index 6c9e6ec7..219ea284 100644 --- a/client/singleplayer/tossups.js +++ b/client/singleplayer/tossups.js @@ -259,6 +259,7 @@ function buzz () { document.getElementById('pause').disabled = true; if (settings.timer) { + timer.stopTimer(); timer.startTimer(ANSWER_TIME_LIMIT, () => document.getElementById('answer-submit').click()); } } @@ -352,6 +353,11 @@ async function next () { // Stop reading the current question: clearTimeout(timeoutID); currentlyBuzzing = false; + if (settings.timer) { + timer.stopTimer(); + timer.tenthsRemaining = 0; + timer.updateDisplay(); + } if (await account.getUsername() && document.getElementById('answer').innerHTML) { const pointValue = previous.isCorrect ? (previous.inPower ? previous.powerValue : 10) : (previous.endOfQuestion ? 0 : previous.negValue); @@ -555,6 +561,12 @@ document.getElementById('answer-form').addEventListener('submit', function (even event.preventDefault(); event.stopPropagation(); + if (settings.timer) { + timer.stopTimer(); + timer.tenthsRemaining = 0; + timer.updateDisplay(); + } + const answer = document.getElementById('answer-input').value; document.getElementById('answer-input').value = '';