diff options
author | Christian Pointner <equinox@ffgraz.net> | 2008-12-06 22:51:19 +0000 |
---|---|---|
committer | Christian Pointner <equinox@ffgraz.net> | 2008-12-06 22:51:19 +0000 |
commit | c222c0230e5bdbea39b097946228d9e2fd92c434 (patch) | |
tree | c3d035e56c880f82c8a84eb42c4bcb6e85f40925 /map.js | |
parent | 8a847c82e6eaa5e1ce91f66b977b655bf929fafd (diff) |
added feedback to reload button
Diffstat (limited to 'map.js')
-rw-r--r-- | map.js | 27 |
1 files changed, 26 insertions, 1 deletions
@@ -1,11 +1,13 @@ var map = null; var physicalMaxLevel; var geocoder = null; +var countboxText = null; var overlays = new Array(); overlays["newmarker"] = null; overlays["ruler"] = new Array(); overlays["locations"] = new Array(); var locations = new Array(); +var reloadcon = null; function initialize(lat, lng, res) { if (!checkBrowser()) { @@ -27,7 +29,8 @@ function initialize(lat, lng, res) { map.setZoom(res); } map.addControl(new RulerControl()); - map.addControl(new ReloadControl()); + reloadcon = new ReloadControl(); + map.addControl(reloadcon); map.addControl(new GSmallMapControl(), new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(10,20))); map.addControl(new GMapTypeControl(), new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(50,10))); @@ -43,6 +46,12 @@ function initialize(lat, lng, res) { geocoder = new GClientGeocoder(); + var countbox = document.getElementById("countbox"); + countboxText = document.createTextNode("Aktiv: 0"); + countbox.appendChild(countboxText); + + document.getElementById("map").style.cursor = "wait"; + reloadcon.started(); GDownloadUrl("data.php", onData); } @@ -94,6 +103,7 @@ function onMapClick(overlay, point) function onData(data, responseCode) { if (responseCode < 200 || responseCode > 299) { + reloadcon.finished(); return alert("Fehler: Konnte die Daten nicht laden!\n(Server Antwort-Code: " + responseCode + ")"); } xmlData = GXml.parse(data); @@ -104,6 +114,12 @@ function onData(data, responseCode) { overlays["locations"] = []; locations = []; drawLocations(xmlData); + + var element = xmlData.getElementsByTagName("count"); + var count = element[0].getAttribute("number"); + countboxText.data = "Aktiv: " + count; + + reloadcon.finished(); } function drawLocations(xmlData) { @@ -263,6 +279,7 @@ ReloadControl.prototype.initialize = function(map) { btnText = document.createTextNode("Daten neu laden"); btnDiv.appendChild(btnText); GEvent.addDomListener(btnDiv, "click", function() { + reloadcon.started(); GDownloadUrl("data.php", onData); }); @@ -270,6 +287,14 @@ ReloadControl.prototype.initialize = function(map) { return container; } +ReloadControl.prototype.started = function() { + btnText.data = "wird geladen..."; +} + +ReloadControl.prototype.finished = function() { + btnText.data = "Daten neu laden"; +} + ReloadControl.prototype.getDefaultPosition = function() { return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(7, 7)); } |