<commit_before>'use strict';

var w = window.innerWidth
|| document.documentElement.clientWidth
|| document.body.clientWidth;

var h = window.innerHeight
|| document.documentElement.clientHeight
|| document.body.clientHeight;

var pos;
var map;
var marker;
var gpsMarker;
var followGps = 0;

// Call this function when the page loads (the "ready" event)
$(document).ready(function() {
	initializePage();
	GoogleMap();
	//google.maps.event.addDomListener(window, 'load', initialize);
})

/*
 * Function that is called when the document is ready.
 */
function initializePage() {
	$("#searchBtn").click(updateResult);
	$('#map_container').css('width', w);
	$('#map_container').css('height', h);
	$('#map_canvas').css('width', w);
	$('#map_canvas').css('height', h-26);

	$.get("/building", setBuildingList);


}

function setBuildingList(result){
	//console.log(result);
	var buildingList = [];

	for( var i in result ){
		var tempInfo = result[i];
		buildingList[i] = tempInfo['name'];

		if( tempInfo['code'] != 'N/A' || tempInfo['buildingnumber'] != 'N/A'){ buildingList[i]+=" |";}

		if( tempInfo['code'] != 'N/A'){ buildingList[i] += ' (' + tempInfo['code'] + ')'; } 
		if( tempInfo['buildingnumber'] != 'N/A'){ buildingList[i] += ' [' + tempInfo['buildingnumber'] + ']'; } 
	}

    var availableTags = buildingList;
    $( "#buildingInput" ).autocomplete({
      source: availableTags
    });
}

function updateResult(e) {
	// Prevent following the link
	e.preventDefault();
	console.log("user clicked on search button");
	var buildingCode = $('#buildingInput').val();
	//buildingCode = buildingCode.toUpperCase();
	$.get("/building", getBuildingDetails);
}

function getBuildingDetails(result){
	var building = 'No Result.';
	var buildingInput = $('#buildingInput').val();

	var indexOfBar =  buildingInput.indexOf("|");
	if( indexOfBar != -1 )
	{
		buildingInput = buildingInput.substring(0, indexOfBar-1);
		console.log(buildingInput);
	}



	for (var i in result){
		var tempInfo = result[i];
		if (buildingInput == tempInfo['name']) {
			building = tempInfo;
			break;
		}
	}

	if( building == 'No Result.'){
		for (var i in result){
			var tempInfo = result[i];
			if (buildingInput == tempInfo['code']) {
				building = tempInfo;
				break;
			}
		}
	}

	if( building == 'No Result.'){
		for (var i in result){
			var tempInfo = result[i];
			if (buildingInput == tempInfo['buildingnumber']) {
				building = tempInfo;
				break;
			}
		}
	}

	//console.log(result);
	var detailsHTML;
	//set result HTML
	if (building == 'No Result.'){
		var detailsHTML = '<nav class="navbar navbar-inverse navbar-fixed-bottom" id="result"><div class="container"><strong>'+building+'</strong></div></nav>';
	}
	else {
		var detailsHTML = '<nav class="navbar navbar-inverse navbar-fixed-bottom" id="result"><div class="container"><strong>'+building['name']+'</strong><br><small>'+building['location']+ " " +building['buildingnumber']+'</div></nav>';
	}
	$('.result').html(detailsHTML);

	//Removing previous Marker
	if( marker != null ) {marker.setMap(null);}

	if(building != 'No Result.'){
		//Setting new Marker
		var pos = new google.maps.LatLng(building['lat'], building['long']);
		marker = new google.maps.Marker({
	    	map: map
	    });

		map.setPosition(pos);
		map.setCenter(pos);
	}
	//get random corrdinates that are within the screen
	//var randomX = Math.floor(w * Math.random());
	//var randomY = Math.floor(h * Math.random());
	//var markerHTML = '<span class="glyphicon glyphicon-map-marker" style="margin-top:'+randomY+'px; margin-left:'+randomX+'px"></span>';
	//$('#marker').html(markerHTML);
}

function GoogleMap()
{
	// get map section ID<commit_msg>Icon marker changes some changes<commit_after>'use strict';

var w = window.innerWidth
|| document.documentElement.clientWidth
|| document.body.clientWidth;

var h = window.innerHeight
|| document.documentElement.clientHeight
|| document.body.clientHeight;

var pos;
var map;
var marker;
var gpsMarker;
var followGps = 0;

// Call this function when the page loads (the "ready" event)
$(document).ready(function() {
	initializePage();
	GoogleMap();
	//google.maps.event.addDomListener(window, 'load', initialize);
})

/*
 * Function that is called when the document is ready.
 */
function initializePage() {
	$("#searchBtn").click(updateResult);
	$('#map_container').css('width', w);
	$('#map_container').css('height', h);
	$('#map_canvas').css('width', w);
	$('#map_canvas').css('height', h-26);

	$.get("/building", setBuildingList);


}

function setBuildingList(result){
	//console.log(result);
	var buildingList = [];

	for( var i in result ){
		var tempInfo = result[i];
		buildingList[i] = tempInfo['name'];

		if( tempInfo['code'] != 'N/A' || tempInfo['buildingnumber'] != 'N/A'){ buildingList[i]+=" |";}

		if( tempInfo['code'] != 'N/A'){ buildingList[i] += ' (' + tempInfo['code'] + ')'; } 
		if( tempInfo['buildingnumber'] != 'N/A'){ buildingList[i] += ' [' + tempInfo['buildingnumber'] + ']'; } 
	}

    var availableTags = buildingList;
    $( "#buildingInput" ).autocomplete({
      source: availableTags
    });
}

function updateResult(e) {
	// Prevent following the link
	e.preventDefault();
	console.log("user clicked on search button");
	var buildingCode = $('#buildingInput').val();
	//buildingCode = buildingCode.toUpperCase();
	$.get("/building", getBuildingDetails);
}

function getBuildingDetails(result){
	var building = 'No Result.';
	var buildingInput = $('#buildingInput').val();

	var indexOfBar =  buildingInput.indexOf("|");
	if( indexOfBar != -1 )
	{
		buildingInput = buildingInput.substring(0, indexOfBar-1);
		console.log(buildingInput);
	}



	for (var i in result){
		var tempInfo = result[i];
		if (buildingInput == tempInfo['name']) {
			building = tempInfo;
			break;
		}
	}

	if( building == 'No Result.'){
		for (var i in result){
			var tempInfo = result[i];
			if (buildingInput == tempInfo['code']) {
				building = tempInfo;
				break;
			}
		}
	}

	if( building == 'No Result.'){
		for (var i in result){
			var tempInfo = result[i];
			if (buildingInput == tempInfo['buildingnumber']) {
				building = tempInfo;
				break;
			}
		}
	}

	//console.log(result);
	var detailsHTML;
	//set result HTML
	if (building == 'No Result.'){
		var detailsHTML = '<nav class="navbar navbar-inverse navbar-fixed-bottom" id="result"><div class="container"><strong>'+building+'</strong></div></nav>';
	}
	else {
		var detailsHTML = '<nav class="navbar navbar-inverse navbar-fixed-bottom" id="result"><div class="container"><strong>'+building['name']+'</strong><br><small>'+building['location']+ " " +building['buildingnumber']+'</div></nav>';
	}
	$('.result').html(detailsHTML);

	//Removing previous Marker
	if( marker != null ) {marker.setMap(null);}

	if(building != 'No Result.'){
		//Setting new Marker
		var pos = new google.maps.LatLng(building['lat'], building['long']);
		marker = new google.maps.Marker({
	    	map: map,
	    	icon: 'images/clocation.png'
	    });

		map.setPosition(pos);
		map.setCenter(pos);
	}
	//get random corrdinates that are within the screen
	//var randomX = Math.floor(w * Math.random());
	//var randomY = Math.floor(h * Math.random());
	//var markerHTML = '<span class="glyphicon glyphicon-map-marker" style="margin-top:'+randomY+'px; margin-left:'+randomX+'px"></span>';
	//$('#marker').html(markerHTML);
}

function GoogleMap()
{
	// get map section ID
{'fraction_non_alphanumeric': 0.1926667568664592, 'fraction_numerical': 0.0016235962657285888, 'mean_word_length': 4.423330887747616, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 35, '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': '881310', 'n_tokens_mistral': 2548, 'n_tokens_neox': 2396, 'n_words': 547}