summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Luka Šijanec <sijanecantonluka@gmail.com>2020-03-06 14:22:03 +0100
committerAnton Luka Šijanec <sijanecantonluka@gmail.com>2020-03-06 14:22:03 +0100
commit64d26557a090b4f5bccb2d0d15c03e148f04f454 (patch)
tree2986b6252747ce561fb1692cbeee022ab73065b8
parentadded i18n, converted HTML files, TODO: js UI responses, TODO: translations (diff)
downloadbeziapp-64d26557a090b4f5bccb2d0d15c03e148f04f454.tar
beziapp-64d26557a090b4f5bccb2d0d15c03e148f04f454.tar.gz
beziapp-64d26557a090b4f5bccb2d0d15c03e148f04f454.tar.bz2
beziapp-64d26557a090b4f5bccb2d0d15c03e148f04f454.tar.lz
beziapp-64d26557a090b4f5bccb2d0d15c03e148f04f454.tar.xz
beziapp-64d26557a090b4f5bccb2d0d15c03e148f04f454.tar.zst
beziapp-64d26557a090b4f5bccb2d0d15c03e148f04f454.zip
-rw-r--r--js/absences.js6
-rw-r--r--js/app.js9
-rw-r--r--js/grades.js12
-rw-r--r--js/gradings.js6
-rw-r--r--js/lang/bundle.js14
-rw-r--r--js/lang/bundle.js.save283
-rw-r--r--js/lang/bundle.js.save.1403
-rw-r--r--js/login.js6
-rw-r--r--js/meals.js38
-rw-r--r--js/messaging.js39
-rw-r--r--js/messaging.js.save396
-rw-r--r--sw.js2
12 files changed, 758 insertions, 456 deletions
diff --git a/js/absences.js b/js/absences.js
index 3228cee..163b3f0 100644
--- a/js/absences.js
+++ b/js/absences.js
@@ -62,7 +62,7 @@ async function loadAbsences(force_refresh = false) {
success: function (data) {
// If data is null, the credentials were incorrect
if (data === null) {
- M.toast({ html: "No absences in the chosen time period." });
+ UIAlert(D("noAbsences"), "loadAbsences(): $.ajax data === null");
setLoading(false);
} else {
// Save absences & populate UI
@@ -75,7 +75,7 @@ async function loadAbsences(force_refresh = false) {
},
error: function () {
- M.toast({ html: "No internet connection!" });
+ UIAlert(D("noInternetConnection"), "loadAbsences(): $.ajax.error");
setLoading(false);
}
@@ -110,7 +110,7 @@ function displayData() {
let subject_lesson_icon = document.createElement("td");
let subject_lesson_text = document.createElement("td");
- subject_lesson_text.innerText = "Lesson " + lesson["ura"];
+ subject_lesson_text.innerText = S("lesson") + " " + lesson["ura"];
let subject_lesson_icon_i = document.createElement("i");
subject_lesson_icon_i.className = "material-icons";
diff --git a/js/app.js b/js/app.js
index cc206f9..267868a 100644
--- a/js/app.js
+++ b/js/app.js
@@ -15,3 +15,12 @@ if (navigator.serviceWorker) {
if (location.protocol != 'https:') {
location.href = 'https:' + window.location.href.substring(window.location.protocol.length);
}
+function UIAlert(usermsg, devmsg) {
+ if(true) { // če bo kakšen dev switch?
+ M.toast( { html: usermsg } );
+ console.log("[BežiApp UIAlert] "+usermsg+" "+devmsg);
+ } else {
+ M.toast( { html: usermsg+" "+devmsg } );
+ }
+}
+
diff --git a/js/grades.js b/js/grades.js
index 2c247f1..ec5bbe8 100644
--- a/js/grades.js
+++ b/js/grades.js
@@ -1,6 +1,4 @@
const API_ENDPOINT = "https://gimb.tk/test.php";
-// const API_ENDPOINT = "http://localhost:5000/test.php";
-
let checkbox_state = false;
async function checkLogin() {
@@ -62,7 +60,7 @@ async function loadGrades(force_refresh = false) {
success: (data) => {
// If data is null, the request failed
if (data === null) {
- M.toast({ html: "Request failed!" });
+ UIAlert(S("requestFailed"), "loadGrades(): data === null; request failed");
setLoading(false);
} else {
// Save grades & populate view
@@ -75,7 +73,7 @@ async function loadGrades(force_refresh = false) {
},
error: () => {
- M.toast({ html: "No internet connection!" });
+ UIAlert(S("noInternetConnection"), "loadGrades(): $ajax-error");
setLoading(false);
}
@@ -222,18 +220,18 @@ function refreshClickHandlers() {
let term_element = document.getElementById("grade-term");
if (grade_obj["rok"] !== "") {
- term_element.innerText = "Term: " + grade_obj["rok"];
+ term_element.innerText = S("term") + ": " + grade_obj["rok"];
term_element.style["display"] = "";
} else {
term_element.style["display"] = "none";
}
- document.getElementById("grade-teacher").innerText = "Teacher: " + grade_obj["profesor"];
+ document.getElementById("grade-teacher").innerText = S("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.innerText = "(" + S("temporary") + ")";
temporary_object_root.style["display"] = "";
} else {
temporary_object_root.style["display"] = "none";
diff --git a/js/gradings.js b/js/gradings.js
index a6024f6..2398c03 100644
--- a/js/gradings.js
+++ b/js/gradings.js
@@ -1,6 +1,4 @@
const API_ENDPOINT = "https://gimb.tk/test.php";
-// const API_ENDPOINT = "http://localhost:5000/test.php";
-
var calendar_obj = null;
async function checkLogin() {
@@ -112,7 +110,7 @@ async function loadGradings(force_refresh = false) {
// If data is null, the credentials were incorrect
if (data === null) {
- M.toast({ html: "Request failed!" });
+ UIAlert( S("requestFailed"), "loadGradings(): data === null; request failed");
setLoading(false);
} else {
// Save gradings & populate calendar
@@ -126,7 +124,7 @@ async function loadGradings(force_refresh = false) {
},
error: () => {
- M.toast({ html: "No internet connection!" });
+ UIAlert( S("noInternetConnection"), "loadGradings(): $.ajax:error" );
setLoading(false);
}
diff --git a/js/lang/bundle.js b/js/lang/bundle.js
index 98a5345..eb9aa2d 100644
--- a/js/lang/bundle.js
+++ b/js/lang/bundle.js
@@ -125,6 +125,7 @@ var langstrings = {
theToS: "the terms and conditions",
and: "and",
thePrivacyPolicy: "the privacy policy",
+ loginFailed: "login failed",
// index
timetable: "timetable",
gradings: "gradings",
@@ -144,6 +145,8 @@ var langstrings = {
useOnlyPermanentGradesNote1: "if checked, only permanent grades will be used in the average grade calculation",
useOnlyPermanentGradesNote2: "if left unchecked, the calculation will include every available grade",
type: "type",
+ term: "term",
+ teacher: "teacher",
// teachers
name: "name",
schoolSubject: "subject",
@@ -154,6 +157,7 @@ var langstrings = {
cancel: "cancel",
ok: "ok",
noAbsences: "no absences in the chosen time period",
+ lesson: "lesson",
// messaging
sendAMessage: "send a message",
recipient: "recipient",
@@ -202,6 +206,8 @@ var langstrings = {
credentialsMatch: "credentials match",
errorSettingMeals: "error setting meals",
mealSet: "meal set! Reload meals to be sure",
+ selected: "selected",
+ requestForAuthenticationFailed: "request for authentication failed",
// about
version: "version",
authors: "authors",
@@ -273,6 +279,7 @@ var langstrings = {
theToS: "pogoji uporabe (v angleščini)",
and: "in",
thePrivacyPolicy: "politika zasebnosti (v angleščini)",
+ loginFailed: "prijava je spodletela",
// index
timetable: "urnik",
gradings: "ocenjevanja",
@@ -287,11 +294,13 @@ var langstrings = {
requestFailed: "zahteva spodletela",
noInternetConnection: "ni povezave s spletom",
// grades
- temporary: "zacasno",
+ temporary: "začasno",
useOnlyPermanentGrades: "uporabi le stalne ocene",
useOnlyPermanentGradesNote1: "če je označeno, bodo za izračun povprečja uporabljene le stalne ocene",
useOnlyPermanentGradesNote2: "če pa je polje neoznačeno, pa se ob izračunu povprečne ocene upoštevajo vse ocene",
type: "tip",
+ term: "rok",
+ teacher: "profesor",
// teachers
name: "ime",
schoolSubject: "predmet",
@@ -302,6 +311,7 @@ var langstrings = {
cancel: "preklic",
ok: "v redu",
noAbsences: "ni izostankov v izbranem časovnem obdobju",
+ lesson: "ura",
// messaging
sendAMessage: "pošlji sporočilo",
recipient: "prejemnik",
@@ -350,6 +360,8 @@ var langstrings = {
credentialsMatch: "prijavni podatki so pravilni",
errorSettingMeals: "napaka pri nastavljanju menijev",
mealSet: "obrok nastavljen! osvežite obroke in se prepričajte sami",
+ selected: "izbrano",
+ requestForAuthenticationFailed: "zahteva za avtentikacijo je spodletela",
// about
version: "različica",
authors: "avtorji",
diff --git a/js/lang/bundle.js.save b/js/lang/bundle.js.save
new file mode 100644
index 0000000..f5140ba
--- /dev/null
+++ b/js/lang/bundle.js.save
@@ -0,0 +1,283 @@
+// there's an DoS backdoor in BežiApp because of this (-:<
+var chosenLang;
+async function refreshLangDOM() {
+ let promises_to_runn = [
+ localforage.getItem("chosenLang").then( (value) => {
+ chosenLang = value;
+ })
+ // localforage.getItem("chosenCapitalize").then( (value) => { // poor unused code
+ // chosenCapitalize = value;
+ // })
+ ];
+ await Promise.all(promises_to_runn);
+ // this could be done nicer. p. s.: lahko bi se uporablil x-s in x-S za razločitev med capitalize in !capitalize queryselectorall ni case sensitive za imena elementov
+ let stringContainerss = document.querySelectorAll("x-sl:not(.langFinished)");
+ for (i = 0; i < stringContainerss.length; i++) {
+ stringContainerss[i].innerHTML = s(stringContainerss[i].innerHTML);
+ stringContainerss[i].classList.add("langFinished");
+ stringContainerss[i].hidden = false;
+ }
+ let stringContainersd = document.querySelectorAll("x-dl:not(.langFinished)");
+ for (i = 0; i < stringContainersd.length; i++) {
+ stringContainersd[i].innerHTML = d(stringContainersd[i].innerHTML);
+ stringContainersd[i].classList.add("langFinished");
+ stringContainersd[i].hidden = false;
+ }
+ let stringContainersS = document.querySelectorAll("x-su:not(.langFinished)");
+ for (i = 0; i < stringContainersS.length; i++) {
+ stringContainersS[i].innerHTML = S(stringContainersS[i].innerHTML);
+ stringContainersS[i].classList.add("langFinished");
+ stringContainersS[i].hidden = false;
+ }
+ let stringContainersD = document.querySelectorAll("x-du:not(.langFinished)");
+ for (i = 0; i < stringContainersD.length; i++) {
+ stringContainersD[i].innerHTML = D(stringContainersD[i].innerHTML);
+ stringContainersD[i].classList.add("langFinished");
+ stringContainersD[i].hidden = false;
+ }
+}
+async function setLangConfigAndReload() {
+ let promises_to_run = [
+ /* localforage.setItem("chosenCapitalize", true), */ // F for unused code
+ localforage.setItem("chosenLang", "en")
+ ];
+ await Promise.all(promises_to_run);
+ window.location.reload();
+}
+window.addEventListener('DOMContentLoaded', (event) => {
+ refreshLangDOM();
+ localforage.getItem("chosenLang").then( (value) => {
+ if(value == null) {
+ setLangConfigAndReload();
+ }
+ }
+ );
+});
+const capitalize = (s) => {
+ if (typeof s !== 'string') return ''
+ return s.charAt(0).toUpperCase() + s.slice(1)
+}
+var s = function(whatString) {
+ return getLang.s(whatString);
+};
+var d = function(whatString) {
+ return getLang.d(whatString);
+};
+var S = function(whatString) {
+ return getLang.S(whatString);
+};
+var D = function(whatString) {
+ return getLang.D(whatString);
+};
+var getLang = { // language object
+ s: function(whatString) { // get string
+ return langstrings[chosenLang][whatString];
+ },
+ S: function(whatString) { // get capitalized string
+ return capitalize(langstrings[chosenLang][whatString]);
+ },
+ d: function(whatString) { // add a dot and get string
+ if(langstrings[chosenLang][whatString].slice(-1) != ".") {
+ return langstrings[chosenLang][whatString]+".";
+ } else {
+ return langstrings[chosenLang][whatString];
+ }
+ },
+ D: function(whatString) { // add a dot and get capitalized string
+ if(langstrings[chosenLang][whatString].slice(-1) != ".") {
+ return capitalize(langstrings[chosenLang][whatString]+".");
+ } else {
+ return capitalize(langstrings[chosenLang][whatString]);
+ }
+ },
+}
+var langstrings = {
+ en: {
+ miscTranslationLanguage: "English",
+ miscTranslationAuthors: "Rok Štular",
+ // date
+ monday: "monday",
+ tuesday: "tuesday",
+ wednesday: "wednesday",
+ thursday: "thursday",
+ friday: "friday",
+ saturday: "saturday",
+ sunday: "sunday",
+ am: "am",
+ pm: "pm",
+ january: "january",
+ february: "february",
+ march: "march",
+ april: "april",
+ may: "may",
+ june: "june",
+ july: "july",
+ august: "august",
+ september: "september",
+ october: "october",
+ november: "november",
+ december: "december",
+ // login
+ username: "username",
+ password: "password",
+ signIn: "sign in",
+ bySigningInYouAgreeTo: "by signing in, you agree to",
+ theToS: "the terms and conditions",
+ and: "and",
+ thePrivacyPolicy: "the privacy policy",
+ loginFailed: "login failed",
+ // index
+ timetable: "timetable",
+ gradings: "gradings",
+ grades: "grades",
+ teachers: "teachers",
+ absences: "absences",
+ messaging: "messaging",
+ meals: "meals",
+ about: "about",
+ logout: "logout",
+ // gradings
+ requestFailed: "request failed",
+ noInternetConnection: "no internet connection",
+ // grades
+ temporary: "temporary",
+ useOnlyPermanentGrades: "use only permanent grades",
+ useOnlyPermanentGradesNote1: "if checked, only permanent grades will be used in the average grade calculation",
+ useOnlyPermanentGradesNote2: "if left unchecked, the calculation will include every available grade",
+ type: "type",
+ term: "term",
+ teacher: "teacher",
+ // teachers
+ name: "name",
+ schoolSubject: "subject",
+ tpMeetings: "TP meetings",
+ // absences
+ from: "from",
+ to: "to",
+ cancel: "cancel",
+ ok: "ok",
+ noAbsences: "no absences in the chosen time period",
+ lesson: "lesson",
+ // messaging
+ sendAMessage: "send a message",
+ recipient: "recipient",
+ messageSubject: "subject",
+ messageBody: "message body",
+ removeImages: "remove images",
+ note: "note",
+ largeImagesNote: "GimB servers don't like large messages, so only very small images may be attached or your message will not be delivered",
+ attachedImages: "attached images",
+ passwordForE2EE: "password for encrypting the message",
+ messages: "messages",
+ received: "received",
+ sent: "sent",
+ deleted: "deleted",
+ messageStorageUsed: "message storage used in this folder",
+ maxMessagesNote: "you can only have 120 messages per message folder, older messages will not be shown. Remember to delete read and sent messages regulary to avoid any issues.",
+ loadMessageBody: "load message body",
+ thisMessageWasEncrypted: "this message was encrypted by BežiApp",
+ enterPassword: "enter password",
+ decrypt: "decrypt",
+ nameDirecroryNotSet: "name directory not set, sending unavailable",
+ errorFetchingMessages: "error fetching messages",
+ unableToReceiveTheMessage: "unable to receive the message",
+ unableToDeleteTheMessage: "unable to delete the message",
+ messageWasProbablySent: "message was probably sent, check the Sent folder to be sure",
+ errorSendingMessage: "error sending message",
+ imageAddedAsAnAttachment: "image added as an attachment",
+ unableToReadDirectory: "unable to read directory of people",
+ messageCouldNotBeSent: "message could to be sent",
+ // meals
+ loginToLopolis: "login to Lopolis",
+ loginToLopolisNote: "it seems like you're not currently logged in to eRestavracija, so this form has been presented to you. You have a different username and password combination used for applying and opting out of of menus. In order to use this feature, you have to log in with your Lopolis account.",
+ logInToLopolis: "log in to Lopolis",
+ logOutFromLopolis: "log out from Lopolis",
+ readOnly: "read only",
+ usage: "usage",
+ mealsUsageNote: "click on a date to open the collapsible menu with choices and click on a specific meal to select it. Reload the meals when you're done and check the entries.",
+ lunchesNote: "app was not tested with lunches in mind. Meals probably won't work with lunches and having a lunch subscription may even break its functionality.",
+ mealNotShownNote: "if a meal is not present in the meals collapsible field, this does not necessarily mean it does not exist. Meals that haven't been altered by you and are unchangable (read-only) are not shown for clarity.",
+ mealsContributeNote: "you are welcome to contribute to the LopolisAPI project and add features, such as checkouts.",
+ authenticationError: "authentication error",
+ lopolisAPIConnectionError: "LopolisAPI server connection error",
+ errorGettingMenus: "error getting menus",
+ errorUnexpectedResponse: "error: unexpected response",
+ requestForAuthenticationFailed: "request for authentication failed",
+ credentialsMatch: "credentials match",
+ errorSettingMeals: "error setting meals",
+ mealSet: "meal set! Reload meals to be sure",
+ selected: "selected",
+ requestForAuthenticationFailed: "request for authentication failed",
+ // about
+ version: "version",
+ authors: "authors",
+ translatorsForThisLanguage: "translators for this language",
+ whatIsNew: "what's new",
+ whatsNew: "what's new",
+ reportABug: "report a bug",
+ sendASuggestion: "send a suggestion",
+ instagram: "instagram",
+ // changelog
+ changelog: "changelog",
+ // terms and conditions
+ termsOfUse: "terms of use",
+ termsOfUseDescription: "as a condition of use, you promise not to use the BežiApp (App or application) and its related infrastructure (API, hosting service) for any purpose that is unlawful or prohibited by these Terms, or any other purpose not reasonably intended by the authors of the App. By way of example, and not as a limitation, you agree not to use the App",
+ termsOfUseHarass: "to abuse, harass, threaten, impersonate or intimidate any person",
+ termsOfUsePost: "to post or transmit, or cause to be posted or transmitted, any Content that is libelous, defamatory, obscene, pornographic, abusive, offensive, profane or that infringes any copyright or other right of any person",
+ termsOfUseCommunicate: "to communicate with the App developers or other users in abusive or offensive manner",
+ termsOfUsePurpose: "for any purpose that is not permitted under the laws of the jurisdiction where you use the App",
+ termsOfUseExploit: "to post or transmit, or cause to be posted or transmitted, any Communication designed or intended to obtain password, account or private information of any App user",
+ termsOfUseSpam: "to create or transmit unwanted “spam” to any person or any URL",
+ termsOfUseModify: "you may also not reverse engineer, modify or redistribute the app without written consent from the developers",
+ terminationOfServices: "termination of services",
+ terminationOfServicesDescriptions: "the developers of the App may terminate your access to the App without any prior warning or notice for any of the following reasons",
+ terminationOfServicesBreaching: "breaching the Terms of Service",
+ terminationOfServicesRequest: "receiving a formal request from authorities of Gimnazija Bežigrad administration requesting termination of your access to the App",
+ limitationOfLiability: "limitation of Liability",
+ limitationOfLiabilityContent: "the developers of the App provide no warranty; You expressly acknowledge and agree that the use of the licensed application is at your sole risk. To the maximum extent permited by applicable law, the licensed application and any services performed of provided by the licensed application are provided “as is” and “as available”, with all faults and without warranty of any kind, and licensor hereby disclaims all warranties and conditions with respect to the licensed application and any services, either express, implied or statutory, including, but not limited to, the implied warranties and/or conditions of merchantability, of satisfactory quality, of fitness for a particular purpose, of accuracy, of quiet enjoyment, and of noninfringement of third-party rights. No oral or written information or advice given by licensor or its authorized representative shall create a warranty. Should the licensed application or services prove defective, you assume the entire cost of all necessary servicing, repair or correction. Some jurisdictions do not allow the exclusion of the implied warranties or limitations on applicable statutory rights of a customer, so the above exclusion may not apply to you.",
+ tosAreEffectiveAsOf: "the Terms of Service are effective as of",
+ // privacy policy
+ privacyImportant: "your privacy is important to us. It is the developers' policy to respect your privacy regarding any information we may collect from you through our app, BežiApp.",
+ privacyOnlyAskedWhen: "we only ask for personal information when we truly need it to provide a service to you. We collect it by fair and lawful means, with your knowledge and consent. We also let you know why we’re collecting it and how it will be used.",
+ privacyDataCollection: "we only retain collected information for as long as necessary to provide you with your requested service. What data we store, we’ll protect within commercially acceptable means to prevent loss and theft, as well as unauthorized access, disclosure, copying, use or modification.",
+ privacySharingData: "we don’t share any personally identifying information publicly or with third-parties, except when required to by law",
+ privacyExternalSites: "our app may link to external sites that are not operated by us. Please be aware that we have no control over the content and practices of these sites, and cannot accept responsibility or liability for their respective privacy policies.",
+ privacyRefuse: "you are free to refuse our request for your personal information, with the understanding that we may be unable to provide you with some of your desired services.",
+ privacyAcceptWithUse: "your continued use of our website will be regarded as acceptance of our practices around privacy and personal information. If you have any questions about how we handle user data and personal information, feel free to contact us.",
+ privacyEffectiveAsOf: "this policy is effective as of"
+ },
+ sl: {
+ miscTranslationLanguage: "slovenščina",
+ miscTranslationAuthors: "Anton Luka Šijanec",
+ // date
+ monday: "ponedeljek",
+ tuesday: "torek",
+ wednesday: "sreda",
+ thursday: "četrtek",
+ friday: "petek",
+ saturday: "sobota",
+ sunday: "nedelja",
+ am: "dop.",
+ pm: "pop.",
+ january: "januar",
+ february: "februar",
+ march: "marec",
+ april: "april",
+ may: "maj",
+ june: "junij",
+ july: "julij",
+ august: "avgust",
+ september: "september",
+ october: "oktober",
+ november: "november",
+ december: "december",
+ // login
+ username: "uporabniško ime",
+ password: "geslo",
+ signIn: "prijava",
+ bySigningInYouAgreeTo: "s prijavo se strinjate s",
+ theToS: "pogoji uporabe (v angleščini)",
+ and: "in",
+ thePrivacyPolicy: "politika zasebnosti (v angleščini)",
+ loginFailed: "prijava je spodletela",
+ // index
diff --git a/js/lang/bundle.js.save.1 b/js/lang/bundle.js.save.1
new file mode 100644
index 0000000..eb9aa2d
--- /dev/null
+++ b/js/lang/bundle.js.save.1
@@ -0,0 +1,403 @@
+// there's an DoS backdoor in BežiApp because of this (-:<
+var chosenLang;
+async function refreshLangDOM() {
+ let promises_to_runn = [
+ localforage.getItem("chosenLang").then( (value) => {
+ chosenLang = value;
+ })
+ // localforage.getItem("chosenCapitalize").then( (value) => { // poor unused code
+ // chosenCapitalize = value;
+ // })
+ ];
+ await Promise.all(promises_to_runn);
+ // this could be done nicer. p. s.: lahko bi se uporablil x-s in x-S za razločitev med capitalize in !capitalize queryselectorall ni case sensitive za imena elementov
+ let stringContainerss = document.querySelectorAll("x-sl:not(.langFinished)");
+ for (i = 0; i < stringContainerss.length; i++) {
+ stringContainerss[i].innerHTML = s(stringContainerss[i].innerHTML);
+ stringContainerss[i].classList.add("langFinished");
+ stringContainerss[i].hidden = false;
+ }
+ let stringContainersd = document.querySelectorAll("x-dl:not(.langFinished)");
+ for (i = 0; i < stringContainersd.length; i++) {
+ stringContainersd[i].innerHTML = d(stringContainersd[i].innerHTML);
+ stringContainersd[i].classList.add("langFinished");
+ stringContainersd[i].hidden = false;
+ }
+ let stringContainersS = document.querySelectorAll("x-su:not(.langFinished)");
+ for (i = 0; i < stringContainersS.length; i++) {
+ stringContainersS[i].innerHTML = S(stringContainersS[i].innerHTML);
+ stringContainersS[i].classList.add("langFinished");
+ stringContainersS[i].hidden = false;
+ }
+ let stringContainersD = document.querySelectorAll("x-du:not(.langFinished)");
+ for (i = 0; i < stringContainersD.length; i++) {
+ stringContainersD[i].innerHTML = D(stringContainersD[i].innerHTML);
+ stringContainersD[i].classList.add("langFinished");
+ stringContainersD[i].hidden = false;
+ }
+}
+async function setLangConfigAndReload() {
+ let promises_to_run = [
+ /* localforage.setItem("chosenCapitalize", true), */ // F for unused code
+ localforage.setItem("chosenLang", "en")
+ ];
+ await Promise.all(promises_to_run);
+ window.location.reload();
+}
+window.addEventListener('DOMContentLoaded', (event) => {
+ refreshLangDOM();
+ localforage.getItem("chosenLang").then( (value) => {
+ if(value == null) {
+ setLangConfigAndReload();
+ }
+ }
+ );
+});
+const capitalize = (s) => {
+ if (typeof s !== 'string') return ''
+ return s.charAt(0).toUpperCase() + s.slice(1)
+}
+var s = function(whatString) {
+ return getLang.s(whatString);
+};
+var d = function(whatString) {
+ return getLang.d(whatString);
+};
+var S = function(whatString) {
+ return getLang.S(whatString);
+};
+var D = function(whatString) {
+ return getLang.D(whatString);
+};
+var getLang = { // language object
+ s: function(whatString) { // get string
+ return langstrings[chosenLang][whatString];
+ },
+ S: function(whatString) { // get capitalized string
+ return capitalize(langstrings[chosenLang][whatString]);
+ },
+ d: function(whatString) { // add a dot and get string
+ if(langstrings[chosenLang][whatString].slice(-1) != ".") {
+ return langstrings[chosenLang][whatString]+".";
+ } else {
+ return langstrings[chosenLang][whatString];
+ }
+ },
+ D: function(whatString) { // add a dot and get capitalized string
+ if(langstrings[chosenLang][whatString].slice(-1) != ".") {
+ return capitalize(langstrings[chosenLang][whatString]+".");
+ } else {
+ return capitalize(langstrings[chosenLang][whatString]);
+ }
+ },
+}
+var langstrings = {
+ en: {
+ miscTranslationLanguage: "English",
+ miscTranslationAuthors: "Rok Štular",
+ // date
+ monday: "monday",
+ tuesday: "tuesday",
+ wednesday: "wednesday",
+ thursday: "thursday",
+ friday: "friday",
+ saturday: "saturday",
+ sunday: "sunday",
+ am: "am",
+ pm: "pm",
+ january: "january",
+ february: "february",
+ march: "march",
+ april: "april",
+ may: "may",
+ june: "june",
+ july: "july",
+ august: "august",
+ september: "september",
+ october: "october",
+ november: "november",
+ december: "december",
+ // login
+ username: "username",
+ password: "password",
+ signIn: "sign in",
+ bySigningInYouAgreeTo: "by signing in, you agree to",
+ theToS: "the terms and conditions",
+ and: "and",
+ thePrivacyPolicy: "the privacy policy",
+ loginFailed: "login failed",
+ // index
+ timetable: "timetable",
+ gradings: "gradings",
+ grades: "grades",
+ teachers: "teachers",
+ absences: "absences",
+ messaging: "messaging",
+ meals: "meals",
+ about: "about",
+ logout: "logout",
+ // gradings
+ requestFailed: "request failed",
+ noInternetConnection: "no internet connection",
+ // grades
+ temporary: "temporary",
+ useOnlyPermanentGrades: "use only permanent grades",
+ useOnlyPermanentGradesNote1: "if checked, only permanent grades will be used in the average grade calculation",
+ useOnlyPermanentGradesNote2: "if left unchecked, the calculation will include every available grade",
+ type: "type",
+ term: "term",
+ teacher: "teacher",
+ // teachers
+ name: "name",
+ schoolSubject: "subject",
+ tpMeetings: "TP meetings",
+ // absences
+ from: "from",
+ to: "to",
+ cancel: "cancel",
+ ok: "ok",
+ noAbsences: "no absences in the chosen time period",
+ lesson: "lesson",
+ // messaging
+ sendAMessage: "send a message",
+ recipient: "recipient",
+ messageSubject: "subject",
+ messageBody: "message body",
+ removeImages: "remove images",
+ note: "note",
+ largeImagesNote: "GimB servers don't like large messages, so only very small images may be attached or your message will not be delivered",
+ attachedImages: "attached images",
+ passwordForE2EE: "password for encrypting the message",
+ messages: "messages",
+ received: "received",
+ sent: "sent",
+ deleted: "deleted",
+ messageStorageUsed: "message storage used in this folder",
+ maxMessagesNote: "you can only have 120 messages per message folder, older messages will not be shown. Remember to delete read and sent messages regulary to avoid any issues.",
+ loadMessageBody: "load message body",
+ thisMessageWasEncrypted: "this message was encrypted by BežiApp",
+ enterPassword: "enter password",
+ decrypt: "decrypt",
+ nameDirecroryNotSet: "name directory not set, sending unavailable",
+ errorFetchingMessages: "error fetching messages",
+ unableToReceiveTheMessage: "unable to receive the message",
+ unableToDeleteTheMessage: "unable to delete the message",
+ messageWasProbablySent: "message was probably sent, check the Sent folder to be sure",
+ errorSendingMessage: "error sending message",
+ imageAddedAsAnAttachment: "image added as an attachment",
+ unableToReadDirectory: "unable to read directory of people",
+ messageCouldNotBeSent: "message could to be sent",
+ // meals
+ loginToLopolis: "login to Lopolis",
+ loginToLopolisNote: "it seems like you're not currently logged in to eRestavracija, so this form has been presented to you. You have a different username and password combination used for applying and opting out of of menus. In order to use this feature, you have to log in with your Lopolis account.",
+ logInToLopolis: "log in to Lopolis",
+ logOutFromLopolis: "log out from Lopolis",
+ readOnly: "read only",
+ usage: "usage",
+ mealsUsageNote: "click on a date to open the collapsible menu with choices and click on a specific meal to select it. Reload the meals when you're done and check the entries.",
+ lunchesNote: "app was not tested with lunches in mind. Meals probably won't work with lunches and having a lunch subscription may even break its functionality.",
+ mealNotShownNote: "if a meal is not present in the meals collapsible field, this does not necessarily mean it does not exist. Meals that haven't been altered by you and are unchangable (read-only) are not shown for clarity.",
+ mealsContributeNote: "you are welcome to contribute to the LopolisAPI project and add features, such as checkouts.",
+ authenticationError: "authentication error",
+ lopolisAPIConnectionError: "LopolisAPI server connection error",
+ errorGettingMenus: "error getting menus",
+ errorUnexpectedResponse: "error: unexpected response",
+ requestForAuthenticationFailed: "request for authentication failed",
+ credentialsMatch: "credentials match",
+ errorSettingMeals: "error setting meals",
+ mealSet: "meal set! Reload meals to be sure",
+ selected: "selected",
+ requestForAuthenticationFailed: "request for authentication failed",
+ // about
+ version: "version",
+ authors: "authors",
+ translatorsForThisLanguage: "translators for this language",
+ whatIsNew: "what's new",
+ whatsNew: "what's new",
+ reportABug: "report a bug",
+ sendASuggestion: "send a suggestion",
+ instagram: "instagram",
+ // changelog
+ changelog: "changelog",
+ // terms and conditions
+ termsOfUse: "terms of use",
+ termsOfUseDescription: "as a condition of use, you promise not to use the BežiApp (App or application) and its related infrastructure (API, hosting service) for any purpose that is unlawful or prohibited by these Terms, or any other purpose not reasonably intended by the authors of the App. By way of example, and not as a limitation, you agree not to use the App",
+ termsOfUseHarass: "to abuse, harass, threaten, impersonate or intimidate any person",
+ termsOfUsePost: "to post or transmit, or cause to be posted or transmitted, any Content that is libelous, defamatory, obscene, pornographic, abusive, offensive, profane or that infringes any copyright or other right of any person",
+ termsOfUseCommunicate: "to communicate with the App developers or other users in abusive or offensive manner",
+ termsOfUsePurpose: "for any purpose that is not permitted under the laws of the jurisdiction where you use the App",
+ termsOfUseExploit: "to post or transmit, or cause to be posted or transmitted, any Communication designed or intended to obtain password, account or private information of any App user",
+ termsOfUseSpam: "to create or transmit unwanted “spam” to any person or any URL",
+ termsOfUseModify: "you may also not reverse engineer, modify or redistribute the app without written consent from the developers",
+ terminationOfServices: "termination of services",
+ terminationOfServicesDescriptions: "the developers of the App may terminate your access to the App without any prior warning or notice for any of the following reasons",
+ terminationOfServicesBreaching: "breaching the Terms of Service",
+ terminationOfServicesRequest: "receiving a formal request from authorities of Gimnazija Bežigrad administration requesting termination of your access to the App",
+ limitationOfLiability: "limitation of Liability",
+ limitationOfLiabilityContent: "the developers of the App provide no warranty; You expressly acknowledge and agree that the use of the licensed application is at your sole risk. To the maximum extent permited by applicable law, the licensed application and any services performed of provided by the licensed application are provided “as is” and “as available”, with all faults and without warranty of any kind, and licensor hereby disclaims all warranties and conditions with respect to the licensed application and any services, either express, implied or statutory, including, but not limited to, the implied warranties and/or conditions of merchantability, of satisfactory quality, of fitness for a particular purpose, of accuracy, of quiet enjoyment, and of noninfringement of third-party rights. No oral or written information or advice given by licensor or its authorized representative shall create a warranty. Should the licensed application or services prove defective, you assume the entire cost of all necessary servicing, repair or correction. Some jurisdictions do not allow the exclusion of the implied warranties or limitations on applicable statutory rights of a customer, so the above exclusion may not apply to you.",
+ tosAreEffectiveAsOf: "the Terms of Service are effective as of",
+ // privacy policy
+ privacyImportant: "your privacy is important to us. It is the developers' policy to respect your privacy regarding any information we may collect from you through our app, BežiApp.",
+ privacyOnlyAskedWhen: "we only ask for personal information when we truly need it to provide a service to you. We collect it by fair and lawful means, with your knowledge and consent. We also let you know why we’re collecting it and how it will be used.",
+ privacyDataCollection: "we only retain collected information for as long as necessary to provide you with your requested service. What data we store, we’ll protect within commercially acceptable means to prevent loss and theft, as well as unauthorized access, disclosure, copying, use or modification.",
+ privacySharingData: "we don’t share any personally identifying information publicly or with third-parties, except when required to by law",
+ privacyExternalSites: "our app may link to external sites that are not operated by us. Please be aware that we have no control over the content and practices of these sites, and cannot accept responsibility or liability for their respective privacy policies.",
+ privacyRefuse: "you are free to refuse our request for your personal information, with the understanding that we may be unable to provide you with some of your desired services.",
+ privacyAcceptWithUse: "your continued use of our website will be regarded as acceptance of our practices around privacy and personal information. If you have any questions about how we handle user data and personal information, feel free to contact us.",
+ privacyEffectiveAsOf: "this policy is effective as of"
+ },
+ sl: {
+ miscTranslationLanguage: "slovenščina",
+ miscTranslationAuthors: "Anton Luka Šijanec",
+ // date
+ monday: "ponedeljek",
+ tuesday: "torek",
+ wednesday: "sreda",
+ thursday: "četrtek",
+ friday: "petek",
+ saturday: "sobota",
+ sunday: "nedelja",
+ am: "dop.",
+ pm: "pop.",
+ january: "januar",
+ february: "februar",
+ march: "marec",
+ april: "april",
+ may: "maj",
+ june: "junij",
+ july: "julij",
+ august: "avgust",
+ september: "september",
+ october: "oktober",
+ november: "november",
+ december: "december",
+ // login
+ username: "uporabniško ime",
+ password: "geslo",
+ signIn: "prijava",
+ bySigningInYouAgreeTo: "s prijavo se strinjate s",
+ theToS: "pogoji uporabe (v angleščini)",
+ and: "in",
+ thePrivacyPolicy: "politika zasebnosti (v angleščini)",
+ loginFailed: "prijava je spodletela",
+ // index
+ timetable: "urnik",
+ gradings: "ocenjevanja",
+ grades: "ocene",
+ teachers: "profesorji",
+ absences: "izostanki",
+ messaging: "sporočanje",
+ meals: "obroki",
+ about: "o",
+ logout: "odjava",
+ // gradings
+ requestFailed: "zahteva spodletela",
+ noInternetConnection: "ni povezave s spletom",
+ // grades
+ temporary: "začasno",
+ useOnlyPermanentGrades: "uporabi le stalne ocene",
+ useOnlyPermanentGradesNote1: "če je označeno, bodo za izračun povprečja uporabljene le stalne ocene",
+ useOnlyPermanentGradesNote2: "če pa je polje neoznačeno, pa se ob izračunu povprečne ocene upoštevajo vse ocene",
+ type: "tip",
+ term: "rok",
+ teacher: "profesor",
+ // teachers
+ name: "ime",
+ schoolSubject: "predmet",
+ tpMeetings: "govorilne ure",
+ // absences
+ from: "od",
+ to: "do",
+ cancel: "preklic",
+ ok: "v redu",
+ noAbsences: "ni izostankov v izbranem časovnem obdobju",
+ lesson: "ura",
+ // messaging
+ sendAMessage: "pošlji sporočilo",
+ recipient: "prejemnik",
+ messageSubject: "zadeva",
+ messageBody: "telo",
+ removeImages: "odstrani slike",
+ note: "opomba",
+ largeImagesNote: "GimB strežniki ne marajo velikih sporočil, zato lahko pošiljate le zelo male slike, v nasprotnem primeru sporočilo ne bo dostavljeno",
+ attachedImages: "pripete slike",
+ passwordForE2EE: "geslo za šifriranje sporočila",
+ messages: "sporočila",
+ received: "prejeta",
+ sent: "poslana",
+ deleted: "izbrisana",
+ messageStorageUsed: "zasedenost shrambe sporočil v tej mapi",
+ maxMessagesNote: "v vsaki mapi imate lahko največ sto dvajset sporočil. Starejša sporočila ne bodo prikazana. Redno brišite sporočila, da se izognete morebitnim težavam.",
+ loadMessageBody: "naloži telo sporočila",
+ thisMessageWasEncrypted: "to sporočilo je šifriral BežiApp",
+ enterPassword: "vnesite geslo",
+ decrypt: "odšifriraj",
+ nameDirecroryNotSet: "imenik ni nastavljen, pošiljanje ni mogoče",
+ errorFetchingMessages: "sporočil ni bilo mogoče prenesti",
+ unableToReceiveTheMessage: "sporočila ni bilo mogoče prenesti",
+ unableToDeleteTheMessage: "sporočila ni bilo mogoče izbrisati",
+ messageWasProbablySent: "sporočilo je bilo verjetno poslano, prepričajte se in preverite mapo s poslanimi sporočili",
+ errorSendingMessage: "sporočila ni bilo mogoče poslati",
+ imageAddedAsAnAttachment: "slika dodana kot priloga",
+ unableToReadDirectory: "imenika ni bilo mogoče prebrati",
+ messageCouldNotBeSent: "sporočila ni bilo mogoče poslati",
+ // meals
+ loginToLopolis: "prijava v Lopolis",
+ loginToLopolisNote: "izgleda, da niste prijavljeni v eRestavracijo, zato se vam je prikazal prijavni obrazec. Za uporavljanje s prehrano se uporablja druga kombinacija uporabniškega imena in gesla, zato se prijavite s svojimi Lopolis prijavnimi podatki za nadaljevanje.",
+ logInToLopolis: "prijava v Lopolis",
+ logOutFromLopolis: "odjava iz Lopolisa",
+ readOnly: "samo za branje",
+ usage: "uporaba",
+ mealsUsageNote: "kliknite na datum za prikaz menijev, nato pa si enega izberite s klikom na ime menija. Po nastavitvi menijev ponovno naložite menije in se prepričajte o pravilnih nastavitvah.",
+ lunchesNote: "aplikacija ni testirana za naročanje na koslila, zato verjetno to ne deluje. Če ste naročeni na kosila lahko naročanje na menije sploh ne deluje ali pa deluje narobe.",
+ mealNotShownNote: "če nek dan manjka med meniji, to verjetno pomeni, da ni več spremenljiv in zanj niste ročno spremenili menija",
+ mealsContributeNote: "vabimo vas k urejanju LopolisAPI programa za upravljanje z meniji.",
+ authenticationError: "napaka avtentikacije",
+ lopolisAPIConnectionError: "napaka povezave na LopolisAPI strežnik",
+ errorGettingMenus: "napaka branja menijev",
+ errorUnexpectedResponse: "napaka: nepričakovan odgovor",
+ requestForAuthenticationFailed: "zahteva za avtentikacijo ni uspela",
+ credentialsMatch: "prijavni podatki so pravilni",
+ errorSettingMeals: "napaka pri nastavljanju menijev",
+ mealSet: "obrok nastavljen! osvežite obroke in se prepričajte sami",
+ selected: "izbrano",
+ requestForAuthenticationFailed: "zahteva za avtentikacijo je spodletela",
+ // about
+ version: "različica",
+ authors: "avtorji",
+ translatorsForThisLanguage: "prevajalci izbranega jezika",
+ whatIsNew: "kaj je novega",
+ whatsNew: "kaj je novega",
+ reportABug: "prijavite napako ali hrošča",
+ sendASuggestion: "pošljite pripombo/predlog/pohvalo/pritožbo",
+ instagram: "instagram",
+ // changelog
+ changelog: "dnevnik sprememb",
+ // terms and conditions
+ termsOfUse: "terms of use",
+ termsOfUseDescription: "as a condition of use, you promise not to use the BežiApp (App or application) and its related infrastructure (API, hosting service) for any purpose that is unlawful or prohibited by these Terms, or any other purpose not reasonably intended by the authors of the App. By way of example, and not as a limitation, you agree not to use the App",
+ termsOfUseHarass: "to abuse, harass, threaten, impersonate or intimidate any person",
+ termsOfUsePost: "to post or transmit, or cause to be posted or transmitted, any Content that is libelous, defamatory, obscene, pornographic, abusive, offensive, profane or that infringes any copyright or other right of any person",
+ termsOfUseCommunicate: "to communicate with the App developers or other users in abusive or offensive manner",
+ termsOfUsePurpose: "for any purpose that is not permitted under the laws of the jurisdiction where you use the App",
+ termsOfUseExploit: "to post or transmit, or cause to be posted or transmitted, any Communication designed or intended to obtain password, account or private information of any App user",
+ termsOfUseSpam: "to create or transmit unwanted “spam” to any person or any URL",
+ termsOfUseModify: "you may also not reverse engineer, modify or redistribute the app without written consent from the developers",
+ terminationOfServices: "termination of services",
+ terminationOfServicesDescriptions: "the developers of the App may terminate your access to the App without any prior warning or notice for any of the following reasons",
+ terminationOfServicesBreaching: "breaching the Terms of Service",
+ terminationOfServicesRequest: "receiving a formal request from authorities of Gimnazija Bežigrad administration requesting termination of your access to the App",
+ limitationOfLiability: "limitation of Liability",
+ limitationOfLiabilityContent: "the developers of the App provide no warranty; You expressly acknowledge and agree that the use of the licensed application is at your sole risk. To the maximum extent permited by applicable law, the licensed application and any services performed of provided by the licensed application are provided “as is” and “as available”, with all faults and without warranty of any kind, and licensor hereby disclaims all warranties and conditions with respect to the licensed application and any services, either express, implied or statutory, including, but not limited to, the implied warranties and/or conditions of merchantability, of satisfactory quality, of fitness for a particular purpose, of accuracy, of quiet enjoyment, and of noninfringement of third-party rights. No oral or written information or advice given by licensor or its authorized representative shall create a warranty. Should the licensed application or services prove defective, you assume the entire cost of all necessary servicing, repair or correction. Some jurisdictions do not allow the exclusion of the implied warranties or limitations on applicable statutory rights of a customer, so the above exclusion may not apply to you.",
+ tosAreEffectiveAsOf: "the Terms of Service are effective as of",
+ // privacy policy
+ privacyImportant: "your privacy is important to us. It is the developers' policy to respect your privacy regarding any information we may collect from you through our app, BežiApp.",
+ privacyOnlyAskedWhen: "we only ask for personal information when we truly need it to provide a service to you. We collect it by fair and lawful means, with your knowledge and consent. We also let you know why we’re collecting it and how it will be used.",
+ privacyDataCollection: "we only retain collected information for as long as necessary to provide you with your requested service. What data we store, we’ll protect within commercially acceptable means to prevent loss and theft, as well as unauthorized access, disclosure, copying, use or modification.",
+ privacySharingData: "we don’t share any personally identifying information publicly or with third-parties, except when required to by law",
+ privacyExternalSites: "our app may link to external sites that are not operated by us. Please be aware that we have no control over the content and practices of these sites, and cannot accept responsibility or liability for their respective privacy policies.",
+ privacyRefuse: "you are free to refuse our request for your personal information, with the understanding that we may be unable to provide you with some of your desired services.",
+ privacyAcceptWithUse: "your continued use of our website will be regarded as acceptance of our practices around privacy and personal information. If you have any questions about how we handle user data and personal information, feel free to contact us.",
+ privacyEffectiveAsOf: "this policy is effective as of"
+ },
+}
diff --git a/js/login.js b/js/login.js
index aba0fa3..d7c9579 100644
--- a/js/login.js
+++ b/js/login.js
@@ -1,6 +1,4 @@
const API_ENDPOINT = "https://gimb.tk/test.php";
-// const API_ENDPOINT = "http://localhost:5000/test.php";
-
document.addEventListener("DOMContentLoaded", () => {
setupEventListeners();
})
@@ -46,7 +44,7 @@ function login() {
// If ime is null, the password was incorrect
if (data["ime"] === null) {
- M.toast({ html: "Login failed!" });
+ UIAlert( S("loginFailed"), "login(): fetchprofil null name; bad login info." );
$("#password").val("");
} else {
@@ -63,7 +61,7 @@ function login() {
},
error: function () {
- M.toast({ html: "No internet connection!" });
+ UIAlert( S("noInternetConnection"), "login(): $.ajax error" );
}
})
diff --git a/js/meals.js b/js/meals.js
index e41756b..26b7f0b 100644
--- a/js/meals.js
+++ b/js/meals.js
@@ -1,6 +1,6 @@
const API_ENDPOINT = "https://lopolis-api.gimb.tk/";
-const jsDateDayString = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
-const jsDateMonthString = ["January", "February", "March", "April", "May", "June", "July", "August", "October", "November", "December"];
+const jsDateDayString = [S("sunday"), S("monday"), S("tuesday"), S("wednesday"), S("thursday"), S("friday"), S("saturday")];
+const jsDateMonthString = [S("january"), S("february"), S("march"), S("april"), S("may"), S("june"), S("july"), S("august"), S("october"), S("november"), S("december")];
async function checkLogin() {
localforage.getItem("logged_in_lopolis").then((value) => {
if (value != true) {
@@ -51,7 +51,7 @@ async function getToken(callback, callbackparams = []) {
type: "POST",
success: (dataauth) => {
if(dataauth === null || dataauth.error == true) {
- UIAlert("Authentication error. ", "getToken(): response error or null");
+ UIAlert(D("authenticationError"), "getToken(): response error or null");
setLoading(false);
localforage.setItem("logged_in_lopolis", false).then( function(){
checkLogin();
@@ -63,12 +63,12 @@ async function getToken(callback, callbackparams = []) {
callback(...argumentsToCallback); // poslje token v {token: xxx}
setLoading(false);
} else {
- UIAlert("Authentication error. ", "getToken(): invalid response, no condition met");
+ UIAlert( D("authenticationError"), "getToken(): invalid response, no condition met");
setLoading(false);
}
},
error: () => {
- UIAlert("LopolisAPI connection error. ", "getToken(): AJAX error");
+ UIAlert( D("lopolisAPIConnectionError"), "getToken(): AJAX error");
setLoading(false);
}
});
@@ -76,7 +76,7 @@ async function getToken(callback, callbackparams = []) {
async function getMenus(dataauth, callback, callbackparams = []) {
setLoading(true);
- let d = new Date();
+ let datee = new Date();
// naloži za dva meseca vnaprej (če so zadnji dnevi v mesecu)
let mealsgathered = {};
let promises_to_wait_for = [];
@@ -85,7 +85,7 @@ async function getMenus(dataauth, callback, callbackparams = []) {
url: API_ENDPOINT+"getmenus",
crossDomain: true,
contentType: "application/json",
- data: JSON.stringify({"month": d.getMonth()+iteration, "year": d.getFullYear()}),
+ data: JSON.stringify({"month": datee.getMonth()+iteration, "year": datee.getFullYear()}),
headers: {
"Authorization": "Bearer "+dataauth.token
},
@@ -94,7 +94,7 @@ async function getMenus(dataauth, callback, callbackparams = []) {
type: "POST",
success: (meals) => {
if(meals === null || meals.error == true) {
- UIAlert("Error getting menus. ", "getMenus(): response error or null");
+ UIAlert( D("errorGettingMenus"), "getMenus(): response error or null");
setLoading(false);
localforage.setItem("logged_in_lopolis", false).then( () => {
checkLogin();
@@ -104,12 +104,12 @@ async function getMenus(dataauth, callback, callbackparams = []) {
mealsgathered[iteration] = meals;
} else {
setLoading(false);
- UIAlert("Error: unexpected response. ", "getMenus(): invalid response, no condition met");
+ UIAlert( D("errorUnexpectedResponse") , "getMenus(): invalid response, no condition met");
}
},
error: () => {
setLoading(false);
- UIAlert("LopolisAPI server connection error. ", "getMenus(): AJAX error");
+ UIAlert( D("lopolisAPIConnectionError"), "getMenus(): AJAX error");
}
});
}
@@ -145,7 +145,7 @@ function displayMeals(meals) {
// Create header text element
let subject_header_text = document.createElement("span");
if(mealzz.readonly) {
- unabletochoosequestionmark = "*Read only*";
+ unabletochoosequestionmark = "*" + S("readOnly") + "*";
}
subject_header_text.innerText = jsDateDayString[datum.getDay()]+", "+datum.getDate()+". "+jsDateMonthString[datum.getMonth()]+" "+datum.getFullYear()+" ("+mealzz.meal+"@"
+mealzz.location+") "+unabletochoosequestionmark;
@@ -177,7 +177,7 @@ function displayMeals(meals) {
// Text
meal_lefttext.innerHTML = "<i>"+dmil.text+"</i>";
// Number
- meal_righttext.innerText = "selected";
+ meal_righttext.innerText = S("selected");
} else {
// Text
meal_lefttext.innerText = dmil.text;
@@ -231,12 +231,12 @@ async function lopolisLogin() {
type: "POST",
success: async function(data) {
if(data == null) {
- M.toast({ html: "Request for Authentication failed!" });
+ UIAlert( S("requestForAuthenticationFailed"), "lopolisLogin(): date is is null");
setLoading(false);
usernameEl.value = "";
passwordEl.value = "";
} else if(data.error == true) {
- M.toast({html:"Authentication failed"});
+ UIAlert( S("loginFailed"), "lopolisLogin(): login failed. data.error is true");
usernameEl.value = "";
passwordEl.value = "";
setLoading(false);
@@ -252,7 +252,7 @@ async function lopolisLogin() {
}
},
error: () => {
- M.toast({html:"Authentication failed!"});
+ UIAlert( D("loginError"), "lopolisLogin(): ajax.error");
setLoading(false);
}
});
@@ -287,19 +287,19 @@ async function setMenus(currentmeals = 69, toBeSentChoices) { // currentmeals je
type: "POST",
success: (response) => {
if(response === null || response.error == true) {
- UIAlert("Error setting meals. ", "setMenus(): response error or null");
+ UIAlert( D("errorSettingMeals"), "setMenus(): response error or null");
setLoading(false);
} else if (response.error == false) {
setLoading(false);
- UIAlert("Meal set! Reload meals to be sure.");
+ UIAlert( D("mealSet"), "setMenus(): meni nastavljen");
} else {
setLoading(false);
- UIAlert("Error: unexpected reponse. ", "setMenus(): invalid response, no condition met");
+ UIAlert( D("errorUnexpectedResponse"), "setMenus(): invalid response, no condition met");
}
},
error: () => {
setLoading(false);
- UIAlert("LopolisAPI connection error. ", "setMenus(): AJAX error");
+ UIAlert( D("lopolisAPIConnectionError"), "setMenus(): AJAX error");
}
});
}
diff --git a/js/messaging.js b/js/messaging.js
index 300da1b..9ec9410 100644
--- a/js/messaging.js
+++ b/js/messaging.js
@@ -1,7 +1,5 @@
const API_ENDPOINT = "https://gimb.tk/test.php";
const DIRECTORY_URL = "/directory.json";
-// const API_ENDPOINT = "http://localhost:5000/test.php";
-
// "Global" object for name directory
var directory = null;
@@ -53,7 +51,7 @@ function loadDirectory() {
localforage.getItem("directory").then((stored_directory) => {
if (stored_directory === null) {
// If unable, set directory to null (so other functions know that we don't have it)
- M.toast({ html: "Name directory not set, sending unavailable" });
+ UIAlert( D("nameDirectoryNotSet"), "loadDirectory(): stored_directory === null" );
directory = null;
// Disable send button
document.getElementById("msg-send").disabled = true;
@@ -135,7 +133,7 @@ async function loadMessages(force_refresh = true, katera = 0) {
success: (data) => {
// If data is null, the request failed
if (data === null) {
- M.toast({ html: "Request failed!" });
+ UIAlert( D("requestFailed") );
setLoading(false);
} else {
// Save messages & populate view
@@ -149,7 +147,7 @@ async function loadMessages(force_refresh = true, katera = 0) {
},
error: () => {
- M.toast({ html: "Error fetching messages!" });
+ UIAlert( D("errorFetchingMessages") );
setLoading(false);
}
@@ -189,7 +187,7 @@ async function loadMsg(id) {
success: (data) => {
// If data is null, the request failed
if (data === null) {
- M.toast({ html: "Unable to receive the message, Request failed!" });
+ UIAlert( D("unableToReceiveTheMessage") + " " + D("requestFailed") );
setLoading(false);
} else {
displayMessage(id, data);
@@ -198,7 +196,7 @@ async function loadMsg(id) {
},
error: () => {
- M.toast({ html: "Error fetching message, No Internet connnection?" });
+ UIAlert( D("unableToReceiveTheMessage") + " " + D("noInternetConnection") );
setLoading(false);
}
@@ -233,7 +231,7 @@ async function deleteMsg(id) {
success: (data) => {
// If data is null, the request failed
if (data === null) {
- M.toast({ html: "Unable to delete the message, Request failed!" });
+ UIAlert( D("unableToDeleteTheMessage") + " " + D("requestFailed") );
setLoading(false);
} else {
document.getElementById("msg_box-" + id).remove();
@@ -242,7 +240,7 @@ async function deleteMsg(id) {
},
error: () => {
- M.toast({ html: "Unable to delete the message, No Internet connnection?" });
+ UIAlert( D("unableToDeleteTheMessage") + " " + D("noInternetConnection") );
setLoading(false);
}
@@ -254,12 +252,12 @@ function displayMessage(id, data) {
if(data["telo"].substring(0, 21) == "<!-- beziapp-e2eemsg-") {
var datatodecrypt = data["telo"].substring(29+Number(data["telo"].substring(21, 25)), data["telo"].length-6) // length-6 da zbrišemo zadnji </div>
var randomencdivid = Math.floor(Math.random() * 9999).toString().padStart(4, '0');
- var msgcontent = "<div id='beziapp-msg-e2ee-form-"+randomencdivid+"'>This message was encrypted by BežiApp."
- +"<input type=password autocomplete=new-password id=beziapp-msg-e2ee-password-"+randomencdivid+" placeholder='Enter password ...'><button type=button"
+ var msgcontent = "<div id='beziapp-msg-e2ee-form-"+randomencdivid+"'>"+D("thisMessageWasEncrypted")
+ +"<input type=password autocomplete=new-password id=beziapp-msg-e2ee-password-"+randomencdivid+" placeholder='"+S("password")+" ...'><button type=button"
+"value=Decrypt! class='btn waves-effect waves-light' onclick=document.getElementById('beziapp-msg-e2ee-content-"+randomencdivid+"').innerHTML="
+"filterXSS(sjcl.decrypt(document.getElementById('beziapp-msg-e2ee-password-"+randomencdivid+"').value,document.getElementById('beziapp-msg-e2ee-content-"
+randomencdivid+"').innerHTML));document.getElementById('beziapp-msg-e2ee-content-"+randomencdivid+"').hidden=false;document."
- +"getElementById('beziapp-msg-e2ee-form-"+randomencdivid+"').hidden=true >Decrypt!</button></div><div id='beziapp-msg-e2ee-content-"+randomencdivid+"' hidden='hidden'>"
+ +"getElementById('beziapp-msg-e2ee-form-"+randomencdivid+"').hidden=true >"+S("decrypt")+"!</button></div><div id='beziapp-msg-e2ee-content-"+randomencdivid+"' hidden='hidden'>"
+datatodecrypt+"</div>";
document.getElementById("msg_body-" + id).innerHTML = msgcontent;
} else {
@@ -295,7 +293,7 @@ function displayData() {
});
document.getElementById("storage-bar").hidden = false;
document.getElementById("storage-progressbar").style.width = Number(Number(messages.length/120)*100).toFixed(2)+"%";
- document.getElementById("storage-desc").innerHTML = messages.length+"/120 messages "+document.getElementById("storage-progressbar").style.width;
+ document.getElementById("storage-desc").innerHTML = messages.length+"/120 "+s("messages")+" "+document.getElementById("storage-progressbar").style.width;
}
async function sendMessage(recipient_number, subject, body) {
@@ -327,11 +325,11 @@ async function sendMessage(recipient_number, subject, body) {
type: "POST",
success: () => {
// we CAN'T know wether the mesgg was delievered
- M.toast({ html: "Message was probably sent, check the Sent folder to be sure!" });
+ UIAlert(D("messageWasProbablySent"));
setLoading(false);
},
error: () => {
- M.toast({ html: "Error sending message, no Internet connnection?" });
+ UIAlert(D("errorSendingMessage"), D("noInternetConnection"));
setLoading(false);
}
})
@@ -370,12 +368,11 @@ function setupEventListeners() {
if(document.getElementById("msg-added-image").innerHTML.length > 1) {
document.getElementById("msg-added-image").innerHTML += '<img style=width:20mm src="' + readerEvent.target.result + '" />'; // this is the content!
} else {
- document.getElementById("msg-added-image").innerHTML = "<input type=button value='Remove images' class='btn waves-effect waves-light' "
- +"onclick=additionalstufftoaddtomessage='';document.getElementById('msg-added-image').innerHTML='' /><br>Note: GimB servers don't like large messages, "
- +"so only very small images may be attached or your message will not be delivered.<br>Attached images:<br><img style=width:20mm "
+ document.getElementById("msg-added-image").innerHTML = "<input type=button value='"+S("removeImages")+"' class='btn waves-effect waves-light' "
+ +"onclick=additionalstufftoaddtomessage='';document.getElementById('msg-added-image').innerHTML='' /><br>"+D("largeImagesNote")+"<br>"+S("attachedImages")+":<br><img style=width:20mm "
+"src='"+readerEvent.target.result+"' />"; // ravno obratni narekovaji
}
- M.toast({ html: "Image added as an attachment." });
+ UIAlert(D("imageAddedAsAnAttachment"));
}
}
input.click();
@@ -391,7 +388,7 @@ function setupEventListeners() {
var msgsubject = document.getElementById("msg-subject").value;
if(document.getElementById("msg-e2ee-pass").hidden == false) {
var randomencdivid = Math.floor(Math.random() * 9999).toString().padStart(4, '0');
- var addrparts = window.location.href.split("/");
+ var addrparts = window.location.href.split("/"); // engleski
msgcontent = "<script src='"+addrparts[0]+"//"+addrparts[2]+"/js/lib/sjcl.js'></script><div id='beziapp-msg-e2ee-form-"+randomencdivid+"'>This message was encrypted by BežiApp."
+"<input type=password autocomplete=new-password id=beziapp-msg-e2ee-password-"+randomencdivid+" placeholder='Enter password ...'><input type=button value=Decrypt! onclick="
+"document.getElementById('beziapp-msg-e2ee-content-"+randomencdivid+"').innerHTML=sjcl.decrypt(document.getElementById('beziapp-msg-e2ee-password-"
@@ -410,7 +407,7 @@ function setupEventListeners() {
document.getElementById("msg-added-image").innerHTML = "";
document.getElementById("msg-e2ee-pass").hidden = true;
}).catch(function (err) {
- M.toast({ html: "Unable to read directory of people. Message could not be sent." });
+ UIAlert( D("unableToReadDirectory") + " " + D("messageCouldNotBeSend"), "45245" );
console.log(err);
});
});
diff --git a/js/messaging.js.save b/js/messaging.js.save
deleted file mode 100644
index fb764a8..0000000
--- a/js/messaging.js.save
+++ /dev/null
@@ -1,396 +0,0 @@
-const API_ENDPOINT = "https://gimb.tk/test.php";
-const DIRECTORY_URL = "/directory.json";
-// const API_ENDPOINT = "http://localhost:5000/test.php";
-
-// "Global" object for name directory
-var directory = null;
-
-async function checkLogin() {
- localforage.getItem("logged_in").then(function (value) {
- // This code runs once the value has been loaded
- // from the offline store.
- if (value !== true) {
- window.location.replace("/index.html");
- }
- }).catch(function (err) {
- // This code runs if there were any errors
- console.log(err);
- });
-}
-
-// -----------HTML HELPERS-----------
-function htmlEncode(value) {
- // Create a in-memory element, set its inner text (which is automatically encoded)
- // Then grab the encoded contents back out. The element never exists on the DOM.
- return $("<textarea/>").text(value).html();
-}
-
-function htmlDecode(value) {
- return $("<textarea/>").html(value).text();
-}
-// ---------------------------------
-
-// Try to fetch name:id directory
-function loadDirectory() {
- $.ajax({
- url: DIRECTORY_URL,
- crossDomain: true,
-
- dataType: "json",
- cache: false,
- type: "GET",
-
- success: (data) => {
- // If we were able to retrieve it, update the saved directory
- localforage.setItem("directory", data);
- directory = data;
- // Populate autocomplete
- populateAutocomplete();
- },
-
- error: () => {
- // Otherwise, try to retrieve stored directory
- localforage.getItem("directory").then((stored_directory) => {
- if (stored_directory === null) {
- // If unable, set directory to null (so other functions know that we don't have it)
- M.toast({ html: "Name directory not set, sending unavailable" });
- directory = null;
- // Disable send button
- document.getElementById("msg-send").disabled = true;
- } else {
- directory = stored_directory;
- // Populate autocomplete
- populateAutocomplete();
- }
- });
- }
- });
-}
-
-function populateAutocomplete() {
- let elems = document.querySelectorAll('.autocomplete-fullname');
-
- // vse editam v nanotu
- let autocomplete_entries = directory;
- for (let variableKey in autocomplete_entries) {
- autocomplete_entries[variableKey] = null;
- }
-
- M.Autocomplete.init(elems, {
- data: autocomplete_entries,
- onAutocomplete: validateName,
- minLength: 0
- });
-}
-
-// Function to toggle loading bar
-function setLoading(state) {
- if (state) {
- $("#loading-bar").removeClass("hidden");
- } else {
- $("#loading-bar").addClass("hidden");
- }
-}
-
-// Function, responsible for fetching and displaying data
-async function loadMessages(force_refresh = true, katera = 0) {
- setLoading(true);
- // Load required data
- let promises_to_run = [
- localforage.getItem("username").then((value) => {
- username = value;
- }),
- localforage.getItem("password").then((value) => {
- password = value;
- }),
- localforage.getItem("messages").then((value) => {
- messages = value;
- })
- ];
-
- Promise.all(promises_to_run).then(() => {
-
- if (messages === null || force_refresh) {
- $.ajax({
- url: API_ENDPOINT,
- crossDomain: true,
- data: {
- "u": username,
- "p": password,
- "m": "fetchsporocilaseznam",
- "a": katera // Message type, see API doc for details
- },
- dataType: "json",
- cache: false,
- type: "GET",
-
- success: (data) => {
- // If data is null, the request failed
- if (data === null) {
- M.toast({ html: "Request failed!" });
- setLoading(false);
- } else {
- // Save messages & populate view
- // console.log(data); // debug
- localforage.setItem("messages", data).then((value) => {
- messages = value;
- displayData();
- setLoading(false);
- });
- }
- },
-
- error: () => {
- M.toast({ html: "Error fetching messages!" });
- setLoading(false);
- }
-
- })
- } else {
- displayData();
- setLoading(false);
- }
- });
-}
-
-async function loadMsg(id) {
- setLoading(true);
- // Load required data
- let promises_to_run = [
- localforage.getItem("username").then((value) => {
- username = value;
- }),
- localforage.getItem("password").then((value) => {
- password = value;
- }),
- ];
-
- Promise.all(promises_to_run).then(() => {
- $.ajax({
- url: API_ENDPOINT,
- crossDomain: true,
- data: {
- "u": username,
- "p": password,
- "m": "fetchsporocilo",
- "a": id
- },
- dataType: "json",
- cache: false,
- type: "GET",
- success: (data) => {
- // If data is null, the request failed
- if (data === null) {
- M.toast({ html: "Unable to receive the message, Request failed!" });
- setLoading(false);
- } else {
- displayMessage(id, data);
- setLoading(false);
- }
- },
-
- error: () => {
- M.toast({ html: "Error fetching message, No Internet connnection?" });
- setLoading(false);
- }
-
- })
- });
-}
-
-
-async function deleteMsg(id) {
- setLoading(true);
- // Load required data
- let promises_to_run = [
- localforage.getItem("username").then((value) => {
- username = value;
- }), localforage.getItem("password").then((value) => {
- password = value;
- }),
- ];
- Promise.all(promises_to_run).then(() => {
- $.ajax({
- url: API_ENDPOINT,
- crossDomain: true,
- data: {
- "u": username,
- "p": password,
- "m": "izbrisisporocilo",
- "a": id
- },
- dataType: "json",
- cache: false,
- type: "GET",
- success: (data) => {
- // If data is null, the request failed
- if (data === null) {
- M.toast({ html: "Unable to delete the message, Request failed!" });
- setLoading(false);
- } else {
- document.getElementById("msg-box-" + id).remove();
- setLoading(false);
- }
- },
-
- error: () => {
- M.toast({ html: "Unable to delete the message, No Internet connnection?" });
- setLoading(false);
- }
-
- })
- });
-}
-
-function displayMessage(id, data) {
- document.getElementById("msg-body-" + id).innerHTML = filterXSS(data["telo"]);
-}
-
-// Function for displaying data
-function displayData() {
- let msg_list = document.getElementById("msg-list");
- msg_list.innerHTML = "";
- messages.forEach(element => {
- if (element["zadeva"].substr(0, 14) != "beziapp-ctlmsg")
- msg_list.innerHTML += '<div class="col s12 m6" id="msg_box-' +
- filterXSS(element["id"]) +
- '"><div class="card blue-grey darken-1"><div class="card-content white-text"><span class="card-title">' +
- filterXSS(element["zadeva"]) +
- '</span><p id="msg_body-' +
- filterXSS(element["id"]) +
- '"><button class="btn waves-effect waves-light" onclick=loadMsg("' +
- filterXSS(element["id"]) +
- '"); type="submit">Load message body<i class="material-icons right">system_update</i></button></p></div><div class="card-action"><a href=javascript:deleteMsg("' +
- filterXSS(element["id"]) +
- '");><i class="material-icons">delete</i></a><a href=\'javascript:document.getElementById("full_name").value="' +
- filterXSS(element["posiljatelj"]) +
- '";document.getElementById("msg_subject").value="Re: ' +
- filterXSS(element["zadeva"]) +
- '";M.updateTextFields();document.getElementById("navigation-main").scrollIntoView();\'><i class="material-icons">reply</i></a>' +
- filterXSS(element["posiljatelj"]) + " &raquo; " + filterXSS(element["datum"]["dan"]) + ". " + filterXSS(element["datum"]["mesec"]) + ". " + filterXSS(element["datum"]["leto"]) + " at " +
- filterXSS(element["cas"]["ura"]) + ":" + filterXSS(element["cas"]["minuta"]) +
- '</div></div></div>';
- });
-}
-
-async function sendMessage(recipient_number, subject, body) {
- setLoading(true);
- let promises_to_run = [
- localforage.getItem("username").then((value) => {
- username = value;
- }),
- localforage.getItem("password").then((value) => {
- password = value;
- }),
- ];
- Promise.all(promises_to_run).then(() => {
- $.ajax({
- url: API_ENDPOINT,
- crossDomain: true,
- data: {
- "u": username,
- "p": password,
- "m": "posljisporocilo",
- "a": recipient_number,
- "b": subject,
- "c": body
- },
-
- dataType: "json",
- cache: false,
-
- type: "POST",
- success: () => {
- // we CAN'T know wether the mesgg was delievered
- M.toast({ html: "Message was probably sent, check the Sent folder to be sure!" });
- setLoading(false);
- },
- error: () => {
- M.toast({ html: "Error sending message, no Internet connnection?" });
- setLoading(false);
- }
- })
- });
-}
-
-function validateName() {
- if (directory !== null) {
-
- if ($("#full-name").val() in directory) {
- $("#full-name").addClass("valid");
- $("#full-name").removeClass("invalid");
- document.getElementById("msg-send").disabled = false;
- } else {
- $("#full-name").addClass("invalid");
- $("#full-name").removeClass("valid");
- document.getElementById("msg-send").disabled = true;
- }
-
- }
-}
-
-// Setup event listeners for buttons
-function setupEventListeners() {
- // Button to add a photo
- $("#msg-add-photo").click(() => {
- let input = document.createElement("input");
- input.type = "file";
- input.onchange = (e) => {
- // getting a hold of the file reference
- let file = e.target.files[0];
- // setting up the reader
- let reader = new FileReader();
- reader.readAsDataURL(file); // this is reading as data url
- // here we tell the reader what to do when it's done reading...
- reader.onload = readerEvent => {
- additionalstufftoaddtomessage += '<br><img src="' + readerEvent.target.result + '" />'; // this is the content!
- M.toast({ html: "Image added as an attachment." });
- }
- }
- input.click();
- });
-
- // Verify recipient when input loses focus
- $("#full-name").on("blur", validateName);
-
- // Button to send message
- $("#msg-send").click(() => {
- localforage.getItem("directory").then(function (value) {
- sendMessage(value[document.getElementById("full-name").value], document.getElementById("msg-subject").value,
- htmlEncode(document.getElementById("msg-body").value + additionalstufftoaddtomessage));
- document.getElementById("msg-body").value = "";
- document.getElementById("full-name").value = "";
- document.getElementById("msg-subject").value = "";
- additionalstufftoaddtomessage = "";
- }).catch(function (err) {
- M.toast({ html: "Unable to read directory of people. Message could not be sent." });
- console.log(err);
- });
- });
-}
-
-function getUrlParameter(sParam) {
- const url_params = new URLSearchParams(window.location.search);
- const found_param = url_params.get(sParam);
- return found_param
-}
-
-var additionalstufftoaddtomessage = "";
-document.addEventListener("DOMContentLoaded", () => {
-
- checkLogin();
- loadDirectory();
- setupEventListeners();
-
- 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");
- M.Sidenav.init(menus, { edge: "right", draggable: true });
-
-});
diff --git a/sw.js b/sw.js
index 030dc99..03720e6 100644
--- a/sw.js
+++ b/sw.js
@@ -1,5 +1,5 @@
// Change version to cause cache refresh
-const static_cache_name = "site-static-v1.0.11.4";
+const static_cache_name = "site-static-v1.0.11.5";
// Tukej ne met notr directory namov, samo imena fajlov,
// ker v primeru index.html to prpele do double-cachinga, oz. do velik 404