<commit_before>var wrong_answer_counter = 0;
var streak_counter = 0;

$(document).ready(function() {
    gon.cave_round_over = false;
    gon.cave_user_wrong_answer = false;
    gon.cave_user_right_answer = false;

    updateAnswerBox_withUserInput();
    clearText_fromAnswerBox();
    captureUserData_and_manipulateAnimation();

    $(".calculator_wrapper").css("background-image", "url('images/backgrounds/cave.png')");
});

var updateAnswerBox_withUserInput = function() {
  $(".calculator").on("click", function(e) {
    e.preventDefault();

    if (gon.cave_round_over == false) {
      var $number = $(this)[0].innerText;
      $(".answer_area").append($number);
    }
  });
}

var clearText_fromAnswerBox = function() {
  $(".calculator-cancel").on("click", function(e) {
    e.preventDefault();
    $(".answer_area")[0].innerText = "";
  });
}

var captureUserData_and_manipulateAnimation = function() {
  $(".calculator-submit").on("click", function(e) {
    e.preventDefault();

    if (gon.cave_round_over == false) {
      var $user_input = $(".answer_area")[0].innerText;

      if ($user_input == gon.answer) {
        gon.cave_user_right_answer = true;
        updateQuestionsviaAJAX();
        streak_counter += 1;

        if (streak_counter >= 2) {
          $(".streak_btn").html("<div id=\"streak_counter\" class=\"streak_counter\"><div>" + streak_counter + "</div><span>combo</span></div>");
        }
      }
      else {
        $(".streak_counter").remove();
        streak_counter = 0;

        gon.cave_user_wrong_answer = true;
      }
    }
  })
}

var updateQuestionsviaAJAX = function() {
  $.ajax({
    url: "/cave",
    method: 'GET'
  })
  .done(function(response) {
    $(".question_area").html(response.problem);
    $(".answer_area")[0].innerText = "";
    gon.answer = response.answer;<commit_msg>fixed ajax files to reset question and answer fields when wrong answer entered<commit_after>var wrong_answer_counter = 0;
var streak_counter = 0;

$(document).ready(function() {
    gon.cave_round_over = false;
    gon.cave_user_wrong_answer = false;
    gon.cave_user_right_answer = false;

    updateAnswerBox_withUserInput();
    clearText_fromAnswerBox();
    captureUserData_and_manipulateAnimation();

    $(".calculator_wrapper").css("background-image", "url('images/backgrounds/cave.png')");
});

var updateAnswerBox_withUserInput = function() {
  $(".calculator").on("click", function(e) {
    e.preventDefault();

    if (gon.cave_round_over == false) {
      var $number = $(this)[0].innerText;
      $(".answer_area").append($number);
    }
  });
}

var clearText_fromAnswerBox = function() {
  $(".calculator-cancel").on("click", function(e) {
    e.preventDefault();
    $(".answer_area")[0].innerText = "";
  });
}

var captureUserData_and_manipulateAnimation = function() {
  $(".calculator-submit").on("click", function(e) {
    e.preventDefault();

    if (gon.cave_round_over == false) {
      var $user_input = $(".answer_area")[0].innerText;

      if ($user_input == gon.answer) {
        gon.cave_user_right_answer = true;
        updateQuestionsviaAJAX();
        streak_counter += 1;

        if (streak_counter >= 2) {
          $(".streak_btn").html("<div id=\"streak_counter\" class=\"streak_counter\"><div>" + streak_counter + "</div><span>combo</span></div>");
        }
      }
      else {
        updateQuestionsviaAJAX();
        $(".streak_counter").remove();
        streak_counter = 0;

        gon.cave_user_wrong_answer = true;
      }
    }
  })
}

var updateQuestionsviaAJAX = function() {
  $.ajax({
    url: "/cave",
    method: 'GET'
  })
  .done(function(response) {
    $(".question_area").html(response.problem);
    $(".answer_area")[0].innerText = "";
    gon.answer = response.answer;
{'fraction_non_alphanumeric': 0.1753780843725126, 'fraction_numerical': 0.004775802600159193, 'mean_word_length': 3.4042056074766354, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, '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': '5443748', 'n_tokens_mistral': 1298, 'n_tokens_neox': 1235, 'n_words': 182}