43 lines
1.2 KiB
JavaScript
43 lines
1.2 KiB
JavaScript
import { getDocumentShaderSource } from './cuteTexture.js';
|
|
|
|
export async function loadStatus(){
|
|
const uri = new URL('/status', document.baseURI);
|
|
|
|
|
|
const html = await (await fetch(uri, {cache: 'no-store'})).text();
|
|
|
|
const remoteDoc = new DOMParser().parseFromString(html, "text/html");
|
|
|
|
const base = remoteDoc.createElement('base');
|
|
base.href = uri.toString();
|
|
remoteDoc.head.prepend(base);
|
|
|
|
//console.log('selected file:', remoteDoc);
|
|
|
|
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 styleFile = style.href.split('/').at(-1);
|
|
style.href = uri + '/' + styleFile;
|
|
//console.log("selected style: ", style.href);
|
|
|
|
document.head.append(icon);
|
|
document.head.append(style);
|
|
|
|
target.appendChild(status);
|
|
|
|
return { open: isOpen, shaderSource };
|
|
}
|