Newer
Older
Digital_Repository / Repositories / Maps / css_map.js
// Global XMLHttpRequest object.
var httpRequest = new XMLHttpRequest();

function load( startMillis, numEntries )
{
	// Open the request. Setting the third argument to TRUE makes the
	// request asynchronous, i.e., the browser doesn't wait.
	http.open('GET', 'css_map.php?top=' + numEntries, true);
	
	// When we hear something from the server, call the handleResponse()
	// function to find out what happened.
	http.onreadystatechange = function ()
		{
			if(http.readyState == 4)
			{
				if (http.status == 200) // Did it work?
				{
					// Grab the response content.
					var response = http.responseText;
			
				}
				else
				{
					// Do some sort of error handling.
				}
			}
		};
	
	// Send the request.
	http.send(null);


		GDownloadUrl( "google_map_generate_data.pl?top=" + numEntries,
			function( data, responseCode )
			{
				var xml = GXml.parse( data );
				var markerlist = xml.documentElement.getElementsByTagName( "marker" );
				for ( var i = 0; i < markerlist.length; i++ )
				{
					var point = new GLatLng( parseFloat( markerlist[i].getAttribute( "lat" ) ),
						parseFloat( markerlist[i].getAttribute( "long" ) ) );
					map.addOverlay( createMarker( point, markerlist[i].getAttribute( "city" ),
						markerlist[i].getAttribute( "abs" ), markerlist[i].getAttribute( "dl" ) ) );
				}
				// Grab finishing time. We have to do this here rather than in
				// the main part of the load() function because the map data
				// are loaded asynchronously.
				var endTime = new Date();
				var numUA = xml.documentElement.getAttribute( "ua" );
				var numUD = xml.documentElement.getAttribute( "ud" );
				document.getElementById( "timer" ).innerHTML =
					'<span style="color:red;">' +
					xml.documentElement.getAttribute( "dl" ) +
					' downloads' + ( ( numUD > 0 ) ? ( ' (+' + numUD + ' unmappable)' ) : '' ) +
					'</span> & <span style="color:blue;">' +
					xml.documentElement.getAttribute( "abs" ) +
					' abstracts' + ( ( numUD > 0 ) ? ( ' (+' + numUA + ' unmappable)' ) : '' ) +
					'</span> from ' +
					markerlist.length +
					' cities (' +
					xml.documentElement.getAttribute( "ips" ) +
					' IP addresses), page generated in ' +
					( endTime - startMillis ) +
					' ms.';
			} );
	}
}