From 5a4c6243125078130debc978a1aa86d89a1938af Mon Sep 17 00:00:00 2001 From: vgaNAR6ta Date: Wed, 9 Sep 2026 01:14:33 +0200 Subject: [PATCH] fix bug et meilleure perf import css status --- js/status.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/js/status.js b/js/status.js index e5296bb..e6aa602 100644 --- a/js/status.js +++ b/js/status.js @@ -1,19 +1,15 @@ import { getDocumentShaderSource } from './cuteTexture.js'; export async function loadStatus(){ - const uri = new URL('/status', document.baseURI); + 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"); - 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'); @@ -29,12 +25,18 @@ export async function loadStatus(){ 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); + + 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); - document.head.append(style); target.appendChild(status);