diff options
author | rstular <rok@stular.eu> | 2020-02-05 10:54:38 +0100 |
---|---|---|
committer | rstular <rok@stular.eu> | 2020-02-05 10:54:38 +0100 |
commit | ee6df3576b38af236e53a0ee31649f3897c626a6 (patch) | |
tree | 859e5ba568f1500777a746f875fb430c69472db7 /js | |
parent | Updated changelog, awaiting more changes (diff) | |
download | beziapp-ee6df3576b38af236e53a0ee31649f3897c626a6.tar beziapp-ee6df3576b38af236e53a0ee31649f3897c626a6.tar.gz beziapp-ee6df3576b38af236e53a0ee31649f3897c626a6.tar.bz2 beziapp-ee6df3576b38af236e53a0ee31649f3897c626a6.tar.lz beziapp-ee6df3576b38af236e53a0ee31649f3897c626a6.tar.xz beziapp-ee6df3576b38af236e53a0ee31649f3897c626a6.tar.zst beziapp-ee6df3576b38af236e53a0ee31649f3897c626a6.zip |
Diffstat (limited to 'js')
-rw-r--r-- | js/gradings.js | 73 |
1 files changed, 37 insertions, 36 deletions
diff --git a/js/gradings.js b/js/gradings.js index 8902a5d..1109961 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 || 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); + } + }); } |