summaryrefslogtreecommitdiff
path: root/static/js/reload.js
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2021-08-22 11:36:40 +0200
committerDaniel Friesel <derf@finalrewind.org>2021-08-22 11:36:40 +0200
commit4596613e65581712f6c230f87971edfabd0ae919 (patch)
tree8af733edee0393d27e11f412694f148ec64282d8 /static/js/reload.js
parent222bd52cefbf7efe689533f21e6ebaf43ed937d8 (diff)
add 'synchronization failed' marker0.3.0
Diffstat (limited to 'static/js/reload.js')
-rw-r--r--static/js/reload.js16
1 files changed, 15 insertions, 1 deletions
diff --git a/static/js/reload.js b/static/js/reload.js
index 9bdc7c0..183268d 100644
--- a/static/js/reload.js
+++ b/static/js/reload.js
@@ -1,12 +1,26 @@
document.addEventListener("DOMContentLoaded", function() {
const departureList = document.getElementById('departurelist');
+ const syncFailedMarker = document.getElementById('syncfailedmarker');
const showDepartures = (departureText) => {
departureList.innerHTML = departureText;
};
const fetchDepartures = () => {
- fetch(window.location.href + '?ajax=1').then(response => response.text()).then(showDepartures);
+ fetch(window.location.href + '?ajax=1')
+ .then(response => {
+ if (!response.ok) {
+ throw Error(response.statusText);
+ }
+ return response.text()
+ })
+ .then(departureText => {
+ syncFailedMarker.style.display = "none";
+ showDepartures(departureText);
+ })
+ .catch(err => {
+ syncFailedMarker.style.display = "inline-block";
+ });
};
setInterval(fetchDepartures, 60000);