« get me outta code hell

content, client: handle random data failing to load - 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:
author(quasar) nebula <qznebula@protonmail.com>2023-11-15 18:56:10 -0400
committer(quasar) nebula <qznebula@protonmail.com>2023-11-15 18:56:58 -0400
commit28371f6e029fb86ba536bf4c20e787dba44d202b (patch)
tree8fef79f97b06d136ccbe920f9729d5dedc984e51 /src/static
parent91f00a36b33d13630ea7a9ac6fcd03110b0f1a73 (diff)
content, client: handle random data failing to load
Diffstat (limited to 'src/static')
-rw-r--r--src/static/client3.js15
-rw-r--r--src/static/site5.css7
2 files changed, 20 insertions, 2 deletions
diff --git a/src/static/client3.js b/src/static/client3.js
index 31eddfe..d2f2bd1 100644
--- a/src/static/client3.js
+++ b/src/static/client3.js
@@ -287,6 +287,7 @@ if (
 ) {
   const dataLoadingLine = document.getElementById('data-loading-line');
   const dataLoadedLine = document.getElementById('data-loaded-line');
+  const dataErrorLine = document.getElementById('data-error-line');
 
   dataLoadingLine.style.display = 'block';
 
@@ -300,8 +301,20 @@ if (
 
       dataLoadingLine.style.display = 'none';
       dataLoadedLine.style.display = 'block';
-    });
+    })
+    .catch(() => {
+      const info = scriptedLinkInfo;
+
+      for (const a of info.randomLinks) {
+        const href = determineRandomLinkHref(a);
+        if (!href) {
+          a.removeAttribute('href');
+        }
+      }
 
+      dataLoadingLine.style.display = 'none';
+      dataErrorLine.style.display = 'block';
+    });
 }
 
 // Data & info card ---------------------------------------
diff --git a/src/static/site5.css b/src/static/site5.css
index 9111f3a..bb83fe6 100644
--- a/src/static/site5.css
+++ b/src/static/site5.css
@@ -793,10 +793,15 @@ html[data-url-key="localized.albumCommentary"] li.no-commentary {
 }
 
 html[data-url-key="localized.listing"][data-url-value0="random"] #data-loading-line,
-html[data-url-key="localized.listing"][data-url-value0="random"] #data-loaded-line {
+html[data-url-key="localized.listing"][data-url-value0="random"] #data-loaded-line,
+html[data-url-key="localized.listing"][data-url-value0="random"] #data-error-line {
   display: none;
 }
 
+html[data-url-key="localized.listing"][data-url-value0="random"] #content a:not([href]) {
+  opacity: 0.7;
+}
+
 /* Images */
 
 .image-container {