diff --git a/Repositories/Maps/gd_map.js b/Repositories/Maps/gd_map.js new file mode 100755 index 0000000..eb1d269 --- /dev/null +++ b/Repositories/Maps/gd_map.js @@ -0,0 +1,79 @@ +/****************************************************************************** + * Code adapted from Rasmus' 30 second AJAX Tutorial at: + * http://rajshekhar.net/blog/archives/85-Rasmus-30-second-AJAX-Tutorial.html + ******************************************************************************/ + +/****************************************************************************** + * Create XMLHttpRequest object. This happens once when the page + * is loaded. + */ +function createRequestObject() +{ + var ro; + var browser = navigator.appName; + // In typical fashion, Microsoft does things differently. + if (browser == "Microsoft Internet Explorer") + { + ro = new ActiveXObject("Microsoft.XMLHTTP"); + } + else + { + ro = new XMLHttpRequest(); + } + return ro; +} + +// Global XMLHttpRequest object. +var http = createRequestObject(); + +/****************************************************************************** + * Send a request to the back end application (written in PHP here, but + * could be ASP, Java servlets, etc.). To use this, attach it to an (X)HTML + * element either as a direct link, e.g.: + * + * [foo] + * + * or via an onclick event, e.g.: + * + * + * + * If you need different handlers for different things, just create them as + * separate PHP files on the back end, and dispatch appropriately from here. + * For example, if you want a separate handler for database operations, you + * could add another function called "sendDBRequest", or something similar. + */ +function load() +{ + // Somewhere to write the timing information to. + var timer = document.getElementById( "timer" ); + timer.innerHTML = "Loading..."; + + // Grab start time. + var startTime = new Date(); + + // Open the request. + http.open('GET', 'coordinates.pl?width=900&height=457', true); + + // Set callback function. + http.onreadystatechange = + function() + { + if(http.readyState == 4) + { + if (http.status == 200) // Did it work? + { + // Grab the response content. + var response = http.responseText; + document.getElementById( "timer" ).innerHTML = ''; + } + } + // 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(); + timer.innerHTML = 'Generated in ' + ( endTime - startTime ) + ' ms.'; + }; + + // Send the request. + http.send(null); +}