<commit_before>var streak = 0;
var time = 10;
var loop = "";
var currentBug;
var rounds;

window.onload = function(){
  // if(window.location.search.match(/restart=true/) !== null){
    // remove_instructions();
    // init_game('c++');
  // }
};

function start() {
  var language = document.getElementById('language').value;
  remove_instructions();
  init_game(language);
}

function init_game(choosenLanguage){
  query.equalTo("language", choosenLanguage);
  //query.limit(1); limit number of bugs on array
  query.find({
    success: function(bugs)
    {
      rounds = bugs;
      streak = 0;
      time = 10;
      loop = window.setInterval(gameloop, 1000);
      next_round();
    },
    error: function(error)
    {
      console.log(error);
    }
  });
}

function restart(){
  window.location.search = '&restart=true';
}

function lineClickHandlers(){
  var rows = document.getElementsByTagName("tr");
  for(var i = 0; i < rows.length; i++)
  {
    (function(i) {
      var thisRow = rows[i];
      thisRow.setAttribute("ontouched", "this.onclick=fix");
      thisRow.addEventListener('click', function(){
        checkAnswer(i+1);
      });
    })(i);
  }
}

function remove_instructions(){
  var instructions = document.getElementById('instructions');
  instructions.setAttribute("style", "display: none");
}

function fix(){
    var el = this;
    var par = el.parentNode;
    var next = el.nextSibling;
    par.removeChild(el);
    setTimeout(function() {par.insertBefore(el, next);}, 0);
}

function checkAnswer(rowNumber){
  bugLines = currentBug.get('bug_lines').split(',');<commit_msg>fix restart<commit_after>var streak = 0;
var time = 10;
var loop = "";
var currentBug;
var rounds;

window.onload = function(){
  // if(window.location.search.match(/restart=true/) !== null){
    // remove_instructions();
    // init_game('c++');
  // }
};

function start() {
  var language = document.getElementById('language').value;
  remove_instructions();
  init_game(language);
}

function init_game(choosenLanguage){
  query.equalTo("language", choosenLanguage);
  //query.limit(1); limit number of bugs on array
  query.find({
    success: function(bugs)
    {
      rounds = bugs;
      streak = 0;
      time = 10;
      loop = window.setInterval(gameloop, 1000);
      next_round();
    },
    error: function(error)
    {
      console.log(error);
    }
  });
}

function restart(){
  window.location.search += '&restart=true';
}

function lineClickHandlers(){
  var rows = document.getElementsByTagName("tr");
  for(var i = 0; i < rows.length; i++)
  {
    (function(i) {
      var thisRow = rows[i];
      thisRow.setAttribute("ontouched", "this.onclick=fix");
      thisRow.addEventListener('click', function(){
        checkAnswer(i+1);
      });
    })(i);
  }
}

function remove_instructions(){
  var instructions = document.getElementById('instructions');
  instructions.setAttribute("style", "display: none");
}

function fix(){
    var el = this;
    var par = el.parentNode;
    var next = el.nextSibling;
    par.removeChild(el);
    setTimeout(function() {par.insertBefore(el, next);}, 0);
}

function checkAnswer(rowNumber){
  bugLines = currentBug.get('bug_lines').split(',');
{'fraction_non_alphanumeric': 0.16432803242906144, 'fraction_numerical': 0.008730901153726224, 'mean_word_length': 3.50561797752809, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5459629', 'n_tokens_mistral': 1054, 'n_tokens_neox': 1027, 'n_words': 210}