<commit_before>(function() {

	var map = null;
	var markers = [];

	var initMap = function() {
		// Default to a central view of the US
		var centerLatLng = new google.maps.LatLng(39.833333, -98.583333);
		var zoomLevel = 4;

		// If we can guess the user's location, zoom into this level instead
		if (google.loader.ClientLocation) {
			var clientLocation = google.loader.ClientLocation;
			centerLatLng = new google.maps.LatLng(clientLocation.latitude, clientLocation.longitude);
			zoomLevel = 7;
		}

		var mapOptions = {
			zoom: zoomLevel,
			center: centerLatLng,
			mapTypeId: google.maps.MapTypeId.TERRAIN
		}

		map = new google.maps.Map($(".map-page")[0], mapOptions);
	};

	var compareLatLng = function(a, b) {
		if (a.lat() < b.lat()) 			{ return -1; }
		else if (a.lat() > b.lat()) 	{ return 1;  }
		else if (a.lng() < b.lng()) 	{ return -1; }
		else if (a.lng() > b.lng()) 	{ return 1;  }
		else 							{ return 0;  }
	};

	var handleGetHikesInBoundsResponse = function(data) {
		var i = 0;
		var j = 0;
		var newMarkers = [];
		while (i != data.length || j != markers.length) {
			var newLatLng = null;
			var oldMarker = null;
			var oldLatLng = null;

			if (i < data.length) {
				newLatLng = new google.maps.LatLng(data[i].latitude, data[i].longitude);
			}

			if (j < markers.length) {
				oldMarker = markers[j];
				oldLatLng = oldMarker.getPosition();
			}
			
			if (!oldLatLng || (newLatLng && compareLatLng(newLatLng, oldLatLng) < 0)) {
				// This is a brand new marker, add it
				var marker = new google.maps.Marker({
					icon: {
						path: google.maps.SymbolPath.CIRCLE,
						fillOpacity: 1,
						fillColor: "ff6262",
						strokeWeight: 1.0, 
						scale: 4
					  },
					map: map,
					position: newLatLng
				});
				newMarkers.push(marker);
				i++;
			} else if (!newLatLng || (oldLatLng && compareLatLng(newLatLng, oldLatLng) > 0)) {
				// The old marker is no longer in use, remove it
				oldMarker.setMap(null);
				j++;
			} else {
				// Use the existing marker
				newMarkers.push(oldMarker);
				i++;
				j++;
			}
		}
		markers = newMarkers;
	};

	var initSocketIo = function() {
		var socket = io.connect(location.protocol + "//" + location.hostname + ":8080");
		google.maps.event.addListener(map, "idle", function() {
			var mapBounds = map.getBounds();
			var northEast = mapBounds.getNorthEast();
			var northEastLatLng = { 
				latitude: northEast.lat(), 
				longitude: northEast.lng() 
			};
			var southWest = mapBounds.getSouthWest();
			var southWestLatLng = { 
				latitude: southWest.lat(), 
				longitude: southWest.lng() 
			};
			socket.emit("get-hikes-in-bounds", { ne:northEastLatLng, sw:southWestLatLng });
		});
		
		socket.on("get-hikes-in-bounds", function (data) {
			handleGetHikesInBoundsResponse(data);
		});
	};

	$(document).ready(function() {
		if ($(".map-page").length) {
			initMap();
			initSocketIo();
		}
	});
}
)();<commit_msg>Redirect to entry page on map marker click.<commit_after>(function() {

	var map;
	var markers;
	var defaultMarker;
	var hoverMarker;

	var initIcons = function() {
		defaultMarker = {
			path: google.maps.SymbolPath.CIRCLE,
			fillOpacity: 1,
			fillColor: "ff6262",
			strokeWeight: 1.0,
			scale: 4
		};
		hoverMarker = {
			path: google.maps.SymbolPath.CIRCLE,
			fillOpacity: 1,
			fillColor: "ffff33",
			strokeWeight: 1.0,
			scale: 5
		};
	};

	var initMap = function() {
		// Default to a central view of the US
		var centerLatLng = new google.maps.LatLng(39.833333, -98.583333);
		var zoomLevel = 4;

		// If we can guess the user's location, zoom into this level instead
		if (google.loader.ClientLocation) {
			var clientLocation = google.loader.ClientLocation;
			centerLatLng = new google.maps.LatLng(clientLocation.latitude, clientLocation.longitude);
			zoomLevel = 7;
		}

		var mapOptions = {
			zoom: zoomLevel,
			center: centerLatLng,
			mapTypeId: google.maps.MapTypeId.TERRAIN
		}

		map = new google.maps.Map($(".map-page")[0], mapOptions);
		markers = [];
	};

	var compareLatLng = function(a, b) {
		if (a.lat() < b.lat()) 			{ return -1; }
		else if (a.lat() > b.lat()) 	{ return 1;  }
		else if (a.lng() < b.lng()) 	{ return -1; }
		else if (a.lng() > b.lng()) 	{ return 1;  }
		else 							{ return 0;  }
	};

	var addMarkerEvents = function(marker, entryData) {
		google.maps.event.addListener(marker, "mouseover", function() {
			marker.setIcon(hoverMarker);
		});
				
		google.maps.event.addListener(marker, "mouseout", function() {
			marker.setIcon(defaultMarker);
		});

		google.maps.event.addListener(marker, "click", function() {
			window.location.href = entryData.string_id;
		});
	};

	var handleGetHikesInBoundsResponse = function(reponseData) {
		var i = 0;
		var j = 0;
		var newMarkers = [];
		while (i != reponseData.length || j != markers.length) {
			var newLatLng = null;
			var oldMarker = null;
			var oldLatLng = null;

			if (i < reponseData.length) {
				newLatLng = new google.maps.LatLng(reponseData[i].latitude, reponseData[i].longitude);
			}

			if (j < markers.length) {
				oldMarker = markers[j];
				oldLatLng = oldMarker.getPosition();
			}
			
			if (!oldLatLng || (newLatLng && compareLatLng(newLatLng, oldLatLng) < 0)) {
				// This is a brand new marker, add it
				var marker = new google.maps.Marker({
					icon: defaultMarker,
					map: map,
					position: newLatLng
				});
				addMarkerEvents(marker, reponseData[i]);
				newMarkers.push(marker);
				i++;
			} else if (!newLatLng || (oldLatLng && compareLatLng(newLatLng, oldLatLng) > 0)) {
				// The old marker is no longer in use, remove it
				oldMarker.setMap(null);
				j++;
			} else {
				// Use the existing marker
				newMarkers.push(oldMarker);
				i++;
				j++;
			}
		}
		markers = newMarkers;
	};

	var initSocketIo = function() {
		var socket = io.connect(location.protocol + "//" + location.hostname + ":8080");
		google.maps.event.addListener(map, "idle", function() {
			var mapBounds = map.getBounds();
			var northEast = mapBounds.getNorthEast();
			var northEastLatLng = { 
				latitude: northEast.lat(), 
				longitude: northEast.lng() 
			};
			var southWest = mapBounds.getSouthWest();
			var southWestLatLng = { 
				latitude: southWest.lat(), 
				longitude: southWest.lng() 
			};
			socket.emit("get-hikes-in-bounds", { ne:northEastLatLng, sw:southWestLatLng });
		});
		
		socket.on("get-hikes-in-bounds", function (data) {
			handleGetHikesInBoundsResponse(data);
		});
	};

	$(document).ready(function() {
		if ($(".map-page").length) {
			initIcons();
			initMap();
			initSocketIo();
		}
	});
}
)();
{'fraction_non_alphanumeric': 0.15264038959062548, 'fraction_numerical': 0.013087810074570081, 'mean_word_length': 3.039336201598033, 'pattern_counts': {'":': 2, '<': 13, '<?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': '1490459', 'n_tokens_mistral': 2871, 'n_tokens_neox': 2359, 'n_words': 521}