<commit_before>$(document).ready(function() {
  toggleView();
  initMap();
  usersIndex();
})

function usersIndex() {
  $(".navbar-brand").on("click", function(event) {
    event.preventDefault();
    $.ajax({
      url: '/users',
      method: 'GET',
      dataType: 'json'
    }).done(function(response){
      console.log(response);
      initMap();



    }).fail(function(response){
      console.log("shit");
    });

  });
}





function initMap() {
  if (($('#map').length) > 0) {
    // google.maps.controlStyle = 'azteca' // allow 'old-style' Pan Controls w/ new map; thru Aug '16
    // var map;
    myLatLng = {lat: 37.784580, lng: -122.397437};
    map = new google.maps.Map(document.getElementById('map'), {
      center: myLatLng,
      zoom: 11,
      fullscreenControl: false,
      // panControl: true, // doesn't work even with 'azteca' - forget about it
      mapTypeId: google.maps.MapTypeId.ROADMAP
    });

    var defaultBounds = new google.maps.LatLngBounds(
      new google.maps.LatLng(37.784580, -122.397437),
      new google.maps.LatLng(37.784580, -122.397437)
    );
    var options = { bounds: defaultBounds };
    }
};<commit_msg>Add functions to format html for Google Map Marker InfoWindow<commit_after>$(document).ready(function() {
  toggleView();
  initMap();
  usersIndex();
})

function usersIndex() {
  $(".navbar-brand").on("click", function(event) {
    event.preventDefault();
    $.ajax({
      url: '/users',
      method: 'GET',
      dataType: 'json'
    }).done(function(response){
      initMap();   // maybe don't need this here again...
      formatDataAndPlaceMarker(response.filecontent);
    }).fail(function(response){
      console.log("shit");
    });
  });
}


function formatDataAndPlaceMarker(users) {
  users.forEach(function(user){
    var name = user.name;
    var id = user.id;
    var userPageLink = '/users/' + id;
    var profile_image = user.profile_image;
    var city = user.city;
    var state = user.state;
    var postal_code = user.postal_code;
    var country = user.country;
    var locationString = "";
    if (city != null) { locationString += city; };
    if (state != null) {
      if (city != null) {
        locationString += (', ' + state);
      } else {
        locationString += (state);
      };
    };
    if (postal_code != null) {
      if (locationString != "") {
        locationString += (' ' + postal_code);
      } else {
        locationString += postal_code;
      }
    };
    if (country != null) {
      if (country != "US") {
        if (locationString != "") {
          locationString += (' ' + country);
        } else {
          locationString += country;
        }
      }
    };

    infoWindowContent = constructInfoWindowContent(profile_image, name, userPageLink, locationString);
    console.log(infoWindowContent)

    // call set marker here, with locationString & infoWindowContent

  });
}

function constructInfoWindowContent(profile_image, name, userPageLink, locationString) {
  contentString =
    '<div id="content">' +
      '<a href="' + userPageLink + '"><span><img src="' + profile_image + '" width="40" height="40" class="img-responsive"></span><h2 id="firstHeading" class="firstHeading">' + name + '</h2></a>' +
      '<div id="bodyContent">' +
        '<p>' + locationString + '<p>' +
      '</div>' +
    '</div>';
    return contentString;
}









function initMap() {
  if (($('#map').length) > 0) {
    // google.maps.controlStyle = 'azteca' // allow 'old-style' Pan Controls w/ new map; thru Aug '16
    // var map;
    myLatLng = {lat: 37.784580, lng: -122.397437};
    map = new google.maps.Map(document.getElementById('map'), {
      center: myLatLng,
      zoom: 11,
      fullscreenControl: false,
      // panControl: true, // doesn't work even with 'azteca' - forget about it
      mapTypeId: google.maps.MapTypeId.ROADMAP
    });

    var defaultBounds = new google.maps.LatLngBounds(
      new google.maps.LatLng(37.784580, -122.397437),
      new google.maps.LatLng(37.784580, -122.397437)
    );
    var options = { bounds: defaultBounds };
    }
};
{'fraction_non_alphanumeric': 0.16495851634943876, 'fraction_numerical': 0.02879453391898487, 'mean_word_length': 2.6894689468946895, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 18, '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': '6181597', 'n_tokens_mistral': 1389, 'n_tokens_neox': 1301, 'n_words': 287}