From 7a294b9add248992f1d35c6d451ed16c215cdbb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Luka=20=C5=A0ijanec?= Date: Sat, 8 Feb 2020 22:46:08 +0100 Subject: added http://beziapp/?m=Name Surname to redirect to the messaging page with prefilled recipient --- js/initialize.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'js/initialize.js') diff --git a/js/initialize.js b/js/initialize.js index 39ed505..2023921 100644 --- a/js/initialize.js +++ b/js/initialize.js @@ -1,3 +1,15 @@ +function getUrlParameter(sParam) { + var sPageURL = window.location.search.substring(1), + sURLVariables = sPageURL.split('&'), + sParameterName, + i; + for (i = 0; i < sURLVariables.length; i++) { + sParameterName = sURLVariables[i].split('='); + if (sParameterName[0] === sParam) { + return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]); + } + } +}; function setupStorage() { promises_to_run = [ localforage.setItem("logged_in", false), @@ -28,7 +40,11 @@ localforage.getItem("logged_in") } else if (value === false) { window.location.replace("/login.html"); } else { - window.location.replace("/pages/timetable.html"); + if(getUrlParameter("m")) { + window.location.replace("pages/messaging.html?"+getUrlParameter("m")); + } else { + window.location.replace("/pages/timetable.html"); + } } } ).catch( -- cgit v1.2.3 From fefeee7ccf1b6fb6a133c8b9c5eb07b1760c2d94 Mon Sep 17 00:00:00 2001 From: rstular Date: Mon, 17 Feb 2020 15:15:55 +0100 Subject: Reformatting --- js/initialize.js | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) (limited to 'js/initialize.js') diff --git a/js/initialize.js b/js/initialize.js index 2023921..ca29e2f 100644 --- a/js/initialize.js +++ b/js/initialize.js @@ -1,15 +1,13 @@ function getUrlParameter(sParam) { - var sPageURL = window.location.search.substring(1), - sURLVariables = sPageURL.split('&'), - sParameterName, - i; - for (i = 0; i < sURLVariables.length; i++) { - sParameterName = sURLVariables[i].split('='); - if (sParameterName[0] === sParam) { - return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]); - } + const url_params = new URLSearchParams(window.location.search); + const found_param = url_params.get(sParam); + if (found_param === null) { + return "" + } else { + return found_param } -}; +} + function setupStorage() { promises_to_run = [ localforage.setItem("logged_in", false), @@ -21,7 +19,8 @@ function setupStorage() { localforage.setItem("gradings", []), localforage.setItem("grades", []), localforage.setItem("absences", {}), - localforage.setItem("messages", {}) + localforage.setItem("messages", {}), + localforage.setItem("directory", {}) ]; Promise.all(promises_to_run) @@ -36,15 +35,20 @@ localforage.getItem("logged_in") // This code runs once the value has been loaded // from the offline store. if (value === null) { + // Setup the storage if it doesn't exist setupStorage(); } else if (value === false) { + // If storage exists, but user isn't logged in, redirect to login window.location.replace("/login.html"); } else { - if(getUrlParameter("m")) { - window.location.replace("pages/messaging.html?"+getUrlParameter("m")); - } else { - window.location.replace("/pages/timetable.html"); - } + // User is logged in, execute appropriate action + + if (getUrlParameter("m") !== "") { + window.location.replace("/pages/messaging.html?m=" + getUrlParameter("m")); + } else { + window.location.replace("/pages/timetable.html"); + } + } } ).catch( -- cgit v1.2.3 From 236628b07d5187d34759aac70d19d4fe89c93077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Luka=20=C5=A0ijanec?= Date: Mon, 24 Feb 2020 23:42:30 +0100 Subject: meals almost done --- js/initialize.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'js/initialize.js') diff --git a/js/initialize.js b/js/initialize.js index ca29e2f..2305742 100644 --- a/js/initialize.js +++ b/js/initialize.js @@ -20,7 +20,8 @@ function setupStorage() { localforage.setItem("grades", []), localforage.setItem("absences", {}), localforage.setItem("messages", {}), - localforage.setItem("directory", {}) + localforage.setItem("directory", {}), + localforage.setItem("meals", {}) ]; Promise.all(promises_to_run) -- cgit v1.2.3 From 4f38105bc4017248568e4c8c8b0506f6ac09a3b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Luka=20=C5=A0ijanec?= Date: Tue, 25 Feb 2020 20:22:33 +0100 Subject: 1.0.10-beta, hrana ~dela, netestirano, ker nimam menijev za izbrat --- js/initialize.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/initialize.js') 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"); } -- cgit v1.2.3 From af7a53069a4ffb8f041b785d89fe0fcb9f4ca63d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Luka=20=C5=A0ijanec?= Date: Thu, 5 Mar 2020 23:02:04 +0100 Subject: added i18n, converted HTML files, TODO: js UI responses, TODO: translations So basically, multilanguage support from an JavaScript object. - only slovenian and english - no change language UI yet - only HTML strings are actually translated \- all text is translated, but javascript M.toast and other similar stuff does not pass trough s(), d(), S() and D() functions yet - how to i18n: - add a string to js/lang/bundle.js TO ALL LANGUAGES (translation mgmt sys will have to be created) - HTML: create tags, where 1st ? tells wether to just output the string (s) without dot suffix or (d) to try and append a . (for sentences and paragraphs) if it is not there yet. second ? tells wether to leave lowercase strings (l) or (u) to force the first character of the string be uppercase (capitalize()). - put the key of your string as the innerHTML of the x-?? element. - JS: S("key") and D("key") return capitalized, s() and d() do not change case. --- js/initialize.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'js/initialize.js') diff --git a/js/initialize.js b/js/initialize.js index d62e8d4..b64cbcc 100644 --- a/js/initialize.js +++ b/js/initialize.js @@ -21,7 +21,9 @@ function setupStorage() { localforage.setItem("absences", {}), localforage.setItem("messages", {}), localforage.setItem("directory", {}), - localforage.setItem("meals", {}) + localforage.setItem("meals", {}), + // localforage.setItem("chosenCapitalize", true), // poor unused feature + localforage.setItem("chosenLang", "en") ]; Promise.all(promises_to_run) -- cgit v1.2.3 From 23b17dda901e5df3b9c73fc4d9129243cbf60a15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Luka=20=C5=A0ijanec?= Date: Tue, 10 Mar 2020 19:54:09 +0100 Subject: 1.0.12.28-beta: now auto update != all db clear --- js/initialize.js | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) (limited to 'js/initialize.js') diff --git a/js/initialize.js b/js/initialize.js index b64cbcc..7bd7cd9 100644 --- a/js/initialize.js +++ b/js/initialize.js @@ -8,38 +8,16 @@ function getUrlParameter(sParam) { } } -function setupStorage() { - promises_to_run = [ - localforage.setItem("logged_in", false), - localforage.setItem("username", ""), - localforage.setItem("password", ""), - localforage.setItem("profile", {}), - localforage.setItem("timetable", []), - localforage.setItem("teachers", []), - localforage.setItem("gradings", []), - localforage.setItem("grades", []), - localforage.setItem("absences", {}), - localforage.setItem("messages", {}), - localforage.setItem("directory", {}), - localforage.setItem("meals", {}), - // localforage.setItem("chosenCapitalize", true), // poor unused feature - localforage.setItem("chosenLang", "en") - ]; - - Promise.all(promises_to_run) - .then( - window.location.replace("/login.html") - ); -} localforage.getItem("logged_in") .then( function (value) { // This code runs once the value has been loaded // from the offline store. - if (value === null) { + if (value == null) { // Setup the storage if it doesn't exist - setupStorage(); + setupStorage(true); + window.location.replace("/login.html"); } else if (value === false) { // If storage exists, but user isn't logged in, redirect to login window.location.replace("/login.html"); -- cgit v1.2.3 From c3b6d083be07da2831bff06496137200547fc947 Mon Sep 17 00:00:00 2001 From: rstular Date: Thu, 14 May 2020 02:39:45 +0200 Subject: Styling fixes, documentation --- js/initialize.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'js/initialize.js') diff --git a/js/initialize.js b/js/initialize.js index 7bd7cd9..cb5d210 100644 --- a/js/initialize.js +++ b/js/initialize.js @@ -1,11 +1,7 @@ function getUrlParameter(sParam) { const url_params = new URLSearchParams(window.location.search); const found_param = url_params.get(sParam); - if (found_param === null) { - return "" - } else { - return found_param - } + return found_param === null ? "" : found_param; } @@ -34,7 +30,6 @@ localforage.getItem("logged_in") } ).catch( function (err) { - // This code runs if there were any errors console.log(err); } ); -- cgit v1.2.3 From fc66b376cb3a2c73843cc882d500cfd743c0790e Mon Sep 17 00:00:00 2001 From: sijanec Date: Sun, 17 May 2020 00:13:40 +0200 Subject: dist should work, TODO: minify and bundle --- js/initialize.js | 35 ----------------------------------- 1 file changed, 35 deletions(-) delete mode 100644 js/initialize.js (limited to 'js/initialize.js') diff --git a/js/initialize.js b/js/initialize.js deleted file mode 100644 index cb5d210..0000000 --- a/js/initialize.js +++ /dev/null @@ -1,35 +0,0 @@ -function getUrlParameter(sParam) { - const url_params = new URLSearchParams(window.location.search); - const found_param = url_params.get(sParam); - return found_param === null ? "" : found_param; -} - - -localforage.getItem("logged_in") - .then( - function (value) { - // This code runs once the value has been loaded - // from the offline store. - if (value == null) { - // Setup the storage if it doesn't exist - setupStorage(true); - window.location.replace("/login.html"); - } else if (value === false) { - // If storage exists, but user isn't logged in, redirect to login - window.location.replace("/login.html"); - } else { - // User is logged in, execute appropriate action - - if (getUrlParameter("m") !== "") { - window.location.replace("/pages/messaging.html#" + getUrlParameter("m")); - } else { - window.location.replace("/pages/timetable.html"); - } - - } - } - ).catch( - function (err) { - console.log(err); - } - ); -- cgit v1.2.3