« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/static
diff options
context:
space:
mode:
Diffstat (limited to 'src/static')
-rw-r--r--src/static/js/client.js17
1 files 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)) {