summaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/chats.js64
-rw-r--r--js/meals.js14
2 files changed, 57 insertions, 21 deletions
diff --git a/js/chats.js b/js/chats.js
index 5b4bbfd..daf10ab 100644
--- a/js/chats.js
+++ b/js/chats.js
@@ -367,27 +367,6 @@ function getUrlParameter(sParam) {
return found_param;
}
-document.addEventListener("DOMContentLoaded", () => {
- checkLogin();
- loadDirectory();
- updateSendButton();
-
- // var receivedmessages = null;
-
- M.updateTextFields();
-
- // Setup side menu
- const menus = document.querySelectorAll(".side-menu");
- M.Sidenav.init(menus, { edge: "right", draggable: true });
- let elems = document.querySelectorAll(".modal");
- M.Modal.init(elems, {});
-
- // Setup side modal
- const modals = document.querySelectorAll(".side-modal");
- M.Sidenav.init(modals, { edge: "left", draggable: false });
- prepareAndStartFetchingMessages(); // just opens modal, as there is no recipient selected
-});
-
async function updateSendButton() {
if ($("#msg-body").val().length == 0) {
$("#msg-send").prop("disabled", true);
@@ -480,3 +459,46 @@ async function renderMessages(gsecMsgList, whom, order = 1) { // order: 1=newest
}
}
}
+
+function setupEventListeners() {
+ $("#chat-recipient-select-btn").click(() => {
+ setRecipient();
+ });
+
+ $("#msg-send").click(() => {
+ sendMessage();
+ });
+
+ $("#full-name").on("input", () => {
+ validateName();
+ });
+
+ $("#msg-body").on("input", () => {
+ updateSendButton();
+ });
+}
+
+document.addEventListener("DOMContentLoaded", () => {
+
+ checkLogin();
+ loadDirectory();
+
+ setupEventListeners();
+
+ updateSendButton();
+
+ // var receivedmessages = null;
+
+ M.updateTextFields();
+
+ // Setup side menu
+ const menus = document.querySelectorAll(".side-menu");
+ M.Sidenav.init(menus, { edge: "right", draggable: true });
+ let elems = document.querySelectorAll(".modal");
+ M.Modal.init(elems, {});
+
+ // Setup side modal
+ const modals = document.querySelectorAll(".side-modal");
+ M.Sidenav.init(modals, { edge: "left", draggable: false });
+ prepareAndStartFetchingMessages(); // just opens modal, as there is no recipient selected
+}); \ No newline at end of file
diff --git a/js/meals.js b/js/meals.js
index f0d0266..0a5313a 100644
--- a/js/meals.js
+++ b/js/meals.js
@@ -341,9 +341,23 @@ async function setMenu(date, menu) {
getToken(getMenus, [setMenus, choice]);
}
+
+function setupEventListeners() {
+ $("#meals-login").click(() => {
+ lopolisLogin();
+ });
+
+ $("#meals-logout").click(() => {
+ lopolisLogout();
+ });
+}
+
// Initialization code
document.addEventListener("DOMContentLoaded", async () => {
checkLogin();
+
+ setupEventListeners();
+
let coll_elem = document.querySelectorAll('.collapsible');
M.Collapsible.init(coll_elem, {});