<commit_before>
/*
	Initialize the Google Map
	Might include some kind of randomization later?
*/
function initialize() {
	var mapOptions = {
		center: new google.maps.LatLng(41.931124, -87.648044),
		zoom: 15
	};

	var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
}


/*
	Set the score at a location.
	Need to figure out how to put custom HTML as a pin.
*/
function display_score_at_location(location, score, lat, lng) {
	var lat_lng = new google.maps.LatLng(lat, lng);

	// Set up the map
	var mapOptions = {
		center: lat_lng,
		zoom: 15
	};

	// Create the map
	var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);

	// Create a marker to attach the score info to
	var marker = new google.maps.Marker({
	    position: lat_lng,
	    map: map
	});

	// Render the score template
	var template = '<p>{{ location }}</p><h1>{{ score }}</h1>';
	var data = {score: score, location: location}
	var rendered = Mustache.render(template, data);

	// Set the score to an info window
	var infowindow = new google.maps.InfoWindow({
		content: rendered
	});

	// Apply the info window listener
	google.maps.event.addListener(marker, 'click', function() {
	    infowindow.open(map,marker);
	});

	// Start with the window open
	infowindow.open(map,marker);
}


function get_score(location) {
	var url = '/score/' + location;

	$.getJSON(url, function(data) {
		display_score_at_location(location, data.score, data.lat, data.lng);
	});
}

/*
	Register the click listener for the burrito submit button.
*/
$('#get_burrito_score').on('click', function() {
	var address = $('#address').val();
	if (address != '' && address != null) {
		get_score(address);
	}
});
<commit_msg>use new results for businesses<commit_after>var geocoder;
var map;
var score_template = '<p>{{ location }}</p><h1>{{ score }}</h1>';
var business_template = '<p>{{ name }}</p><h1>{{ score }}</h1>';

/*
	Initialize the Google Map
	Might include some kind of randomization later?
*/
function initialize() {
	geocoder = new google.maps.Geocoder();

	var mapOptions = {
		center: new google.maps.LatLng(41.931124, -87.648044),
		zoom: 15
	};

	map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
}


function place_business_marker(business) {
	var marker = new google.maps.Marker({
		map: map,
		position: new google.maps.LatLng(business['lat'], business['lon'])
	});

	var data = {name: business['name'], score: business['score']};
	var rendered = Mustache.render(business_template, data);

	var infowindow = new google.maps.InfoWindow({
		content: rendered
	});

	google.maps.event.addListener(marker, 'click', function() {
		infowindow.open(map, marker);
	});
}


/*
	Set the score at a location.
	Need to figure out how to put custom HTML as a pin.
*/
function display_score_at_location(location, score, businesses) {
	// Center the map on our location
	code_address(location)

	// Drop a pin in the center
	var marker = new google.maps.Marker({
		map: map,
		position: map.getCenter()
	});

	// Render the score template
	var data = {score: score, location: location}
	var rendered = Mustache.render(score_template, data);

	// Set the score to an info window
	var infowindow = new google.maps.InfoWindow({
		content: rendered
	});

	// Apply the info window listener
	google.maps.event.addListener(marker, 'click', function() {
	    infowindow.open(map, marker);
	});

	// Start with the window open
	infowindow.open(map, marker);

	// Place all the businesses
	for (var i = 0; i < businesses.length; i++) {
		place_business_marker(businesses[i]);
	}
}


function get_score(location) {
	var url = '/score/' + location;

	$.getJSON(url, function(data) {
		display_score_at_location(location, data.score, data.businesses);
	});
}


function code_address(address) {
	geocoder.geocode({'address': address}, function(results, status) {
		if (status == google.maps.GeocoderStatus.OK) {
			map.setCenter(results[0].geometry.location);
		} else {
			// handle the error
		}
	});
}

/*
	Register the click listener for the burrito submit button.
*/
$('#get_burrito_score').on('click', function() {
	// Re init the map
	initialize();

	// Get the address
	var address = $('#address').val();

	// Center on it on the map
	code_address(address);

	// Get the score and businesses on the map
	if (address != '' && address != null) {
		get_score(address);
	}
});

{'fraction_non_alphanumeric': 0.14824920418371987, 'fraction_numerical': 0.010459299681673489, 'mean_word_length': 3.987528344671202, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 15, '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': '5702818', 'n_tokens_mistral': 1512, 'n_tokens_neox': 1426, 'n_words': 419}