45 lines
1.2 KiB
JavaScript
45 lines
1.2 KiB
JavaScript
import { getDocumentShaderSource } from './cuteTexture.js';
|
|
|
|
export async function loadStatus(){
|
|
const uri = new URL('/status/', document.baseURI);
|
|
|
|
console.log('folder uri', uri);
|
|
|
|
|
|
const html = await (await fetch(uri, {cache: 'no-store'})).text();
|
|
|
|
const remoteDoc = new DOMParser().parseFromString(html, "text/html");
|
|
|
|
let shaderSource = getDocumentShaderSource(remoteDoc);
|
|
|
|
let target = document.querySelector('#statuSection');
|
|
|
|
let hiddenBtn = target.querySelector('a');
|
|
|
|
hiddenBtn.style.visibility = 'collapse';
|
|
|
|
let status = remoteDoc.querySelector('#lolStatus');
|
|
//console.log('current status:', status);
|
|
|
|
let isOpen = status.innerText.includes('ouvert');
|
|
|
|
let icon = remoteDoc.querySelector('link[rel="icon"]');
|
|
let style = remoteDoc.querySelector('link[data-import="status-style"]');
|
|
|
|
let newStyle = document.createElement('link');
|
|
newStyle.href = new URL(style.getAttribute("href"), uri).href;
|
|
newStyle.rel = "stylesheet";
|
|
if (style.media) newStyle.media = style.media;
|
|
if (style.crossOrigin) newStyle.crossOrigin = style.crossOrigin;
|
|
|
|
console.log("selected style: ", newStyle);
|
|
|
|
document.head.append(newStyle);
|
|
|
|
document.head.append(icon);
|
|
|
|
target.appendChild(status);
|
|
|
|
return { open: isOpen, shaderSource };
|
|
}
|