diff --git a/CONTRIBUTORS b/CONTRIBUTORS index a5193b47a..ccbca7e4f 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -168,6 +168,7 @@ Arbyste Vasll laalsaas ijqq +AntoineQ1 ******************** The text of the 3 clause BSD license follows: diff --git a/qt/aqt/data/web/js/reviewer-bottom.ts b/qt/aqt/data/web/js/reviewer-bottom.ts index ff2f32a05..4ebf34510 100644 --- a/qt/aqt/data/web/js/reviewer-bottom.ts +++ b/qt/aqt/data/web/js/reviewer-bottom.ts @@ -9,15 +9,6 @@ let time: number; // set in python code let timerStopped = false; let maxTime = 0; -document.addEventListener("DOMContentLoaded", () => { - updateTime(); - setInterval(function() { - if (!timerStopped) { - time += 1; - updateTime(); - } - }, 1000); -}); function updateTime(): void { const timeNode = document.getElementById("time"); @@ -38,10 +29,24 @@ function updateTime(): void { } } +let intervalId: number | undefined; + function showQuestion(txt: string, maxTime_: number): void { showAnswer(txt); time = 0; maxTime = maxTime_; + updateTime(); + + if (intervalId !== undefined) { + clearInterval(intervalId); + } + + intervalId = setInterval(function() { + if (!timerStopped) { + time += 1; + updateTime(); + } + }, 1000); } function showAnswer(txt: string, stopTimer = false): void {