diff --git a/templates/results.html b/templates/results.html index e98d6f4..df0e7c9 100644 --- a/templates/results.html +++ b/templates/results.html @@ -85,6 +85,7 @@ + Loading fares
@@ -352,13 +353,23 @@ } function loadWalkonFares() { - for (var sectionId in WALKON_API_URLS) { + var urls = WALKON_API_URLS; + var pending = Object.keys(urls).length; + if (!pending) return; + function done() { + if (--pending === 0) { + var el = document.getElementById('walkon-loading'); + if (el) el.style.display = 'none'; + } + } + for (var sectionId in urls) { (function(id, url) { fetch(url).then(function(r) { return r.json(); }).then(function(fares) { mergeWalkonFares(id, fares); updateDisplay(); - }); - })(sectionId, WALKON_API_URLS[sectionId]); + done(); + }).catch(done); + })(sectionId, urls[sectionId]); } }