<commit_before>var body = document.body;
var audioEls = document.getElementsByClassName("audio");

addClickHandlerToAudio();
addClickHandlerToRandomMode();

function getAudio(id) {
  return document.getElementById(id + "-audio");
}

function getLength(a) {
  return a.duration;
}

function playAudio(id) {
  var a = getAudio(id);
  var length = getLength(a);
  showProgress(id, length);
  a.play();
  return length;
}

function toggleProgressBar(id, transition) {
  id = document.getElementById(id);
  var progressEl = id.children[0];
  progressEl.setAttribute("style", transition);
  id.classList.toggle("playing", transition);
}

function showProgress(id, length) {
  var transition = "transition: width " + length + "s linear;"
  toggleProgressBar(id, transition);

  setTimeout(function() {
    toggleProgressBar(id, false);
  }, length * 1000);
}

function randomSoundbite() {
  var number = Math.floor(Math.random() * audioEls.length);
  return audioEls[number];
}

function randomMode() {
  var id = randomSoundbite().id;
  var length = playAudio(id);

  setTimeout(function() {
    if (! body.classList.contains("random")) {
      return; 
    }
    randomMode();
  }, length * 900);
}

function addClickHandlerToAudio() {
  for (var i = 0; i < audioEls.length; i++) {
    audioEls[i].onclick = function() {
      playAudio(this.id);
    };
  }
}

function addClickHandlerToRandomMode() {
  var randomModeEl = document.getElementById("random-mode");
  randomModeEl.onclick = function() {
    if (body.classList.contains("random")) {
      body.className = "";
    } else {
      body.className = "random";
      randomMode();
    }
  };
}<commit_msg>Load all audio files, fix for mobile in theory<commit_after>var body = document.body;
var audioEls = document.getElementsByClassName("audio");

addClickHandlerToAudio();
addClickHandlerToRandomMode();
loadAudioFiles();

function getAudio(id) {
  return document.getElementById(id + "-audio");
}

function getLength(a) {
  return a.duration;
}

function playAudio(id) {
  var a = getAudio(id);
  var length = getLength(a);
  showProgress(id, length);
  a.play();
  return length;
}

function toggleProgressBar(id, transition) {
  id = document.getElementById(id);
  var progressEl = id.children[0];
  progressEl.setAttribute("style", transition);
  id.classList.toggle("playing", transition);
}

function showProgress(id, length) {
  var transition = "transition: width " + length + "s linear;"
  toggleProgressBar(id, transition);

  setTimeout(function() {
    toggleProgressBar(id, false);
  }, length * 1000);
}

function randomSoundbite() {
  var number = Math.floor(Math.random() * audioEls.length);
  return audioEls[number];
}

function randomMode() {
  var id = randomSoundbite().id;
  var length = playAudio(id);

  setTimeout(function() {
    if (! body.classList.contains("random")) {
      return; 
    }
    randomMode();
  }, length * 900);
}

function addClickHandlerToAudio() {
  for (var i = 0; i < audioEls.length; i++) {
    audioEls[i].onclick = function() {
      playAudio(this.id);
    };
  }
}

function addClickHandlerToRandomMode() {
  var randomModeEl = document.getElementById("random-mode");
  randomModeEl.onclick = function() {
    if (body.classList.contains("random")) {
      body.className = "";
    } else {
      body.className = "random";
      randomMode();
    }
  };
}

function loadAudioFiles() {
  for (var i = 0; i < audioEls.length; i++) {
    a = getAudio(audioEls[i].id);
    a.load();
  }
}
{'fraction_non_alphanumeric': 0.14874141876430205, 'fraction_numerical': 0.005434782608695652, 'mean_word_length': 4.031654676258992, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1288527', 'n_tokens_mistral': 1128, 'n_tokens_neox': 1113, 'n_words': 237}