<commit_before>var Tv = function(args) {
  this.title = args.title || "unknown";
  this.id = args.id || "unknown";
}

var availableContent = function(args) {
  this.display_name = args.display_name || "unknown";
}

  var shows;
  var sources;
  var show_id;

$(document).ready (function(){


  $('#title-input').on ('submit', function(event) {
    event.preventDefault();

    $("#pending").append("Searching the database...");

    $target = $(event.target)
    var API_KEY = "<KEY>";
    var BASE_URL = "https://api-public.guidebox.com/v1.43/US/";
    var TITLE = $target.find("input").val();
    var search_url_title_id = BASE_URL + API_KEY + "/search/title/" + TITLE + "/fuzzy";

  $.ajax({
    method: "GET",
    url: search_url_title_id,
    dataType: 'json'
    }).done(function(response){
      shows = []
    return response.results.forEach(function(item){
      return shows.push( new Tv(item) )
    })
    }).fail(function(error){
      $("#available-sources").append('<li>' + error.statusText + '</li>')
    }).then(function(resp){
        if (shows.length === 0) {
        $("#available-sources").append('<li>Please try a different search.</li>')
        } else {
         
      show_id = shows[0].id
      var search_available_content = BASE_URL + API_KEY + "/show/" + show_id + "/available_content";

      $.ajax({
        method: "GET",
        url: search_available_content,
        dataType: 'json'
      }).done(function(response){
        $("#pending").html("")
        sources = []
        return response.results.web.episodes.all_sources.forEach(function(item) {
          return sources.push( new availableContent(item))
        })
      }).fail(function(error){
        $("#available-sources").append('<li>' + error.statusText + '</li>')
      }).then(function(resp){
      $("#available-sources").html("")
      $("#title").html(shows[0].title + " is playing on...")
      for (var i in sources) {
        $("#available-sources").append('<li>'+ sources[i].display_name + " " + '</li>')
      }
      $("#title-input-box").val("")

      })
        }
    });
  });
});
<commit_msg>on second search, the previous input disappears<commit_after>var Tv = function(args) {
  this.title = args.title || "unknown";
  this.id = args.id || "unknown";
}

var availableContent = function(args) {
  this.display_name = args.display_name || "unknown";
}

  var shows;
  var sources;
  var show_id;

$(document).ready (function(){


  $('#title-input').on ('submit', function(event) {
    event.preventDefault();

    $("#pending").append("Searching the database...");
    $("#available-sources").html("");
    $("#title").html("");

    $target = $(event.target)
    var API_KEY = "<KEY>";
    var BASE_URL = "https://api-public.guidebox.com/v1.43/US/";
    var TITLE = $target.find("input").val();
    var search_url_title_id = BASE_URL + API_KEY + "/search/title/" + TITLE + "/fuzzy";

  $.ajax({
    method: "GET",
    url: search_url_title_id,
    dataType: 'json'
    }).done(function(response){
      shows = []
    return response.results.forEach(function(item){
      return shows.push( new Tv(item) )
    })
    }).fail(function(error){
      $("#available-sources").append('<li>' + error.statusText + '</li>')
    }).then(function(resp){
        if (shows.length === 0) {
        $("#available-sources").append('<li>Please try a different search.</li>')
        } else {
         
      show_id = shows[0].id
      var search_available_content = BASE_URL + API_KEY + "/show/" + show_id + "/available_content";

      $.ajax({
        method: "GET",
        url: search_available_content,
        dataType: 'json'
      }).done(function(response){
        $("#pending").html("")
        sources = []
        return response.results.web.episodes.all_sources.forEach(function(item) {
          return sources.push( new availableContent(item))
        })
      }).fail(function(error){
        $("#available-sources").append('<li>' + error.statusText + '</li>')
      }).then(function(resp){
      $("#available-sources").html("")
      $("#title").html(shows[0].title + " is playing on...")
      for (var i in sources) {
        $("#available-sources").append('<li>'+ sources[i].display_name + " " + '</li>')
      }
      $("#title-input-box").val("")

      })
        }
    });
  });
});

{'fraction_non_alphanumeric': 0.2012987012987013, 'fraction_numerical': 0.0027829313543599257, 'mean_word_length': 2.763525305410122, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 2, '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': '4789784', 'n_tokens_mistral': 1365, 'n_tokens_neox': 1363, 'n_words': 250}