diff --git a/wled00/data/common.js b/wled00/data/common.js index 6e72428d56..5f73c946d8 100644 --- a/wled00/data/common.js +++ b/wled00/data/common.js @@ -51,6 +51,38 @@ function tooltip(cont=null) { }); }); }; +// sequential loading of external resources (JS or CSS) with retry, calls init() when done +function loadResources(files, init) { + let i = 0; + const loadNext = () => { + if (i >= files.length) { + if (init) { + d.documentElement.style.visibility = 'visible'; // make page visible after all files are loaded if it was hidden (prevent ugly display) + d.readyState === 'complete' ? init() : window.addEventListener('load', init); + } + return; + } + const file = files[i++]; + const isCSS = file.endsWith('.css'); + const el = d.createElement(isCSS ? 'link' : 'script'); + if (isCSS) { + el.rel = 'stylesheet'; + el.href = file; + const st = d.head.querySelector('style'); + if (st) d.head.insertBefore(el, st); // insert before any - -
+ \ No newline at end of file diff --git a/wled00/data/liveviewws2D.htm b/wled00/data/liveviewws2D.htm index a077cb5fef..91f63739cf 100644 --- a/wled00/data/liveviewws2D.htm +++ b/wled00/data/liveviewws2D.htm @@ -10,11 +10,18 @@ margin: 0; } - - + diff --git a/wled00/data/settings_2D.htm b/wled00/data/settings_2D.htm index 5c7e66e41d..63ea4a60bf 100644 --- a/wled00/data/settings_2D.htm +++ b/wled00/data/settings_2D.htm @@ -4,11 +4,20 @@