summaryrefslogtreecommitdiff
path: root/map.js
diff options
context:
space:
mode:
authorChristian Pointner <equinox@ffgraz.net>2013-12-30 02:08:15 +0000
committerChristian Pointner <equinox@ffgraz.net>2013-12-30 02:08:15 +0000
commit868d5d661987483ac10214216a2ceda5d0c1cd7a (patch)
tree98b43904dd6f76279c85b7fd633317f814f3f256 /map.js
parent3407c6aea9c93d1abf62fe2bec61cd4f2807f619 (diff)
reenables login
readded reaload control (basic version)
Diffstat (limited to 'map.js')
-rw-r--r--map.js104
1 files changed, 46 insertions, 58 deletions
diff --git a/map.js b/map.js
index 7eb01ce..f2aa9aa 100644
--- a/map.js
+++ b/map.js
@@ -35,8 +35,12 @@ function initialize(lat, lng, res) {
map = new google.maps.Map(document.getElementById("map"), mapOptions);
//##// map.addControl(new RulerControl());
-//##// reloadcon = new reloadcontrol();
-//##// map.addcontrol(reloadcon);
+
+ var reloadconDiv = document.createElement('div');
+ var reloadcon = new ReloadControl(reloadconDiv, map);
+
+ reloadconDiv.index = 1;
+ map.controls[google.maps.ControlPosition.TOP_RIGHT].push(reloadconDiv);
google.maps.event.addListener(map, "click", onMapClick);
@@ -509,16 +513,11 @@ function setNewMarker(point) {
}
function fflogin(username, password) {
- var postbody = "username=" + encodeURIComponent(username) + "&password=" + encodeURIComponent(password) + "&login=Einloggen#";
-//##// GDownloadUrl("login.php", onFFLogin, postbody);
+ $.post("login.php", { username: username, password: password, login: "Einloggen#" } )
+ .done(function(data) { onFFLogin(data); });
}
-function onFFLogin(data, responseCode) {
- if (responseCode < 200 || responseCode > 299) {
- return alert("Fehler: Konnte die Daten nicht laden!\n(Server Antwort-Code: " + responseCode + ")");
- }
- xmlData = GXml.parse(data);
-
+function onFFLogin(xmlData) {
var error = xmlData.getElementsByTagName("error");
if(error.length > 0) {
alert(error[0].getAttribute("string"));
@@ -528,7 +527,6 @@ function onFFLogin(data, responseCode) {
if(status[0].getAttribute("code") == "logged_in") {
var username = xmlData.getElementsByTagName("username")[0].getAttribute("name");
showFFLogout(username);
-
//##// reloadcon.started();
$.get( "data.php",onData);
}
@@ -550,25 +548,19 @@ function showFFLogin() {
}
function fflogout() {
- var postbody = "logout=Ausloggen#";
-//##// GDownloadUrl("login.php", onFFLogout, postbody);
+ $.post("login.php", { logout: "Ausloggen#" } )
+ .done(function(data) { onFFLogout(data); });
}
-function onFFLogout(data, responseCode) {
- if (responseCode < 200 || responseCode > 299) {
- return alert("Fehler: Konnte die Daten nicht laden!\n(Server Antwort-Code: " + responseCode + ")");
- }
- xmlData = GXml.parse(data);
-
+function onFFLogout(xmlData) {
var error = xmlData.getElementsByTagName("error");
if(error.length > 0) {
alert(error[0].getAttribute("string"));
}
else {
showFFLogin();
-
//##// reloadcon.started();
- $.get( "data.php",onData);
+ $.get("data.php", onData);
}
}
@@ -596,43 +588,39 @@ function showAddress(address) {
}
}
-//##//function ReloadControl() {
-//##//}
-//##//
-//##//ReloadControl.prototype = new GControl();
-//##//
-//##//ReloadControl.prototype.initialize = function(map) {
-//##// var container = document.createElement("div");
-//##// var btnDiv = document.createElement("div");
-//##// btnDiv.className = "btn";
-//##// btnDiv.id = "reloadbtn";
-//##// container.appendChild(btnDiv);
-//##// btnText = document.createTextNode("Daten neu laden");
-//##// btnDiv.appendChild(btnText);
-//##// google.maps.event.addDomListener(btnDiv, "click", function() {
-//##// reloadcon.started();
-//##// GDownloadUrl("data.php", onData);
-//##// });
-//##//
-//##// map.getContainer().appendChild(container);
-//##// return container;
-//##//}
-//##//
-//##//ReloadControl.prototype.started = function() {
-//##// btnText.data = "wird geladen...";
-//##//}
-//##//
-//##//ReloadControl.prototype.loaded = function() {
-//##// btnText.data = "wird verarbeitet...";
-//##//}
-//##//
-//##//ReloadControl.prototype.finished = function() {
-//##// btnText.data = "Daten neu laden";
-//##//}
-//##//
-//##//ReloadControl.prototype.getDefaultPosition = function() {
-//##// return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(7, 7));
-//##//}
+function ReloadControl(controlDiv, map) {
+ controlDiv.style.padding = '5px';
+
+ var controlUI = document.createElement('div');
+ controlUI.className = 'btn';
+ controlUI.title = 'Click to reload data';
+ controlDiv.appendChild(controlUI);
+
+ var controlText = document.createElement('div');
+ controlText.innerHTML = '<strong>Daten neu laden</strong>';
+ controlUI.appendChild(controlText);
+
+ google.maps.event.addDomListener(controlUI, 'click', function() {
+// reloadcon.started();
+ $.get("data.php", onData);
+ });
+}
+
+// ReloadControl.prototype.started = function() {
+// btnText.data = "wird geladen...";
+// }
+
+// ReloadControl.prototype.loaded = function() {
+// btnText.data = "wird verarbeitet...";
+// }
+
+// ReloadControl.prototype.finished = function() {
+// btnText.data = "Daten neu laden";
+// }
+
+// ReloadControl.prototype.getDefaultPosition = function() {
+// return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(7, 7));
+// }
//##//function RulerControl() {