summaryrefslogtreecommitdiff
path: root/static/js/reload.js
diff options
context:
space:
mode:
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);