From 2cf4405ce0c1f48119902f8adde1ce2244cda2f7 Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Sat, 24 Aug 2024 19:08:40 -0700 Subject: [PATCH] Tweak PWA mobile loading indicator * Don't show the loading indicator when intercepted href="#" links have been clicked (e.g. like buttons, settings tabs) --- web/static/js/bulma.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/web/static/js/bulma.js b/web/static/js/bulma.js index 9cc056f..dfeab07 100644 --- a/web/static/js/bulma.js +++ b/web/static/js/bulma.js @@ -16,7 +16,11 @@ document.addEventListener('DOMContentLoaded', () => { const spinner = document.querySelector("#nonshy-pwa-loader"); (document.querySelectorAll("a, form") || []).forEach(node => { // Links: only on-site ones. - if (node.tagName === 'A' && node.target === '_blank') return; + if (node.tagName === 'A') { + let href = node.attributes.href?.textContent; + if (!href) return; + if (node.target === '_blank' || href.indexOf('#') === 0 || href.indexOf(location.pathname) === 0) return; + } // Show our spinner on click or submit. node.addEventListener(node.tagName === 'A' ? 'click' : 'submit', () => {