<commit_before>var click = new Audio('click.mp3');
var bing = new Audio('bing.mp3');
var count, stage, timer, stageCounter, stageRest, stageDone, stageTimer;
var overlay = document.querySelector('.overlay');

function reset() {
  document.querySelector('.stage-12 .counter').innerHTML = "DONE";
  overlay.innerHTML = "<h1>Smashed it.</h1><p>Click anywhere to go again</p>";
  overlay.classList.toggle('on')
  document.querySelector('.content').classList.toggle('animate');
}

function initialiseCounters() {
  count = 1;
  stage = 1;
  timer = 3;
}

function setStageElements() {
  stageCounter = document.querySelector('.stage-' + stage + ' .counter');
  stageRest = document.querySelector('.stage-' + stage + ' .rest');
  stageDone = document.querySelector('.stage-' + stage + ' .done');
  stageTimer = document.querySelector('.stage-' + stage + ' .timer');
}

function startExercise() {
  timer = 30;
  document.querySelector('.content').classList.toggle('animate');
  document.querySelector('.stage-1 .counter').innerHTML = "30";
  overlay.classList.toggle('on');
  setStageElements();
  tick();
}

function tick(start) {
  setTimeout(function () {
    timer--;

    if (start) {
      overlay.innerHTML = timer;
      if (timer > 0) {
        tick(true)
      } else {
        startExercise()
      }
    } else {
      if (count % 40 < 30) {
        click.play();
        if (count % 40 == 0) {
          stageRest.classList.toggle('on')
          stageDone.classList.toggle('on')
          stageCounter.innerHTML = "DONE";
          stage++;
          timer = 30;
          setStageElements();
          stageTimer.classList.toggle('on')
        }
      } else if (count % 40 == 30) {
        bing.play();
        timer = 10;
        stageTimer.classList.toggle('on')
        stageRest.classList.toggle('on')
      }

      stageCounter.innerHTML = timer;
      count++;

      if (count <= 470) {
        tick();
      } else {
        bing.play();
        reset();
      }
    }
  }, 1000);
}

overlay.addEventListener('click', function() {
  initialiseCounters();
  overlay.innerHTML = timer;
  tick(true);
});

document.querySelector('.mute').addEventListener('click', function() {
  click.volume = click.volume == 1 ? 0 : 1;
  bing.volume = bing.volume == 1 ? 0 : 1;
  this.classList.toggle('fa-volume-up');
  this.classList.toggle('fa-volume-off');
});<commit_msg>Stop start spamming messing up the timers<commit_after>var click = new Audio('click.mp3');
var bing = new Audio('bing.mp3');
var count, stage, timer, stageCounter, stageRest, stageDone, stageTimer;
var overlay = document.querySelector('.overlay');

function reset() {
  document.querySelector('.stage-12 .counter').innerHTML = "DONE";
  overlay.innerHTML = "<h1>Smashed it.</h1><p>Click anywhere to go again</p>";
  overlay.classList.toggle('on')
  document.querySelector('.content').classList.toggle('animate');
}

function initialiseCounters() {
  count = 1;
  stage = 1;
  timer = 3;
}

function setStageElements() {
  stageCounter = document.querySelector('.stage-' + stage + ' .counter');
  stageRest = document.querySelector('.stage-' + stage + ' .rest');
  stageDone = document.querySelector('.stage-' + stage + ' .done');
  stageTimer = document.querySelector('.stage-' + stage + ' .timer');
}

function startExercise() {
  timer = 30;
  document.querySelector('.content').classList.toggle('animate');
  document.querySelector('.stage-1 .counter').innerHTML = "30";
  overlay.classList.toggle('on');
  overlay.classList.toggle('started')
  setStageElements();
  tick();
}

function tick(start) {
  setTimeout(function () {
    timer--;

    if (start) {
      overlay.innerHTML = timer;
      if (timer > 0) {
        tick(true)
      } else {
        startExercise()
      }
    } else {
      if (count % 40 < 30) {
        click.play();
        if (count % 40 == 0) {
          stageRest.classList.toggle('on')
          stageDone.classList.toggle('on')
          stageCounter.innerHTML = "DONE";
          stage++;
          timer = 30;
          setStageElements();
          stageTimer.classList.toggle('on')
        }
      } else if (count % 40 == 30) {
        bing.play();
        timer = 10;
        stageTimer.classList.toggle('on')
        stageRest.classList.toggle('on')
      }

      stageCounter.innerHTML = timer;
      count++;

      if (count <= 470) {
        tick();
      } else {
        bing.play();
        reset();
      }
    }
  }, 1000);
}

overlay.addEventListener('click', function() {
  if (overlay.classList.contains("started")) {
    return;
  }
  initialiseCounters();
  overlay.innerHTML = timer;
  tick(true);
  overlay.classList.toggle("started")
});

document.querySelector('.mute').addEventListener('click', function() {
  click.volume = click.volume == 1 ? 0 : 1;
  bing.volume = bing.volume == 1 ? 0 : 1;
  this.classList.toggle('fa-volume-up');
  this.classList.toggle('fa-volume-off');
});
{'fraction_non_alphanumeric': 0.1680552733184312, 'fraction_numerical': 0.017476122739280633, 'mean_word_length': 2.8513302034428794, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1471499', 'n_tokens_mistral': 1552, 'n_tokens_neox': 1484, 'n_words': 299}