File indexing completed on 2025-01-19 03:50:51
0001 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 0002 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 0003 <head> 0004 <meta http-equiv="content-type" content="text/html; charset=utf-8"/> 0005 <title>Debug KGeoMap</title> 0006 <script type="text/javascript"> 0007 var debugTextField; 0008 var codeTextField; 0009 var scriptUrls = Array(); 0010 var lastLoadedScript = ''; 0011 var debugInitialized = false; 0012 var callRunAfterInit = false; 0013 function runMyScript() { 0014 if (!debugInitialized) { 0015 callRunAfterInit = true; 0016 initializeDebug(); 0017 return; 0018 } 0019 0020 var myCode = codeTextField.value; 0021 0022 var result = eval(myCode); 0023 if (result) { 0024 debugTextField.value = 'Result: '+result+'\n'+debugTextField.value; 0025 } 0026 } 0027 function kgeomapDebugHook(debugString) { 0028 debugTextField.value = debugString + '\n' + debugTextField.value; 0029 } 0030 function clearDebugTextField() { 0031 debugTextField.value = ''; 0032 } 0033 function initializeBackend() { 0034 kgeomapDebugHook("-- Backend loaded! Calling kgeomapInitialize"); 0035 kgeomapInitialize(); 0036 kgeomapDebugHook("-- kgeomapInitialize called!"); 0037 0038 debugInitialized = true; 0039 0040 if (callRunAfterInit) { 0041 runMyScript(); 0042 } 0043 } 0044 function loadNextJavaScriptFile() { 0045 0046 if (lastLoadedScript!='') { 0047 kgeomapDebugHook('-- Loaded: '+lastLoadedScript); 0048 lastLoadedScript = ''; 0049 } 0050 0051 if (scriptUrls.length==0) { 0052 // all scripts loaded, continue: 0053 initializeBackend(); 0054 0055 return; 0056 } 0057 0058 var scriptUrl = scriptUrls.shift(); 0059 var scriptObject = document.createElement("script"); 0060 scriptObject.setAttribute("type", "text/javascript"); 0061 scriptObject.setAttribute("charset", "utf-8"); 0062 scriptObject.setAttribute("src", scriptUrl); 0063 0064 if (scriptUrl.indexOf('loadNextJavaScriptFile')<0) { 0065 scriptObject.setAttribute("onload", "loadNextJavaScriptFile();"); 0066 } 0067 0068 kgeomapDebugHook("-- Loading: "+scriptUrl); 0069 lastLoadedScript = scriptUrl; 0070 var theHeader = document.getElementsByTagName("head").item(0); 0071 theHeader.appendChild(scriptObject); 0072 } 0073 function handleApiReady() { 0074 alert('handleapiready'); 0075 } 0076 function loadBackendCode(backendName) { 0077 0078 kgeomapDebugHook('-- Loading backend ' + backendName); 0079 0080 if (backendName=='osm') { 0081 scriptUrls.push('http://www.openlayers.org/api/OpenLayers.js'); 0082 scriptUrls.push('http://www.openstreetmap.org/openlayers/OpenStreetMap.js'); 0083 scriptUrls.push('backend-osm-js.js'); 0084 } else if (backendName=='googlemaps') { 0085 scriptUrls.push('http://maps.google.com/maps/api/js?sensor=false&callback=loadNextJavaScriptFile'); 0086 scriptUrls.push('backend-googlemaps-js.js'); 0087 } 0088 0089 loadNextJavaScriptFile(); 0090 } 0091 function initializeDebug() { 0092 debugTextField = document.getElementById("debugoutput"); 0093 codeTextField = document.getElementById("codetorun"); 0094 0095 document.getElementById("backendselectorform").style.display='none'; 0096 0097 clearDebugTextField(); 0098 0099 // determine which backend to load: 0100 var backendSelector = document.getElementById("backendselector"); 0101 var backendName = backendSelector.options[backendSelector.selectedIndex].value; 0102 0103 loadBackendCode(backendName); 0104 } 0105 </script> 0106 </head> 0107 <body> 0108 0109 <form id="backendselectorform"> 0110 Backend: <select id="backendselector"><option value="osm">OpenStreetMap</option><option value="googlemaps">Google Maps</option></select> <input type="button" onclick="initializeDebug();" value="Load!"/><br/> 0111 <br/> 0112 </form> 0113 0114 <div id="map_canvas" style="width:700px; height:400px; border: 1px solid black;"></div> 0115 0116 <br/> 0117 0118 <form> 0119 Run code: <input type="button" value="Run!" onclick="runMyScript();"/><br/> 0120 <textarea rows="5" cols="80" id="codetorun"></textarea> 0121 </form> 0122 0123 <br/> 0124 0125 <form> 0126 Debug output: <input type="button" value="Clear" onclick="clearDebugTextField();"/><br/> 0127 <textarea rows="15" cols="100" id="debugoutput"></textarea> 0128 </form> 0129 0130 </body> 0131 </html>