diff options
author | Christian Pointner <equinox@ffgraz.net> | 2009-02-08 04:48:53 +0000 |
---|---|---|
committer | Christian Pointner <equinox@ffgraz.net> | 2009-02-08 04:48:53 +0000 |
commit | f6be9edd401664d95e60ae3c81aeaf36723ba891 (patch) | |
tree | 86f2127f51f0f16053c1b593c722cf0a5eeecba4 /map.js | |
parent | 0c420c393dba896e14972ecb5181904f1a1342a4 (diff) |
added login capability
Diffstat (limited to 'map.js')
-rw-r--r-- | map.js | 73 |
1 files changed, 73 insertions, 0 deletions
@@ -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 = '<form action="#" onsubmit="fflogin(this.username.value, this.password.value); this.reset(); return false">'; + html += '<table><tr>'; + html += '<td>Benutzername:</td>'; + html += '<td><input name="username" size="23" type="text" tabindex="1"/></td>'; + html += '<td rowspan="2" valign="bottom"><input name="login" type="submit" id="login" value="Einloggen" tabindex="3"></td>'; + html += '</tr><tr>'; + html += '<td>Passwort:</td>'; + html += '<td><input name="password" type="password" tabindex="2" /></td>'; + html += '</tr></table></form>'; + + 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 = '<form action="#" onsubmit="fflogout(); return false">'; + html += 'Sie sind eingeloggt als:</br >'; + html += '<b>'+username+'</b> ' + html += '<input name="login" type="submit" id="logout" value="Ausloggen"></form>'; + + document.getElementById("loginbox").innerHTML = html; +} + function showAddress(address) { if (geocoder) { address += ", Graz, Austria"; |