From 4596613e65581712f6c230f87971edfabd0ae919 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 22 Aug 2021 11:36:40 +0200 Subject: add 'synchronization failed' marker --- static/js/reload.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'static/js') 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); -- cgit v1.2.3