Skip to content

Commit

Permalink
fix #295, #298: timer bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffrey-wu committed Jul 5, 2024
1 parent 00171fb commit bcdf837
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion client/scripts/Timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default class Timer {
return this.tenthsRemaining % 10;
}

pauseTimer () {
stopTimer () {
clearInterval(this.timerInterval);
}

Expand Down
12 changes: 12 additions & 0 deletions client/singleplayer/tossups.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 = '';
Expand Down

0 comments on commit bcdf837

Please sign in to comment.