summaryrefslogtreecommitdiffstats
path: root/js/login.js
diff options
context:
space:
mode:
authorsijanec <sijanecantonluka@gmail.com>2020-05-17 00:13:40 +0200
committersijanec <sijanecantonluka@gmail.com>2020-05-17 00:13:40 +0200
commitfc66b376cb3a2c73843cc882d500cfd743c0790e (patch)
treec94ab426742180e88100629102fa7c21eb820a58 /js/login.js
parentHandlers moved from HTML to JS (diff)
downloadbeziapp-fc66b376cb3a2c73843cc882d500cfd743c0790e.tar
beziapp-fc66b376cb3a2c73843cc882d500cfd743c0790e.tar.gz
beziapp-fc66b376cb3a2c73843cc882d500cfd743c0790e.tar.bz2
beziapp-fc66b376cb3a2c73843cc882d500cfd743c0790e.tar.lz
beziapp-fc66b376cb3a2c73843cc882d500cfd743c0790e.tar.xz
beziapp-fc66b376cb3a2c73843cc882d500cfd743c0790e.tar.zst
beziapp-fc66b376cb3a2c73843cc882d500cfd743c0790e.zip
Diffstat (limited to 'js/login.js')
-rw-r--r--js/login.js45
1 files changed, 0 insertions, 45 deletions
diff --git a/js/login.js b/js/login.js
deleted file mode 100644
index 4633306..0000000
--- a/js/login.js
+++ /dev/null
@@ -1,45 +0,0 @@
-// const API_ENDPOINT = "https://gimb.tk/test.php"; // deprecated
-document.addEventListener("DOMContentLoaded", () => {
- setupEventListeners();
-})
-
-function setupEventListeners() {
- // Setup login button listener
- $("#login-button").click(() => {
- login();
- });
-
- window.addEventListener("keyup", (event) => {
- // Number 13 is the "Enter" key on the keyboard
- if (event.keyCode === 13) {
- // Cancel the default action, if needed
- event.preventDefault();
- login();
- }
- });
-}
-
-// Handle login button click
-function login() {
- let username = $("#username").val();
- let password = $("#password").val();
- var gsecInstance = new gsec();
- gsecInstance.login(username, password).then( (value) => {
- if (typeof value == "string") {
- let promises_to_run = [
- localforage.setItem("logged_in", true),
- localforage.setItem("username", username),
- localforage.setItem("password", password)
- ];
- Promise.all(promises_to_run).then(function () {
- window.location.replace("/pages/timetable.html");
- });
- } else {
- UIAlert("loginFailed");
- $("#password").val("");
- }
- }).catch((err) => {
- gsecErrorHandlerUI(err);
- $("#password").val("");
- });
-}