Moved status to ici.labolyon.fr
This commit is contained in:
20
js/status.js
20
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 <main> 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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user