fix bug et meilleure perf import css status
This commit is contained in:
+13
-11
@@ -1,19 +1,15 @@
|
|||||||
import { getDocumentShaderSource } from './cuteTexture.js';
|
import { getDocumentShaderSource } from './cuteTexture.js';
|
||||||
|
|
||||||
export async function loadStatus(){
|
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 html = await (await fetch(uri, {cache: 'no-store'})).text();
|
||||||
|
|
||||||
const remoteDoc = new DOMParser().parseFromString(html, "text/html");
|
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 shaderSource = getDocumentShaderSource(remoteDoc);
|
||||||
|
|
||||||
let target = document.querySelector('#statuSection');
|
let target = document.querySelector('#statuSection');
|
||||||
@@ -29,12 +25,18 @@ export async function loadStatus(){
|
|||||||
|
|
||||||
let icon = remoteDoc.querySelector('link[rel="icon"]');
|
let icon = remoteDoc.querySelector('link[rel="icon"]');
|
||||||
let style = remoteDoc.querySelector('link[data-import="status-style"]');
|
let style = remoteDoc.querySelector('link[data-import="status-style"]');
|
||||||
let styleFile = style.href.split('/').at(-1);
|
|
||||||
style.href = uri + '/' + styleFile;
|
let newStyle = document.createElement('link');
|
||||||
//console.log("selected style: ", style.href);
|
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(icon);
|
||||||
document.head.append(style);
|
|
||||||
|
|
||||||
target.appendChild(status);
|
target.appendChild(status);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user