mirror of
https://github.com/vladmandic/automatic
synced 2026-09-18 16:54:33 +02:00
update loader
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
async function preloadImages() {
|
||||
const dark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
|
||||
const imagePromises = [];
|
||||
const num = Math.floor(Math.random() * 9) + 1;
|
||||
const num = Math.floor(10 * Math.random());
|
||||
const imageUrls = [
|
||||
`file=html/logo-bg-${dark ? 'dark' : 'light'}.jpg`,
|
||||
`file=html/logo-bg-${num}.jpg`,
|
||||
@@ -23,16 +23,17 @@ async function preloadImages() {
|
||||
}
|
||||
|
||||
async function createSplash() {
|
||||
await preloadImages();
|
||||
const dark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
|
||||
console.log('createSplash', { theme: dark ? 'dark' : 'light' });
|
||||
const num = Math.floor(Math.random() * 7) + 1;
|
||||
const splash = `
|
||||
<div id="splash" class="splash" style="background: ${dark ? 'black' : 'white'}">
|
||||
<div class="loading"><div class="loader"></div></div>
|
||||
<div class="splash-img" alt="logo" style="background-image: url(file=html/logo-bg-${dark ? 'dark' : 'light'}.jpg), url(file=html/logo-bg-${num}.jpg); background-blend-mode: ${dark ? 'darken' : 'lighten'}"></div>
|
||||
</div>`;
|
||||
document.body.insertAdjacentHTML('beforeend', splash);
|
||||
console.log('createSplash', dark);
|
||||
await preloadImages();
|
||||
const imgElement = `<div class="splash-img" alt="logo" style="background-image: url(file=html/logo-bg-${dark ? 'dark' : 'light'}.jpg), url(file=html/logo-bg-${num}.jpg); background-blend-mode: ${dark ? 'darken' : 'lighten'}"></div>`;
|
||||
document.getElementById('splash').insertAdjacentHTML('afterbegin', imgElement);
|
||||
}
|
||||
async function removeSplash() {
|
||||
const splash = document.getElementById('splash');
|
||||
|
||||
Reference in New Issue
Block a user