Error on missing css file

This commit is contained in:
Henrik 2023-04-23 11:40:07 +02:00
parent 8c9656b799
commit 480e1e17c8

View File

@ -184,18 +184,26 @@ function loadBg(iUrl)
}); });
} }
function loadSkinCSS(cId) function loadSkinCSS(cId) {
{
if (!gId(cId)) // check if element exists if (!gId(cId)) // check if element exists
//This is called by if (cfg.comp.css) loadSkinCSS('skinCss'); but ideally this should return false if the file does not exist. Needs checking on the server side.
{ {
var h = d.getElementsByTagName('head')[0]; var url = (loc?`http://${locip}`:'.') + '/skin.css';
var l = d.createElement('link'); fetch(url)
l.id = cId; .then(response => {
l.rel = 'stylesheet'; if (response.ok) {
l.type = 'text/css'; var h = d.getElementsByTagName('head')[0];
l.href = (loc?`http://${locip}`:'.') + '/skin.css'; var l = d.createElement('link');
l.media = 'all'; l.id = cId;
h.appendChild(l); l.rel = 'stylesheet';
l.type = 'text/css';
l.href = url;
l.media = 'all';
h.appendChild(l);
} else {
console.log('CSS file not found. You can disable CSS file usage in settings to remove this message.');
}
})
} }
} }