<commit_before>(function ($) {

var search = $("#search");

function searchWiki(){
  var searchValue = $('#searchValue').val();
  var loading = $('#loading');
  var results = $('#results');
  results.empty();
  loading.show();
  $.ajax( {
    url: "https://cors-anywhere.herokuapp.com/https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch="
    + searchValue + "&srlimit=50&prop=revisions&rvprop=content&format=json",
    dataType: 'json',
    type: 'POST',
    headers: { 'Api-User-Agent': 'Example/1.0' },
    success: function(data) {
      var resData = JSON.stringify(data);
    //  console.log(resData);
     resData = JSON.parse(resData);
    // console.log('Search results: ' + resData.query.search[0]);
     var search = resData.query.search;
     console.log("Total: " + search.length);
     loading.hide();
     for(var i = 0; i<search.length; i++){
       results.append("<div class='snippet'><a href='https://en.wikipedia.org/wiki/"+ search[i].title +
       "' target='_blank'<p><span class='title'>" + search[i].title + ":    </span>"
       + search[i].snippet +"...</p></a></div>");
     }
     $("#foot").css("position", "relative");
    }
} );
}

search.click( function(){
  searchWiki();
});

// add keybinding for enter to trigger submit click
$('#searchValue').keypress(function(e){
  if(e.which == 13){//Enter key pressed
    search.click();//Trigger search button click event
  }
});



}(jQuery));<commit_msg>add function to handle no results found<commit_after>(function ($) {

var search = $("#search");

function searchWiki(){
  var searchValue = $('#searchValue').val();
  var loading = $('#loading');
  var results = $('#results');
  results.empty();
  loading.show();
  $.ajax( {
    url: "https://cors-anywhere.herokuapp.com/https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch="
    + searchValue + "&srlimit=50&prop=revisions&rvprop=content&format=json",
    dataType: 'json',
    type: 'POST',
    headers: { 'Api-User-Agent': 'Example/1.0' },
    success: function(data) {
      var resData = JSON.stringify(data);
     resData = JSON.parse(resData);
     var search = resData.query.search;
     loading.hide();
     if(search.length==0){
       results.append('<div><p>No results found for "' + searchValue
       + '." Please try a different search term.</p></div>');
     }
     for(var i = 0; i<search.length; i++){
       results.append("<div class='snippet'><a href='https://en.wikipedia.org/wiki/"+ search[i].title +
       "' target='_blank'<p><span class='title'>" + search[i].title + ":    </span>"
       + search[i].snippet +"...</p></a></div>");
     }
     $("#foot").css("position", "relative");
   },
   error: function(xhr,status,error){
     console.log("error: " + error);
   }
} );
}

search.click( function(){
  searchWiki();
});

// add keybinding for enter to trigger submit click
$('#searchValue').keypress(function(e){
  if(e.which == 13){//Enter key pressed
    search.click();//Trigger search button click event
  }
});



}(jQuery));
{'fraction_non_alphanumeric': 0.21334214002642007, 'fraction_numerical': 0.005284015852047556, 'mean_word_length': 3.5074404761904763, 'pattern_counts': {'":': 2, '<': 25, '<?xml version=': 0, '>': 21, 'https://': 6, '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': '2512861', 'n_tokens_mistral': 997, 'n_tokens_neox': 986, 'n_words': 185}