<commit_before>$(function() {
  var lat, lon, map;

  /*******************
  LOCATION AND MAPPING
  *******************/

  // Use HTML5 GeoLocation to get lat/long
  var getLocation = function() {
    if (navigator.geolocation) {
      navigator.geolocation.getCurrentPosition(getAddress);
    } else {
      updateLocationField('Geolocation not supported...');
    }
  };

  // Use GoogleMaps API to get nearest address for lat/long
  var getAddress = function(position) {
    lat =position.coords.latitude;
    lon =position.coords.longitude;



    initLeafletMap(lat, lon);

    var maps_url = "http://maps.googleapis.com/maps/api/geocode/json?latlng=" + lat + "," + lon +"&sensor=true";

    $.get(maps_url, function(data) {
      var parts   = data.results[0].address_components.slice(0,4);

      var address = "";
      $.each(parts, function(index, value) {
        if (index === 0) {
          address += value.short_name;  
        } else {
          address += ", " + value.short_name;
        }
      });

      updateLocationField(address);
    })
    .fail(function() {
      updateLocationField('Cannot get location...');
    });
  };

  // Update 'location' field in UI
  var updateLocationField = function(text) {
    $('#location').html('<p>' + text + '</p>');
  };

  // Create Leaflet Map centered at user's location
  var initLeafletMap = function(lat, lon) {
    map = L.map('map', {scrollWheelZoom: false}).setView([lat, lon], 14);

    L.mapbox.tileLayer('alexnorton.h2hfjmmo', {detectRetina: true}).addTo(map);

    L.marker([lat, lon], { 
      bounceOnAdd: true
    }).addTo(map);

    $('#map_btn').show();
    $('#map').css('border-style', 'solid');

    addPredictionCard();
  };

  var initFSMap = function(markers) {
    var fs_map = L.map('fs_map', {scrollWheelZoom: false}).setView([lat, lon], 14);
    L.mapbox.tileLayer('alexnorton.h2hfjmmo', {detectRetina: true}).addTo(fs_map);

    var colors = ['red', 'darkred', 'orange', 'green', 'darkgreen', 'blue', 'purple', 'darkpuple', 'cadetblue'];

    var icon_lookup = {
      'Pub': 'beer',
      'Plaza': 'leaf',
      'Café': 'coffee',
      'Fast Food': 'cutlery',
      'Grocery Store': 'shopping-cart',
      'Performing Arts': 'pencil',
      'Theater': 'smile-o'
    }

    $.each(markers, function(index, value) {
      var color = colors[Math.floor(Math.random() * colors.length)];

      var redMarker = L.AwesomeMarkers.icon({
        icon: icon_lookup[value.icon],
        prefix: 'fa',
        markerColor: color
      });

      var marker = L.marker(value.points, {icon: redMarker}, { 
        bounceOnAdd: true
      }).addTo(fs_map);
      marker.bindPopup(value.text);
    });
  };

  getLocation();

  /***********
  ADDING CARDS
  ***********/
<commit_msg>Set FourSquare map bounds to fit visible markers<commit_after>$(function() {
  var lat, lon, map;

  /*******************
  LOCATION AND MAPPING
  *******************/

  // Use HTML5 GeoLocation to get lat/long
  var getLocation = function() {
    if (navigator.geolocation) {
      navigator.geolocation.getCurrentPosition(getAddress);
    } else {
      updateLocationField('Geolocation not supported...');
    }
  };

  // Use GoogleMaps API to get nearest address for lat/long
  var getAddress = function(position) {
    lat =position.coords.latitude;
    lon =position.coords.longitude;



    initLeafletMap(lat, lon);

    var maps_url = "http://maps.googleapis.com/maps/api/geocode/json?latlng=" + lat + "," + lon +"&sensor=true";

    $.get(maps_url, function(data) {
      var parts   = data.results[0].address_components.slice(0,4);

      var address = "";
      $.each(parts, function(index, value) {
        if (index === 0) {
          address += value.short_name;  
        } else {
          address += ", " + value.short_name;
        }
      });

      updateLocationField(address);
    })
    .fail(function() {
      updateLocationField('Cannot get location...');
    });
  };

  // Update 'location' field in UI
  var updateLocationField = function(text) {
    $('#location').html('<p>' + text + '</p>');
  };

  // Create Leaflet Map centered at user's location
  var initLeafletMap = function(lat, lon) {
    map = L.map('map', {scrollWheelZoom: false}).setView([lat, lon], 14);

    L.mapbox.tileLayer('alexnorton.h2hfjmmo', {detectRetina: true}).addTo(map);

    L.marker([lat, lon], { 
      bounceOnAdd: true
    }).addTo(map);

    $('#map_btn').show();
    $('#map').css('border-style', 'solid');

    addPredictionCard();
  };

  var initFSMap = function(markers) {
    var fs_map = L.map('fs_map', {scrollWheelZoom: false}).setView([lat, lon], 14);
    L.mapbox.tileLayer('alexnorton.h2hfjmmo', {detectRetina: true}).addTo(fs_map);

    var colors = ['red', 'darkred', 'orange', 'green', 'darkgreen', 'blue', 'purple', 'darkpuple', 'cadetblue'];

    var icon_lookup = {
      'Pub': 'beer',
      'Plaza': 'leaf',
      'Café': 'coffee',
      'Fast Food': 'cutlery',
      'Grocery Store': 'shopping-cart',
      'Performing Arts': 'pencil',
      'Theater': 'smile-o'
    }

      var markerLayers = [];

    $.each(markers, function(index, value) {
      var color = colors[Math.floor(Math.random() * colors.length)];

      var redMarker = L.AwesomeMarkers.icon({
        icon: icon_lookup[value.icon],
        prefix: 'fa',
        markerColor: color
      });

      var marker = L.marker(value.points, {icon: redMarker}, { 
        bounceOnAdd: true
      });
      marker.bindPopup(value.text);

        markerLayers.push(marker);
      });

      var markerLayerGroup = new L.FeatureGroup(markerLayers);
      markerLayerGroup.addTo(fs_map);
      fs_map.fitBounds(markerLayerGroup.getBounds());
  };

  getLocation();

  /***********
  ADDING CARDS
  ***********/

{'fraction_non_alphanumeric': 0.18488996707676314, 'fraction_numerical': 0.003812164269623982, 'mean_word_length': 2.8816408876933424, 'pattern_counts': {'":': 0, '<': 7, '<?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': '2843401', 'n_tokens_mistral': 1976, 'n_tokens_neox': 1884, 'n_words': 379}