From 4e1936f740d6ed3499df59e4f76efa91f49c5cb3 Mon Sep 17 00:00:00 2001 From: schneefux Date: Thu, 13 Mar 2014 19:03:14 +0100 Subject: füge Login-Request hinzu; erstelle das Layout für den Wechsel zur Planansicht MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/index.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'js') diff --git a/js/index.js b/js/index.js index 1f239e8..ab4d48e 100644 --- a/js/index.js +++ b/js/index.js @@ -16,6 +16,30 @@ * along with this program. If not, see . */ +function login(){ + var req = new XMLHttpRequest(); + + var username = encodeURIComponent(document.getElementById('username').value); + var password = encodeURIComponent(document.getElementById('password').value); + var params = "username=" + username + "&password=" + password; + + req.onreadystatechange = function(){ + if(req.readyState == 4){ + if(req.status == 0){ + console.log("Es fehlt die Berechtigung, um auf den Server zuzugreifen."); + }else if(req.status != 200 || window.location.href.indexOf("http") != -1){ + console.log("Etwas ist schiefgelaufen :("); + }else{ + console.log('Request erfolgreich'); + } + } + } + + req.open("POST", "https://***REMOVED***/moodle/login/index.php", true); + req.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); + req.send(params); +} + var app = { // Application Constructor initialize: function() { -- cgit v1.3.1