]> Lady’s Gitweb - x_status_git/commitdiff
Fix index.html to only fetch topics once
authorLady <redacted>
Sat, 16 Dec 2023 19:35:21 +0000 (14:35 -0500)
committerLady <redacted>
Sat, 23 Dec 2023 20:17:52 +0000 (15:17 -0500)
index.html

index 44698ed810095a5144735f47d9b1b24d65656164..3db74467c734bc6894be84a591800dbd12778433 100644 (file)
@@ -25,10 +25,8 @@ footer small{ Font-Size: Inherit; Font-Style: Italic }
 const parser = new DOMParser
 document.title = location.hostname
 document.documentElement.querySelector("body>h1").textContent = location.hostname
-const renderLatest = (path, container) => fetch(`${path}.jsonld`)
-.then($ => $.json())
-.then(meta => {
-  const { items } = meta
+const renderLatest = (meta, container) => {
+  const { feed, items } = meta
   const status = items.pop()
   const src = status.content
   const { documentElement: article } = parser.parseFromString(src, "application/xhtml+xml")
@@ -57,10 +55,12 @@ const renderLatest = (path, container) => fetch(`${path}.jsonld`)
     summary.textContent = title
     details.append(...document.importNode(article, true).childNodes)
     container.replaceChildren(wrapper, footer) }
-  else container.replaceChildren(document.importNode(article, true), footer) })
+  else container.replaceChildren(document.importNode(article, true), footer) }
 fetch("statuses.jsonld")
 .then($ => $.json())
-.then(meta => renderLatest(meta.current, document.getElementById("status")))
+.then(meta => fetch(`${meta.current}.jsonld`))
+.then($ => $.json())
+.then(meta => renderLatest(meta, document.getElementById("status")))
 fetch("topics.jsonld")
 .then($ => $.json())
 .then(meta => {
@@ -73,6 +73,5 @@ fetch("topics.jsonld")
       section.appendChild(document.createElement("h3")).textContent = topic.subject
       const div = section.appendChild(document.createElement("div"))
       div.className = "STATUS"
-      renderLatest(new URL(topic["@id"]).pathname, div)
-    }) } })
+      renderLatest(topic, div) }) } })
 </SCRIPT>
This page took 0.025052 seconds and 4 git commands to generate.