Skip to content

Commit

Permalink
fix: game reset buttons properly reset
Browse files Browse the repository at this point in the history
  • Loading branch information
vladdeSV committed Mar 31, 2024
1 parent 0363482 commit b273444
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions website/lost.the.game.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function resetGame() {
resetContainer.innerHTML = '<button type=reset>reset timer</button>'
const reset = resetContainer.querySelector('button[type=reset]')
reset.addEventListener('click', () => {
clearInterval(intervals[form.dataset.checkswipe !== undefined ? 0 : 1]);
clearInterval(intervals[fieldset.dataset.checkswipe !== undefined ? 0 : 1]);
timerStarted = false;
timer = 0;
timerDisplay.textContent = '–';
Expand All @@ -56,7 +56,7 @@ function resetGame() {
});

function startTimer() {
intervals[form.dataset.checkswipe !== undefined ? 0 : 1] = setInterval(() => {
intervals[fieldset.dataset.checkswipe !== undefined ? 0 : 1] = setInterval(() => {
timer++;
let displayNumber = timer / 100
timerDisplay.textContent = displayNumber.toFixed(2) + 's';
Expand All @@ -66,7 +66,7 @@ function resetGame() {
function checkCompletion() {
const allChecked = Array.from(checkboxes).every(checkbox => checkbox.checked);
if (allChecked) {
clearInterval(intervals[form.dataset.checkswipe !== undefined ? 0 : 1]);
clearInterval(intervals[fieldset.dataset.checkswipe !== undefined ? 0 : 1]);
let best = timerDisplay.dataset.best;
if (best === undefined || best === '' || timer < best) {
timerDisplay.dataset.best = String(timer);
Expand Down

0 comments on commit b273444

Please sign in to comment.