<commit_before>// Place all the behaviors and hooks related to the matching controller here.
// All this logic will automatically be available in application.js.

document.addEventListener("turbolinks:load", function() {
  $('#new_task').submit(function(event) {
    event.preventDefault();
    let values = $(this).serialize();
    let posting = $.post(this.action, values);
    posting.success(function(data) {
      let task = data;
      let template = Handlebars.compile(document.getElementById("task-template").innerHTML);
      let result = template(task);
      if (task.description) {
        document.getElementById("edit-selected").innerHTML += result;
        document.getElementById("new_task").reset();
        // update incomplete tasks counter
        num = parseInt(document.getElementById("number-of-incomplete-tasks").innerHTML);
        document.getElementById("number-of-incomplete-tasks").innerHTML = num + 1;
      }
    });
  });
});
<commit_msg>update navbar incomplete tasks counter with AJAX call<commit_after>// Place all the behaviors and hooks related to the matching controller here.
// All this logic will automatically be available in application.js.

document.addEventListener("turbolinks:load", function() {
  $('#new_task').submit(function(event) {
    event.preventDefault();
    let values = $(this).serialize();
    let posting = $.post(this.action, values);
    posting.success(function(data) {
      let task = data;
      let template = Handlebars.compile(document.getElementById("task-template").innerHTML);
      let result = template(task);
      if (task.description) {
        document.getElementById("edit-selected").innerHTML += result;
        document.getElementById("new_task").reset();
        // update incomplete tasks counters
        num = parseInt(document.getElementById("number-of-incomplete-tasks").innerHTML);
        document.getElementById("number-of-incomplete-tasks").innerHTML = num + 1;

        element = document.querySelector(".list-group-lists a.active span");
        if (element.innerHTML) {
          element.innerHTML = num + 1;
        } else {
          element.innerHTML = 1;
        }
      }
    });
  });
});

{'fraction_non_alphanumeric': 0.13281606572341398, 'fraction_numerical': 0.0018256503879507074, 'mean_word_length': 3.3578528827037775, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4016366', 'n_tokens_mistral': 551, 'n_tokens_neox': 549, 'n_words': 133}