Ajout de l'ouverture du LOL
This commit is contained in:
26
js/status.js
Normal file
26
js/status.js
Normal file
@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Fetch status content and insert main content into provided container
|
||||
* @param {Element} containerEl Container to insert status into
|
||||
*/
|
||||
async function insertStatus(containerEl){
|
||||
|
||||
const baseUrl = new URL("/status/", containerEl.baseURI)
|
||||
const res = await fetch(baseUrl);
|
||||
|
||||
if(!res.ok){
|
||||
console.info(`Network error requesting status : ${res.status} ${res.statusText}`);
|
||||
return;
|
||||
}
|
||||
|
||||
const dom = new DOMParser().parseFromString(await res.text(), "text/html");
|
||||
|
||||
const main = dom.querySelector("main");
|
||||
|
||||
if(!main)
|
||||
throw new Error("Status page does not contain a <main> element");
|
||||
|
||||
containerEl.innerHTML = main.innerHTML;
|
||||
containerEl.className = main.className;
|
||||
}
|
||||
|
||||
insertStatus(document.getElementById("status"))
|
Reference in New Issue
Block a user