<commit_before>$(function() {
  var map = L.map('map').setView([41.505, 25.00], 3);

  L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}', {
      attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>',
      maxZoom: 18,
      id: 'sophiasanchez.c3eddfe3',
      accessToken: '<KEY>'
  }).addTo(map);

  var Map = {
    self.countries = {};
    highlightCountries: function(countryNames, highlightStyle, layer) {
      for (var countryName in countriesNames) {
        country = self.countries[countryName];
        country.highlight(highlightStyle, layer);
      }
    }
  }

  var Trip = {
    drawTripLine: function(){};

  }

  function Country (name, coordinates) {
    this.name = name;
    this.coordinates = coordinates;
    this.selected = false,

    highlight: function(color, weight, fillOpacity, layerGroup) {
      layerGroup.addLayer(self.coordinates);
      self.coordinates.setStyle({
        weight: weight,
        color: color,
        dashArray: '',
        fillOpacity: fillOpacity,
      });
    }
  }




  var currentlySelectedCountry = null;
  var currentTarget = null;
  var endCountries = {};
  var latlngs = Array();
  var polylines = [];
  var polylineLayergroup = L.layerGroup();

  // FIXME: cache the JSON, don't reload it every time
  d3.json(COUNTRIES_DATA_JSON_URL, function (json){
    country = new Country(name, coordinates);
    Map.countries[name] = country;
    
    function style(feature) {
      return {
        fillColor: "#E3E3E3",
        weight: 1,
        opacity: 0.4,
        color: 'white',
        fillOpacity: 0.3
      };
    }
    geojson = L.geoJson(json, {
      onEachFeature: onEachFeature,
      style : style
    }).addTo(map);

    function onEachFeature(feature, layer){
      layer.on({
        click : onCountryClick,
        mouseover : onCountryHighLight,
        mouseout : onCountryMouseOut
      });
    }
  });

  /**
   * Callback for when a country is highlighted. Will take care of the ui aspects, and it will call
   * other callbacks after done.<commit_msg>Caching d3.json<commit_after>$(function() {
  var map = L.map('map').setView([41.505, 25.00], 3);

  L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}', {
      attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>',
      maxZoom: 18,
      id: 'sophiasanchez.c3eddfe3',
      accessToken: '<KEY>'
  }).addTo(map);

  var Map = {
    self.countries = {};
    highlightCountries: function(countryNames, highlightStyle, layer) {
      for (var countryName in countriesNames) {
        country = self.countries[countryName];
        country.highlight(highlightStyle, layer);
      }
    }
  }

  var Trip = {
    drawTripLine: function(){};

  }

  function Country (name, coordinates) {
    this.name = name;
    this.coordinates = coordinates;
    this.selected = false,

    highlight: function(color, weight, fillOpacity, layerGroup) {
      layerGroup.addLayer(self.coordinates);
      self.coordinates.setStyle({
        weight: weight,
        color: color,
        dashArray: '',
        fillOpacity: fillOpacity,
      });
    }
  }




  var currentlySelectedCountry = null;
  var currentTarget = null;
  var endCountries = {};
  var latlngs = Array();
  var polylines = [];
  var polylineLayergroup = L.layerGroup();

  // FIXME: cache the JSON, don't reload it every time
  d3.json(COUNTRIES_DATA_JSON_URL, function (json){
    data = json.features;
    for (var i = 0; i < data.length; i++) {
      name = data[i].properties.name;
      coordinates = reverseCoordinates(data[i].geometry.coordinates[0]);
      country = new Country(name, coordinates);
      Map.countries[name] = country;
    };

    function style(feature) {
      return {
        fillColor: "#E3E3E3",
        weight: 1,
        opacity: 0.4,
        color: 'white',
        fillOpacity: 0.3
      };
    }
    geojson = L.geoJson(json, {
      onEachFeature: onEachFeature,
      style : style
    }).addTo(map);

    function onEachFeature(feature, layer){
      layer.on({
        click : onCountryClick,
        mouseover : onCountryHighLight,
        mouseout : onCountryMouseOut
      });
    }
  });

  /**
   * Callback for when a country is highlighted. Will take care of the ui aspects, and it will call
   * other callbacks after done.
{'fraction_non_alphanumeric': 0.1407185628742515, 'fraction_numerical': 0.01176218990590248, 'mean_word_length': 2.7266932270916335, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 17, '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': '733373', 'n_tokens_mistral': 1559, 'n_tokens_neox': 1491, 'n_words': 327}