From 05fa968c2fc7e9de6db72fa7c3c2e147afe5d647 Mon Sep 17 00:00:00 2001 From: EpicKiwi Date: Wed, 16 Aug 2023 01:33:10 +0200 Subject: [PATCH] Moved status to ici.labolyon.fr --- index.html | 2 +- js/status.js | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index a3fc344..dd5a7ec 100644 --- a/index.html +++ b/index.html @@ -57,7 +57,7 @@
- Vérifier si le local est ouvert 🠖 + Vérifier si le local est ouvert 🠖
diff --git a/js/status.js b/js/status.js index 46f600d..9a20425 100644 --- a/js/status.js +++ b/js/status.js @@ -4,7 +4,7 @@ */ async function insertStatus(containerEl){ - const baseUrl = new URL("/status/", containerEl.baseURI) + const baseUrl = containerEl.href; const res = await fetch(baseUrl, {cache:"no-cache"}); if(!res.ok){ @@ -14,12 +14,28 @@ async function insertStatus(containerEl){ const dom = new DOMParser().parseFromString(await res.text(), "text/html"); + + let base = dom.createElement("base"); + base.href = containerEl.href; + dom.head.append(base); + const main = dom.querySelector("main"); if(!main) throw new Error("Status page does not contain a
element"); - containerEl.innerHTML = main.innerHTML; + for(let it of main.querySelectorAll("[href],[src]")){ + if(it.hasAttribute("href")){ + it.href = it.href + } else { + it.src = it.src + } + } + + containerEl.innerHTML = ""; + for(let node of main.childNodes){ + containerEl.append(document.importNode(node, true)); + } containerEl.className = main.className; }