<commit_before>function loadFile(file) {
  var getInfo = new XMLHttpRequest();

  getInfo.open("GET", file);
  getInfo.send();

  getInfo.onreadystatechange = function() {
    var text = document.getElementById("textTarget");
    if (getInfo.readyState === 4) {
      if (getInfo.status === 200) {
        text.innerHTML = getInfo.responseText;
      } else {
        console.log("There was a problem with the request.");
      }
    }
  }
}




// Time stamps
// after the loop starts: 0.066ms
// scripts.js:34 after the loop starts: 0.040ms
// scripts.js:34 after the loop starts: 0.066ms
// scripts.js:34 after the loop starts: 0.020ms
// scripts.js:36 the whole loop: 1.120ms
// scripts.js:32 after click: 0.478ms
// scripts.js:32 after click: 0.529ms

// The first click takes over a asecond to make the AJAX call
// The clicks run the code really fast after that



// The first click takes over a asecond to make the AJAX call
// The clicks run the code really fast after that

document.addEventListener("DOMContentLoaded", function() {
console.log("DOM's good");
  var buttons = document.querySelectorAll(".btn");

  // for each selected element
  console.time("the whole loop");
  for (var i = 0; i < buttons.length; i++) {
    console.time("after the loop starts");
    // add click handler
    buttons[i].addEventListener("click", function() {
      console.time("after click");
      loadFile(this.dataset.file);
     console.timeEnd("after click");
    });
    console.timeEnd("after the loop starts");
  }
  console.timeEnd("the whole loop");
});<commit_msg>clean up merge errors in file<commit_after>function loadFile(file) {
  var getInfo = new XMLHttpRequest();

  getInfo.open("GET", file);
  getInfo.send();

  getInfo.onreadystatechange = function() {
    var text = document.getElementById("textTarget");
    if (getInfo.readyState === 4) {
      if (getInfo.status === 200) {
        text.innerHTML = getInfo.responseText;
      } else {
        console.log("There was a problem with the request.");
      }
    }
  }
}

var buttons = document.querySelectorAll(".btn");

for (key in buttons) {

  var theButtons = buttons[key];

  // If a form field is blurred, validate it
  theButtons.onclick = function() {

    loadFile(this.dataset.file);

  }

}
{'fraction_non_alphanumeric': 0.13330400351957766, 'fraction_numerical': 0.02155741311042675, 'mean_word_length': 3.1648351648351647, 'pattern_counts': {'":': 0, '<': 4, '<?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': '523161', 'n_tokens_mistral': 731, 'n_tokens_neox': 675, 'n_words': 208}