summaryrefslogtreecommitdiffstats
path: root/assets
diff options
context:
space:
mode:
authorsijanec <anton@sijanec.eu>2021-05-16 16:49:09 +0200
committersijanec <anton@sijanec.eu>2021-05-16 16:49:09 +0200
commitabd9011fa84bdc1f6ee583e387d0ec686c3dc3ab (patch)
tree297222608598dae2478c79f4e82b655c6c497292 /assets
parentMerge branch 'master' into dev (diff)
downloadbeziapp-abd9011fa84bdc1f6ee583e387d0ec686c3dc3ab.tar
beziapp-abd9011fa84bdc1f6ee583e387d0ec686c3dc3ab.tar.gz
beziapp-abd9011fa84bdc1f6ee583e387d0ec686c3dc3ab.tar.bz2
beziapp-abd9011fa84bdc1f6ee583e387d0ec686c3dc3ab.tar.lz
beziapp-abd9011fa84bdc1f6ee583e387d0ec686c3dc3ab.tar.xz
beziapp-abd9011fa84bdc1f6ee583e387d0ec686c3dc3ab.tar.zst
beziapp-abd9011fa84bdc1f6ee583e387d0ec686c3dc3ab.zip
Diffstat (limited to 'assets')
-rw-r--r--assets/js/colors.js46
-rw-r--r--assets/js/gradings.js20
-rw-r--r--assets/js/gsec.js4
-rw-r--r--assets/js/lang/bundle.js.bvr10
-rw-r--r--assets/js/settings.js21
-rw-r--r--assets/js/setup-storage.js.bvr1
-rw-r--r--assets/js/timetable.js40
-rw-r--r--assets/pages-src/changelog.bvr17
-rw-r--r--assets/pages-src/gradings.bvr3
-rw-r--r--assets/pages-src/settings.bvr13
-rw-r--r--assets/pages-src/timetable.bvr1
11 files changed, 124 insertions, 52 deletions
diff --git a/assets/js/colors.js b/assets/js/colors.js
new file mode 100644
index 0000000..d06861a
--- /dev/null
+++ b/assets/js/colors.js
@@ -0,0 +1,46 @@
+/* adapted from https://git.šijanec.eu/siska/beziapp-sam-lepo */
+
+function linMap(c, mn, mx) {
+ return c*(mx-mn)+mn;
+}
+function getDecimal(n) {
+ return (n-Math.floor(n));
+}
+function mapColorPalete(c, palete) {
+ let poz = c*(palete.length-1);
+ let col1 = palete[Math.floor(poz)]; /* https://git.šijanec.eu/siska/beziapp-sam-lepo */
+ let col2 = palete[Math.ceil(poz)]; /* made by siska */
+ return (Math.floor(linMap(getDecimal(poz),col1[0],col2[0])).toString(16).padStart(2,0)+
+ Math.floor(linMap(getDecimal(poz),col1[1],col2[1])).toString(16).padStart(2,0)+
+ Math.floor(linMap(getDecimal(poz),col1[2],col2[2])).toString(16).padStart(2,0)).toUpperCase();
+}
+/**
+ *
+ * Convert last 3 bytes of an integer to RGB color
+ * @param {integer} input_integer Integer that will be converted to RGB color
+ * @returns {string} Hex color code
+ *
+ */
+function intToRGB(i, palete = null) {
+ if (palete == null) {
+ var c = (i & 0x00FFFFFF)
+ .toString(16)
+ .toUpperCase();
+
+ return "00000".substring(0, 6 - c.length) + c;
+ } else return mapColorPalete((i & 0xFF) / 0xFF, palete);
+}
+
+
+/**
+ *
+ * Convert a given string to hex color
+ * @param {string} input_string Input string
+ * @returns {string} Hex RGB color
+ */
+function getHexColorFromString(str) {
+ if (urnikTheme == "privzeta")
+ return "#" + intToRGB(hashCode(str));
+ else
+ return "#" + intToRGB(hashCode(str), [[38, 70, 83], [42, 157, 143], [233, 196, 106], [244, 162, 97], [231, 111, 81]]);
+}
diff --git a/assets/js/gradings.js b/assets/js/gradings.js
index 92e696d..7db4c98 100644
--- a/assets/js/gradings.js
+++ b/assets/js/gradings.js
@@ -32,14 +32,6 @@ function hashCode(str) { // java String#hashCode
return hash;
}
-function intToRGB(i) {
- var c = (i & 0x00FFFFFF)
- .toString(16)
- .toUpperCase();
-
- return "00000".substring(0, 6 - c.length) + c;
-}
-
// http://www.w3.org/TR/AERT#color-contrast
function getForegroundFromBackground(background_color) {
let color_hex = background_color.replace("#", "");
@@ -56,11 +48,6 @@ function getForegroundFromBackground(background_color) {
}
}
-function getHexColorFromString(str) {
- return "#" + intToRGB(hashCode(str));
-}
-// --------------------------------------------------
-
function getDateString() {
let date = new Date();
@@ -171,9 +158,12 @@ function setupPickers() {
instances = M.Datepicker.init(elems, options);
}
+var urnikTheme = "privzeta";
-
-document.addEventListener("DOMContentLoaded", () => {
+document.addEventListener("DOMContentLoaded", async function () {
+ urnikTheme = await localforage.getItem("urnikTheme");
+ if (urnikTheme == null || urnikTheme == undefined || urnikTheme == false)
+ urnikTheme = "privzeta";
checkLogin();
// Calendar setup
var calendarEl = document.getElementById("calendar");
diff --git a/assets/js/gsec.js b/assets/js/gsec.js
index 3dcde88..2f5400d 100644
--- a/assets/js/gsec.js
+++ b/assets/js/gsec.js
@@ -236,12 +236,14 @@ class gsec {
var razred = desc[2];
var teacher = desc[3];
var place = desc[4];
+ var nadomescanje = urnikElement.parentElement.classList.contains("flagS");
urnik[day][period] = {
"subject": subject,
"acronym": abkurzung,
"class": razred,
"teacher": teacher,
- "place": place
+ "place": place,
+ "substitution": nadomescanje
};
}
resolve(urnik);
diff --git a/assets/js/lang/bundle.js.bvr b/assets/js/lang/bundle.js.bvr
index 125d3c6..c75e965 100644
--- a/assets/js/lang/bundle.js.bvr
+++ b/assets/js/lang/bundle.js.bvr
@@ -159,6 +159,7 @@ var langstrings = {
settings: "settings",
// timetable
noPeriods: "no periods in selected week",
+ substitution: "substitution",
// gradings
date: "date",
description: "description",
@@ -244,7 +245,7 @@ var langstrings = {
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: "editable meals are highlighted in gold, read-only meals are highlighted in grey and cannot be changed. Meals that provide no options for menus are not shown for clarity, same applies for days where there are no meals",
- mealsContributeNote: "you are welcome to contribute to the LopolisAPI project and add features, such as checkouts.",
+ mealsContributeNote: "you are welcome to contribute to the BežiApp project.",
authenticationError: "authentication error",
lopolisAPIConnectionError: "LopolisAPI server connection error",
errorGettingMenus: "error getting menus",
@@ -315,6 +316,7 @@ var langstrings = {
on: "on",
off: "off",
selectErrorReporting: "should error reports be submitted to the developers?",
+ urnikTheme: "timetable theme",
// gsec
gsecErrNet: "GimSIS connection error",
gsecErrLogin: "GimSIS login error (bad password?), try logging out",
@@ -361,6 +363,7 @@ var langstrings = {
browserNotSupported: "BežiApp ne bo deloval na vaši napravi, če ne posodobite vašega Internetnega brskalnika",
// timetable
noPeriods: "ni ur v izbranem tednu",
+ substitution: "nadomeščanje",
// index
timetable: "urnik",
gradings: "ocenjevanja",
@@ -457,7 +460,7 @@ var langstrings = {
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 kosila, zato verjetno to ne deluje. Če ste naročeni na kosila lahko naročanje na menije sploh ne deluje ali pa deluje narobe.",
mealNotShownNote: "obroki, označeni z zlato so nastavljivi, tisti, označeni s sivo, niso, če pa pri kakšnem dnevu obroka ni, pa pomeni, da ga ni moč nastaviti ali pa da ne obrok ne obstaja",
- mealsContributeNote: "vabimo vas k urejanju LopolisAPI programa za upravljanje z meniji.",
+ mealsContributeNote: "vabimo vas k urejanju BežiApp programa.",
authenticationError: "napaka avtentikacije",
lopolisAPIConnectionError: "napaka povezave na LopolisAPI strežnik",
errorGettingMenus: "napaka branja menijev",
@@ -517,7 +520,7 @@ var langstrings = {
themeLight: "svetel izgled (privzeto)",
themeDark: "temen izgled",
themeNight: "nočni izgled",
- themeSet: "izgled nastavljen, odprite neko drugo stran da se spremembe uveljavijo",
+ themeSet: "izgled nastavljen, odprite neko drugo stran, da se spremembe uveljavijo",
selectTheme: "izberite željen izgled",
errorReportingSet: "nastavitev pošiljanja napak izbrana",
errorReporting: "pošiljanje napak",
@@ -528,6 +531,7 @@ var langstrings = {
triggerAgreement: "strinjam se z zgoraj navedenimi pogoji",
triggerWarningSet: "spremenili ste stanje dodatnih nastavitev",
additionalOptions: "dodatne nastavitve",
+ urnikTheme: "izgled urnika",
// gsec
gsecErrNet: "napaka povezave na GimSIS",
gsecErrLogin: "prijava v GimSIS ni uspela (napačno geslo?), poskusite se odjaviti",
diff --git a/assets/js/settings.js b/assets/js/settings.js
index 3106f14..2a721d7 100644
--- a/assets/js/settings.js
+++ b/assets/js/settings.js
@@ -14,6 +14,13 @@ async function setTheme(targetTheme) {
});
}
+async function setUrnikTheme(targetTheme) {
+ localforage.setItem("urnikTheme", targetTheme).then((value) => {
+ console.log("Urnik theme set" + value);
+ UIAlert(D("themeSet"), "setUrnikTheme(): themeSet")
+ });
+}
+
async function setErrorReporting(targetE) {
localforage.setItem("errorReporting", targetE).then((value) => {
console.log("ErrorReporing set: " + value);
@@ -82,7 +89,9 @@ document.addEventListener("DOMContentLoaded", async () => {
$("#select-errorreporting").on("change", function() {
setErrorReporting($(this).find(":selected").val());
});
-
+ $("#select-urniktheme").on("change", function() {
+ setUrnikTheme($(this).find(":selected").val());
+ });
localforage.getItem("chosenLang").then((value) => {
let selectedLanguage = value;
if(value == null || value.length < 1) {
@@ -90,7 +99,12 @@ document.addEventListener("DOMContentLoaded", async () => {
}
$(`#option-${selectedLanguage}`).attr("selected", true);
}).catch(() => {});
-
+ localforage.getItem("urnikTheme").then((value) => {
+ if (value == null || value.length < 1) {
+ value = "privzeta";
+ }
+ $(`#option-${value}`).attr("selected", true);
+ }).catch(()=>{});
localforage.getItem("theme").then((value) => {
let selectedTheme = value;
if(value == null || value.length < 1) {
@@ -124,6 +138,9 @@ document.addEventListener("DOMContentLoaded", async () => {
var elems = document.querySelectorAll(".errorreporting-select");
M.FormSelect.init(elems, {});
+ var elems = document.querySelectorAll(".urniktheme-select");
+ M.FormSelect.init(elems, {});
+
// Setup language select dropdown
var elems = document.querySelectorAll(".lang-select");
M.FormSelect.init(elems, {});
diff --git a/assets/js/setup-storage.js.bvr b/assets/js/setup-storage.js.bvr
index 3d3b554..75dfdf8 100644
--- a/assets/js/setup-storage.js.bvr
+++ b/assets/js/setup-storage.js.bvr
@@ -21,6 +21,7 @@ async function setupStorage(force = false) {
localforage.setItem("directory", {}), //\\ well I could remember my own code but I didn't.
localforage.setItem("meals", {}),
localforage.setItem("lastUpdate", 0),
+ localforage.setItem("urnikTheme", "privzeta"),
localforage.setItem("triggerWarningAccepted", false)
];
diff --git a/assets/js/timetable.js b/assets/js/timetable.js
index 85c555a..f4fa01d 100644
--- a/assets/js/timetable.js
+++ b/assets/js/timetable.js
@@ -42,21 +42,6 @@ function hashCode(str) { // java String#hashCode
return hash;
}
-/**
- *
- * Convert last 3 bytes of an integer to RGB color
- * @param {integer} input_integer Integer that will be converted to RGB color
- * @returns {string} Hex color code
- *
- */
-function intToRGB(i) {
- var c = (i & 0x00FFFFFF)
- .toString(16)
- .toUpperCase();
-
- return "00000".substring(0, 6 - c.length) + c;
-}
-
// http://www.w3.org/TR/AERT#color-contrast
/**
*
@@ -78,16 +63,6 @@ function getForegroundFromBackground(background_color) {
return "#ffffff";
}
}
-
-/**
- *
- * Convert a given string to hex color
- * @param {string} input_string Input string
- * @returns {string} Hex RGB color
- */
-function getHexColorFromString(str) {
- return "#" + intToRGB(hashCode(str));
-}
// --------------------------------------------------
// ---------DATE FUNCTION-------------
@@ -214,6 +189,7 @@ function displayTimetable(weekly_timetable, date_object) {
class: lesson["class"],
teacher: lesson["teacher"],
classroom: lesson["place"],
+ substitution: lesson["substitution"],
start: lesson_times[0].substring(0, 5),
end: lesson_times[1].substring(0, 5)
}
@@ -224,9 +200,10 @@ function displayTimetable(weekly_timetable, date_object) {
start: date_string + " " + lesson_times[0],
end: date_string + " " + lesson_times[1],
backgroundColor: bg_color,
- textColor: fg_color
+ textColor: fg_color,
};
-
+ if (lesson["substitution"])
+ lesson_object.borderColor = "red";
transformed_timetable.push(lesson_object);
});
@@ -246,7 +223,7 @@ function eventClickHandler(eventClickInfo) {
let lesson_class = lesson_metadata["class"];
let lesson_duration = lesson_metadata["start"] + " - " + lesson_metadata["end"];
- $("#lesson-subject").text(lesson_subject);
+ $("#lesson-subject").text(lesson_subject + (lesson_metadata["substitution"] ? (" (" + s("substitution") + ")") : ""));
$("#lesson-teacher").text(lesson_teacher);
$("#lesson-class").text(lesson_class);
$("#lesson-classroom").text(lesson_classroom);
@@ -256,10 +233,13 @@ function eventClickHandler(eventClickInfo) {
M.Sidenav.getInstance(modal).open();
}
+var urnikTheme = "privzeta";
-document.addEventListener("DOMContentLoaded", () => {
+document.addEventListener("DOMContentLoaded", async function() {
+ urnikTheme = await localforage.getItem("urnikTheme");
+ if (urnikTheme == null || urnikTheme == undefined || urnikTheme == false)
+ urnikTheme = "privzeta";
checkLogin();
-
let calendarEl = document.getElementById("calendar");
calendar_obj = new FullCalendar.Calendar(calendarEl, {
plugins: ["timeGrid"],
diff --git a/assets/pages-src/changelog.bvr b/assets/pages-src/changelog.bvr
index e112765..5593c59 100644
--- a/assets/pages-src/changelog.bvr
+++ b/assets/pages-src/changelog.bvr
@@ -54,6 +54,23 @@
<ul class="collapsible">
<li>
+ <div class="collapsible-header">Version 1.0.17-beta</div>
+ <div class="collapsible-body">
+ <ul class="collection">
+ <li
+ class="collection-item">Added
+ substitutions</li>
+ <li
+ class="collection-item">Added
+ urnik
+ theme
+ selection
+ (Thanks to
+ a dijak from
+ Vegova's G2B)</li>
+ </ul>
+ </div>
+
<div class="collapsible-header">Version 1.0.16-beta</div>
<div class="collapsible-body">
<ul class="collection">
diff --git a/assets/pages-src/gradings.bvr b/assets/pages-src/gradings.bvr
index 9a18dae..0c12dd0 100644
--- a/assets/pages-src/gradings.bvr
+++ b/assets/pages-src/gradings.bvr
@@ -26,6 +26,7 @@
<link type="text/css" href="/css/styles.css" rel="stylesheet">
<script type="text/javascript" src="/js/gsec.js"></script> <!-- gimsisextclient -->
+ <script src=/js/colors.js></script>
<script type="text/javascript" src="/js/gradings.js"></script>
<link rel="manifest" href="/manifest.json">
@@ -87,4 +88,4 @@
</body>
- </html> \ No newline at end of file
+ </html>
diff --git a/assets/pages-src/settings.bvr b/assets/pages-src/settings.bvr
index e3ebb9c..a364f40 100644
--- a/assets/pages-src/settings.bvr
+++ b/assets/pages-src/settings.bvr
@@ -83,6 +83,19 @@
</div>
</div>
+ <div class="row">
+ <div class="col s12">
+ <h5 class="general-text"><x-su>urnikTheme</x-su></h5>
+ </div>
+ <div class="input-field col s12">
+ <i class="material-icons prefix">palette</i>
+ <select class="urniktheme-select input-select" id="select-urniktheme">
+ <option value="privzeta" id="option-privzeta" data-urniktheme="privzeta" selected>GimB</option>
+ <option value="poletna" id="option-poletna" data-urniktheme="poletna">Summer / poletna</option>
+ </select>
+ <label><x-su>selectTheme</x-su></label>
+ </div>
+ </div>
<div class="row">
<div class="col s12">
diff --git a/assets/pages-src/timetable.bvr b/assets/pages-src/timetable.bvr
index 171a595..47457c0 100644
--- a/assets/pages-src/timetable.bvr
+++ b/assets/pages-src/timetable.bvr
@@ -27,6 +27,7 @@
<link type="text/css" href="/css/styles.css" rel="stylesheet">
<script type="text/javascript" src="/js/gsec.js"></script> <!-- gimsisextclient -->
+ <script src=/js/colors.js></script> <!-- colors by šiška -->
<script type="text/javascript" src="/js/timetable.js"></script>
<link rel="manifest" href="/manifest.json">