Show spinner while walk-on fares are loading

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Edward Betts 2026-05-21 18:42:01 +01:00
parent 03d2a53961
commit 5910bae33b

View file

@ -85,6 +85,7 @@
<button type="button" class="btn-group-option {% if nr_class == 'advance_std' %}active{% endif %}" onclick="setNrClass('advance_std')">Advance Std</button>
<button type="button" class="btn-group-option {% if nr_class == 'advance_1st' %}active{% endif %}" onclick="setNrClass('advance_1st')">Advance 1st</button>
</div>
<span id="walkon-loading"><span class="spinner spinner-inline" aria-hidden="true"></span>Loading fares</span>
<span id="advance-loading" style="display:none"><span class="spinner spinner-inline" aria-hidden="true"></span>Loading advance fares</span>
</div>
<div>
@ -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]);
}
}