From a038ef2b08bac548ea7b5a31e74467ac93b4516b Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Thu, 30 May 2024 22:27:54 -0300 Subject: client: fix scoped chronology links activating w/o switcher --- src/static/js/client.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/static/js/client.js b/src/static/js/client.js index 49326663..5ff3ab9a 100644 --- a/src/static/js/client.js +++ b/src/static/js/client.js @@ -3001,6 +3001,7 @@ clientSteps.addPageListeners.push(addAdditionalNamesBoxListeners); // Scoped chronology links -------------------------------- const scopedChronologyLinksInfo = initInfo('scopedChronologyLinksInfo', { + switcher: null, containers: null, switcherLinks: null, modes: null, @@ -3013,18 +3014,18 @@ const scopedChronologyLinksInfo = initInfo('scopedChronologyLinksInfo', { function getScopedChronologyLinksReferences() { const info = scopedChronologyLinksInfo; - const switcher = + info.switcher = document.querySelector('.scoped-chronology-switcher'); - if (!switcher) { + if (!info.switcher) { return; } info.containers = - Array.from(switcher.querySelectorAll(':scope > div')); + Array.from(info.switcher.querySelectorAll(':scope > div')); info.switcherLinks = - Array.from(switcher.querySelectorAll('.switcher-link')); + Array.from(info.switcher.querySelectorAll('.switcher-link')); info.modes = info.containers @@ -3038,6 +3039,10 @@ function addScopedChronologyLinksPageHandlers() { const info = scopedChronologyLinksInfo; const {session} = scopedChronologyLinksInfo; + if (!info.switcher) { + return; + } + for (const [index, { container: currentContainer, switcherLink: currentSwitcherLink, @@ -3070,6 +3075,10 @@ function addScopedChronologyLinksPageHandlers() { function mutateScopedChronologyLinksContent() { const info = scopedChronologyLinksInfo; + if (!info.switcher) { + return; + } + const {selectedMode} = info.session; if (info.modes.includes(selectedMode)) { -- cgit 1.3.0-6-gf8a5