summaryrefslogtreecommitdiffstats
path: root/js/gradings.js
diff options
context:
space:
mode:
authorrstular <rok@stular.eu>2020-02-05 11:18:06 +0100
committerGitHub <noreply@github.com>2020-02-05 11:18:06 +0100
commit5088c34735cd4f1fc9ae8162ed1a43838a2a4b20 (patch)
tree07a81116d656f96b88e7ff374d0faff5fbaa2947 /js/gradings.js
parentMerge pull request #4 from beziapp/dev (diff)
parentMerge branch 'dev' of https://github.com/beziapp/beziapp.github.io into dev (diff)
downloadbeziapp-5088c34735cd4f1fc9ae8162ed1a43838a2a4b20.tar
beziapp-5088c34735cd4f1fc9ae8162ed1a43838a2a4b20.tar.gz
beziapp-5088c34735cd4f1fc9ae8162ed1a43838a2a4b20.tar.bz2
beziapp-5088c34735cd4f1fc9ae8162ed1a43838a2a4b20.tar.lz
beziapp-5088c34735cd4f1fc9ae8162ed1a43838a2a4b20.tar.xz
beziapp-5088c34735cd4f1fc9ae8162ed1a43838a2a4b20.tar.zst
beziapp-5088c34735cd4f1fc9ae8162ed1a43838a2a4b20.zip
Diffstat (limited to 'js/gradings.js')
-rw-r--r--js/gradings.js73
1 files changed, 37 insertions, 36 deletions
diff --git a/js/gradings.js b/js/gradings.js
index 8902a5d..0b8b53b 100644
--- a/js/gradings.js
+++ b/js/gradings.js
@@ -91,51 +91,52 @@ async function loadGradings(force_refresh = false) {
})
];
- await Promise.all(promises_to_run);
+ Promise.all(promises_to_run).then(() => {
- if (gradings === null || force_refresh) {
- $.ajax({
- url: API_ENDPOINT,
- crossDomain: true,
+ if (gradings === null || gradings === [] || gradings === -1 || force_refresh) {
+ $.ajax({
+ url: API_ENDPOINT,
+ crossDomain: true,
- data: {
- "u": username,
- "p": password,
- "m": "fetchocenjevanja"
- },
- dataType: "json",
+ data: {
+ "u": username,
+ "p": password,
+ "m": "fetchocenjevanja"
+ },
+ dataType: "json",
- cache: false,
- type: "GET",
+ cache: false,
+ type: "GET",
- success: (data) => {
+ success: (data) => {
- // If data is null, the credentials were incorrect
- if (data === null) {
- M.toast({ html: "Request failed!" });
- setLoading(false);
- } else {
- // Save gradings & populate calendar
- localforage.setItem("gradings", data).then((value) => {
- gradings = value;
- displayData();
+ // If data is null, the credentials were incorrect
+ if (data === null) {
+ M.toast({ html: "Request failed!" });
setLoading(false);
- });
+ } else {
+ // Save gradings & populate calendar
+ localforage.setItem("gradings", data).then((value) => {
+ gradings = value;
+ displayData();
+ setLoading(false);
+ });
+ }
+
+ },
+
+ error: () => {
+ M.toast({ html: "No internet connection!" });
+ setLoading(false);
}
- },
-
- error: () => {
- M.toast({ html: "No internet connection!" });
- setLoading(false);
- }
-
- })
+ })
- } else {
- displayData();
- setLoading(false);
- }
+ } else {
+ displayData();
+ setLoading(false);
+ }
+ });
}