<commit_before>// Click on get more info link on the user/trip index page, populates with trips?s

// JSON
$(function(){
  $(".js-more").on("click", function(event){
    event.preventDefault();
    // this is <a class="js-more" href="/trips/1">More Info</a>
    var tripUrl = (this.href += ".json");

    // AJAX call
    $.get(tripUrl).success(function(response){
      var tripDiv = 'div.trip-info-' + response["trip"]["id"];

      var newTripInfo = new Trip(
        response["trip"]["user_id"],
        response["trip"]["destination"]["city"],
        response["trip"]["trip_nickname"],
        response["trip"]["start_date"],
        response["trip"]["end_date"]
        );
      
      // Show data
      $(tripDiv).append(newTripInfo.trip_nickname 
        + " is in " + newTripInfo.city + " from " + newTripInfo.start_date
        + " to " + newTripInfo.end_date);
    })
  })
})

// Trip Constructor
function Trip(user_id, city, trip_nickname, start_date, end_date){
  this.user_id = user_id;
  this.city = city;
  this.trip_nickname = trip_nickname;
  this.start_date = start_date;
  this.end_date = end_date;
}

// Placeholder
Trip.prototype.capitalize = function(){

}<commit_msg>add method to Trip prototype to tell whether the trip has already passed or not<commit_after>// Click on get more info link on the user/trip index page, populates with trips?s

// Trip Constructor
function Trip(user_id, city, trip_nickname, start_date, end_date){
  this.user_id = user_id;
  this.city = city;
  this.trip_nickname = trip_nickname;
  this.start_date = start_date;
  this.end_date = end_date;

  // Lets you know if the trip is upcoming or past
  this.countdown = function(){
    var todayDate = new Date();
    if(start_date.getTime() > todayDate.getTime()){
      return "This trip is coming up";
    }
    else {
      return "This trip has already passed";
    }
  }
}

$(function(){
  $(".js-more").on("click", function(event){
    event.preventDefault();
    // this is <a class="js-more" href="/trips/1">More Info</a>
    
    var tripUrl = (this.href += ".json");

    // AJAX call
    $.get(tripUrl).success(function(response){
      var tripDiv = 'div.trip-info-' + response["trip"]["id"];

      // Use the trip constructor
      var newTripInfo = new Trip(
        response["trip"]["user_id"],
        response["trip"]["destination"]["city"],
        response["trip"]["trip_nickname"],
        response["trip"]["start_date"],
        response["trip"]["end_date"]
        );
      
      // Show data in the div
      $(tripDiv).append(newTripInfo.trip_nickname 
        + " is in " + newTripInfo.city + " from " + newTripInfo.start_date
        + " to " + newTripInfo.end_date);
    })
  })
})
{'fraction_non_alphanumeric': 0.158496129745669, 'fraction_numerical': 0.0007371913011426465, 'mean_word_length': 2.9390420899854863, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, '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': '1186126', 'n_tokens_mistral': 906, 'n_tokens_neox': 889, 'n_words': 202}