<commit_before>var pendingRequest = undefined;

function showPost(postID) {
  $.getJSON(
    "/postdata/" + postID,
    function processPostResult(post) {
      clearResults();
      addResult(post);
      $('img.result-img').lazyload({
        effect: "fadeIn",
        threshold: 1000,
        skip_invisible: true
      });
    }
  );
}

function updateResults() {
  var query = $("#query").val();
  if (pendingRequest) {
    pendingRequest.abort();
  }
  pendingRequest = $.getJSON(
    "/search",
    {query: query},
    function processQueryResult(data) {
      clearResults();
      for (var x=0; x<data.length; x++) {
        var post = data[x];
        addResult(post);
      }
      $('img.result-img').lazyload({
        effect: "fadeIn",
        threshold: 1000,
        skip_invisible: true
      });
    }
  );
}

function clearResults() {
  $("#results").html("");
}

function addResult(postData) {
  var postHTML = '<div class="result">';
  postHTML += '<h2>';<commit_msg>Refactor javascript<commit_after>var pendingRequest = undefined;

function showPost(postID) {
  $.getJSON(
    "/postdata/" + postID,
    function processPostResult(post) {
      clearResults();
      addResults([post]);
    }
  );
}

function updateResults() {
  var query = $("#query").val();
  if (pendingRequest) {
    pendingRequest.abort();
  }
  pendingRequest = $.getJSON(
    "/search",
    {query: query},
    function processQueryResult(data) {
      clearResults();
      addResults(data);
    }
  );
}

function clearResults() {
  $("#results").html("");
}

function addResults(data) {
  for (var x=0; x<data.length; x++) {
    var post = data[x];
    addResult(post);
  }
  $('img.result-img').lazyload({
    effect: "fadeIn",
    threshold: 1000,
    skip_invisible: true
  });
}

function addResult(postData) {
  var postHTML = '<div class="result">';
  postHTML += '<h2>';
{'fraction_non_alphanumeric': 0.17208311134789558, 'fraction_numerical': 0.008524240809802876, 'mean_word_length': 2.888198757763975, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '5483720', 'n_tokens_mistral': 623, 'n_tokens_neox': 614, 'n_words': 120}