From f6be9edd401664d95e60ae3c81aeaf36723ba891 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sun, 8 Feb 2009 04:48:53 +0000 Subject: added login capability --- map.js | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) (limited to 'map.js') diff --git a/map.js b/map.js index 6edc21c..3ac9685 100644 --- a/map.js +++ b/map.js @@ -364,6 +364,79 @@ function setNewMarker(point) { marker.openInfoWindowHtml(addNewNodeText(point)); } +function fflogin(username, password) { + var postbody = "username=" + encodeURIComponent(username) + "&password=" + encodeURIComponent(password) + "&login=Einloggen#"; + GDownloadUrl("login.php", onFFLogin, postbody); +} + +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); + + var error = xmlData.getElementsByTagName("error"); + if(error.length > 0) { + alert(error[0].getAttribute("string")); + } + else { + var status = xmlData.getElementsByTagName("status"); + if(status[0].getAttribute("code") == "logged_in") { + var username = xmlData.getElementsByTagName("username")[0].getAttribute("name"); + showFFLogout(username); + + reloadcon.started(); + GDownloadUrl("data.php", onData); + } + } +} + +function showFFLogin() { + var html = '
'; + html += ''; + html += ''; + html += ''; + html += ''; + html += ''; + html += ''; + html += ''; + html += '
Benutzername:
Passwort:
'; + + document.getElementById("loginbox").innerHTML = html; +} + +function fflogout() { + var postbody = "logout=Ausloggen#"; + GDownloadUrl("login.php", onFFLogout, postbody); +} + +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); + + var error = xmlData.getElementsByTagName("error"); + if(error.length > 0) { + alert(error[0].getAttribute("string")); + } + else { + showFFLogin(); + + reloadcon.started(); + GDownloadUrl("data.php", onData); + } +} + +function showFFLogout(username) { + var html = '
'; + html += 'Sie sind eingeloggt als:
'; + html += ''+username+'   ' + html += '
'; + + document.getElementById("loginbox").innerHTML = html; +} + function showAddress(address) { if (geocoder) { address += ", Graz, Austria"; -- cgit v1.2.1