<commit_before>// Set underscore template settings
_.templateSettings = {
  interpolate : /\{\{(.+?)\}\}/g
};


// Setup mapbox
L.mapbox.accessToken = '<KEY>';


var tripTemplate = _.template($('#tripTemplate').html()),
    trips = [],
    map;

// user settings
var mileageRate = 0.56;

fetchFriends(renderFriends);
fetchTrips(renderTrips);


$('#trip').on('click', '.nextTrip', function(e) {
  console.log($(e.target).data('tripId'));
});



function renderFriends(friends) {
  console.log(friends);
}


function renderTrips(data) {
  trips = data;
  if(trips.length) {
    renderTrip(trips[0]);
  } else {
    showAlert('No Trips', 'error');
  }
}


function renderTrip(trip) {
  console.log(trip);


  $('#trip')
    .html(tripTemplate(trip))
    .data('trip', trip);

  updateCost(trip);

  renderMap(trip);

  updateTripControls(trip);
}


function updateCost(trip) {
  var tripCost = calculateTripCost(trip);
  $('#trip .costData').html(formatCost(tripCost));
}


function renderMap(trip) {
  var map = L.mapbox.map('map', 'automatic.idonii25')
      start = [trip.StartLocation.Lat, trip.StartLocation.Lng],
      end = [trip.LastKnownLocation.Lat, trip.LastKnownLocation.Lng];

  map.fitBounds([start, end]);

  var startIcon = L.icon({
    iconUrl: '/images/marker_start.png',
    iconSize: [70, 64],
    iconAnchor: [35, 64],
    popupAnchor: [0,-41],
    shadowUrl: '/images/marker_shadow.png',
    shadowSize: [70, 64],
    shadowAnchor: [35, 64]
  });

  var endIcon = L.icon({
    iconUrl: '/images/marker_end.png',
    iconSize: [70, 64],
    iconAnchor: [35, 64],
    popupAnchor: [0,-41],
    shadowUrl: '/images/marker_shadow.png',
    shadowSize: [70, 64],
    shadowAnchor: [35, 64]
  });

  L.marker(start, {title: 'Start Location', icon: startIcon})
    .bindPopup(trip.StartAddressFormatted + '<br>' + trip.StartCityState + trip.StartDateTime)
    .addTo(map);

  L.marker(end, {title: 'End Location', icon: endIcon})
    .bindPopup(trip.StartAddressFormatted + '<br>' + trip.StartCityState + trip.StartDateTime)
    .addTo(map);
}

function updateTripControls(trip) {
  $('.nextTrip')
    .toggleClass('disabled', !!trip.NextTrip)
    .data('tripId', trip.NextTrip);
  $('.prevTrip')
    .toggleClass('disabled', !!trip.PrevTrip)
    .data('tripId', trip.PrevTrip);
}<commit_msg>Prev/Next Trips<commit_after>// Set underscore template settings
_.templateSettings = {
  interpolate : /\{\{(.+?)\}\}/g
};


// Setup mapbox
L.mapbox.accessToken = '<KEY>';


var tripTemplate = _.template($('#tripTemplate').html()),
    trips = [],
    map;

// user settings
var mileageRate = 0.56;

fetchFriends(renderFriends);
fetchTrips(renderTrips);


$('#trip')
.on('click', '.nextTrip, .prevTrip', function(e) {
  var tripId = $(e.target).data('tripId'),
      trip = _.findWhere(trips, {_id: tripId});

  if(trip) {
    renderTrip(trip);
  } 
});



function renderFriends(friends) {
  console.log(friends);
}


function renderTrips(data) {
  trips = data;
  if(trips.length) {
    renderTrip(trips[0]);
  } else {
    showAlert('No Trips', 'error');
  }
}


function renderTrip(trip) {
  console.log(trip);


  $('#trip')
    .html(tripTemplate(trip))
    .data('trip', trip);

  updateCost(trip);

  renderMap(trip);

  updateTripControls(trip);
}


function updateCost(trip) {
  var tripCost = calculateTripCost(trip);
  $('#trip .costData').html(formatCost(tripCost));
}


function renderMap(trip) {
  var map = L.mapbox.map('map', 'automatic.idonii25')
      start = [trip.StartLocation.Lat, trip.StartLocation.Lng],
      end = [trip.LastKnownLocation.Lat, trip.LastKnownLocation.Lng];

  map.fitBounds([start, end]);

  var startIcon = L.icon({
    iconUrl: '/images/marker_start.png',
    iconSize: [70, 64],
    iconAnchor: [35, 64],
    popupAnchor: [0,-41],
    shadowUrl: '/images/marker_shadow.png',
    shadowSize: [70, 64],
    shadowAnchor: [35, 64]
  });

  var endIcon = L.icon({
    iconUrl: '/images/marker_end.png',
    iconSize: [70, 64],
    iconAnchor: [35, 64],
    popupAnchor: [0,-41],
    shadowUrl: '/images/marker_shadow.png',
    shadowSize: [70, 64],
    shadowAnchor: [35, 64]
  });

  L.marker(start, {title: 'Start Location', icon: startIcon})
    .bindPopup(trip.StartAddressFormatted + '<br>' + trip.StartCityState + trip.StartDateTime)
    .addTo(map);

  L.marker(end, {title: 'End Location', icon: endIcon})
    .bindPopup(trip.StartAddressFormatted + '<br>' + trip.StartCityState + trip.StartDateTime)
    .addTo(map);
}

function updateTripControls(trip) {
  $('.nextTrip')
    .toggleClass('disabled', !trip.NextTrip)
    .data('tripId', trip.NextTrip);
  $('.prevTrip')
    .toggleClass('disabled', !trip.PrevTrip)
    .data('tripId', trip.PrevTrip);
}
{'fraction_non_alphanumeric': 0.18496496071352728, 'fraction_numerical': 0.018687619452112975, 'mean_word_length': 3.796334012219959, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2103050', 'n_tokens_mistral': 1822, 'n_tokens_neox': 1667, 'n_words': 307}