summaryrefslogtreecommitdiff
path: root/map.js
diff options
context:
space:
mode:
authorChristian Pointner <equinox@ffgraz.net>2013-12-30 02:38:49 +0000
committerChristian Pointner <equinox@ffgraz.net>2013-12-30 02:38:49 +0000
commitdbc4875e553af4d617bba3d2450562c0671aea95 (patch)
tree13956ac112c16a0da3f40e6e16bf0206b9b51bfa /map.js
parent0cf4d26fa38c09d4ad7fe4259e89eeb9c5f08c52 (diff)
improved reload control
Diffstat (limited to 'map.js')
-rw-r--r--map.js34
1 files changed, 14 insertions, 20 deletions
diff --git a/map.js b/map.js
index 56212d6..8f7a088 100644
--- a/map.js
+++ b/map.js
@@ -37,9 +37,7 @@ function initialize(lat, lng, res) {
//##// map.addControl(new RulerControl());
var reloadconDiv = document.createElement('div');
- var reloadcon = new ReloadControl(reloadconDiv, map);
-
- reloadconDiv.index = 1;
+ reloadcon = new ReloadControl(reloadconDiv, map);
map.controls[google.maps.ControlPosition.TOP_RIGHT].push(reloadconDiv);
google.maps.event.addListener(map, "click", onMapClick);
@@ -58,8 +56,7 @@ function initialize(lat, lng, res) {
countboxText = document.createTextNode("Aktiv: 0");
countbox.appendChild(countboxText);
- reloadcon.started();
- $.get( "data.php",onData);
+ reloadcon.reload();
}
function onMapClick(mouse_event)
@@ -68,11 +65,10 @@ function onMapClick(mouse_event)
setNewMarker(mouse_event.latLng);
}
-//##//function onData(data, responseCode) {
-//##// if (responseCode < 200 || responseCode > 299) {
-//##// reloadcon.finished();
-//##// return alert("Fehler: Konnte die Daten nicht laden!\n(Server Antwort-Code: " + responseCode + ")");
-//##// }
+function onDataErr() {
+ reloadcon.finished();
+}
+
function onData(xmlData) {
reloadcon.loaded();
@@ -528,8 +524,7 @@ function onFFLogin(xmlData) {
if(status[0].getAttribute("code") == "logged_in") {
var username = xmlData.getElementsByTagName("username")[0].getAttribute("name");
showFFLogout(username);
- reloadcon.started();
- $.get( "data.php",onData);
+ reloadcon.reload();
}
}
}
@@ -560,8 +555,7 @@ function onFFLogout(xmlData) {
}
else {
showFFLogin();
- reloadcon.started();
- $.get("data.php", onData);
+ reloadcon.reload();
}
}
@@ -601,15 +595,15 @@ function ReloadControl(controlDiv, map) {
controlText.innerHTML = 'Daten neu laden';
controlUI.appendChild(controlText);
- google.maps.event.addDomListener(controlUI, 'click', function() {
- controlText.innerHTML = 'wird geladen...';
- $.get("data.php", onData);
- });
-
var cntrl = new Object();
- cntrl.started = function() { controlText.innerHTML = 'wird geladen...'; }
+ cntrl.reload = function() {
+ controlText.innerHTML = 'wird geladen...';
+ $.get("data.php", onData).fail(onDataErr);
+ }
cntrl.loaded = function() { controlText.innerHTML = 'wird verarbeitet...'; }
cntrl.finished = function() { controlText.innerHTML = 'Daten neu laden'; }
+
+ google.maps.event.addDomListener(controlUI, 'click', cntrl.reload);
return cntrl;
}