diff options
Diffstat (limited to 'js/index.js')
| -rw-r--r-- | js/index.js | 24 |
1 files changed, 24 insertions, 0 deletions
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 <http://www.gnu.org/licenses/>. */ +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() { |
