summaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/initialize.js2
-rw-r--r--js/meals.js45
-rw-r--r--js/messaging.js14
3 files changed, 19 insertions, 42 deletions
diff --git a/js/initialize.js b/js/initialize.js
index 2305742..d62e8d4 100644
--- a/js/initialize.js
+++ b/js/initialize.js
@@ -45,7 +45,7 @@ localforage.getItem("logged_in")
// User is logged in, execute appropriate action
if (getUrlParameter("m") !== "") {
- window.location.replace("/pages/messaging.html?m=" + getUrlParameter("m"));
+ window.location.replace("/pages/messaging.html#" + getUrlParameter("m"));
} else {
window.location.replace("/pages/timetable.html");
}
diff --git a/js/meals.js b/js/meals.js
index bb3653f..59463c0 100644
--- a/js/meals.js
+++ b/js/meals.js
@@ -109,6 +109,8 @@ function displayMeals() {
let root_element = document.getElementById("meals-collapsible");
for(const [date, mealzz] of Object.entries(meals.data)) {
+ let unabletochoosequestionmark = "";
+ let readonly = mealzz.readonly;
var datum = new Date(date);
// Create root element for a date entry
let subject_entry = document.createElement("li");
@@ -118,8 +120,11 @@ function displayMeals() {
subject_header.classList.add("collapsible-header-root");
// Create header text element
let subject_header_text = document.createElement("span");
+ if(mealzz.readonly) {
+ unabletochoosequestionmark = "*Read only*";
+ }
subject_header_text.innerText = jsDateDayString[datum.getDay()]+", "+datum.getDate()+". "+jsDateMonthString[datum.getMonth()]+" "+datum.getFullYear()+" ("+mealzz.meal+"@"
- +mealzz.location+")";
+ +mealzz.location+") "+unabletochoosequestionmark;
// Create collection for displaying individuals meals
let subject_body = document.createElement("div");
@@ -134,8 +139,10 @@ function displayMeals() {
meal_node.classList.add("collection-item")
meal_node.classList.add("meal-node");
meal_node.dataset["index"] = dindex;
- meal_node.onclick = function () {
- setMenu(date, dmil.value);
+ if(!readonly) {
+ meal_node.onclick = function () {
+ setMenu(date, dmil.value);
+ }
}
let meal_node_div = document.createElement("div");
@@ -195,38 +202,6 @@ function refreshMeals(force) {
loadMeals(force);
}
-function refreshClickHandlers() { // unused
- $("#meals-collapsible").find(".collection-item.meal-node").click(function () {
- let grade_obj = grades[parseInt(this.dataset["index"])];
- document.getElementById("grade-header").innerText = grade_obj["predmet"] + ": " + grade_obj["ocena"];
- document.getElementById("grade-date").innerText = grade_obj["datum"];
- document.getElementById("grade-title").innerText = grade_obj["naslov"];
- document.getElementById("grade-type").innerText = "Type: " + grade_obj["vrsta"];
-
- let term_element = document.getElementById("grade-term");
- if (grade_obj["rok"] !== "") {
- term_element.innerText = "Term: " + grade_obj["rok"];
- term_element.style["display"] = "";
- } else {
- term_element.style["display"] = "none";
- }
-
- document.getElementById("grade-teacher").innerText = "Teacher: " + grade_obj["profesor"];
-
- let temporary_object = document.getElementById("grade-temporary");
- let temporary_object_root = document.getElementById("grade-temporary-root");
- if (grade_obj["zacasna"]) {
- temporary_object.innerText = "(zacasna)";
- temporary_object_root.style["display"] = "";
- } else {
- temporary_object_root.style["display"] = "none";
- }
-
- const modal = document.querySelectorAll('.side-modal')[0];
- M.Sidenav.getInstance(modal).open();
- });
-}
-
function lopolisLogout() {
localforage.setItem("logged_in_lopolis", false);
checkLogin();
diff --git a/js/messaging.js b/js/messaging.js
index f5d2e13..70b7545 100644
--- a/js/messaging.js
+++ b/js/messaging.js
@@ -82,6 +82,13 @@ function populateAutocomplete() {
onAutocomplete: validateName,
minLength: 0
});
+ if(window.location.hash.length > 1) {
+ document.getElementById("full-name").value = decodeURIComponent(window.location.hash.substring(1));
+ } else {
+ document.getElementById("full-name").value = getUrlParameter("m");
+ }
+ M.updateTextFields();
+ validateName();
}
// Function to toggle loading bar
@@ -317,9 +324,8 @@ async function sendMessage(recipient_number, subject, body) {
});
}
-function validateName() {
+async function validateName() {
if (directory !== null) {
-
if ($("#full-name").val() in directory) {
$("#full-name").addClass("valid");
$("#full-name").removeClass("invalid");
@@ -329,7 +335,6 @@ function validateName() {
$("#full-name").removeClass("valid");
document.getElementById("msg-send").disabled = true;
}
-
}
}
@@ -398,10 +403,7 @@ document.addEventListener("DOMContentLoaded", () => {
var receivedmessages = null;
loadMessages(true, 0);
-
- document.getElementById("full-name").value = getUrlParameter("m");
M.updateTextFields();
- validateName();
// Setup side menu
const menus = document.querySelectorAll(".side-menu");