fix inits

This commit is contained in:
MLH
2024-12-22 02:23:48 +01:00
parent d5c697afdf
commit 65a5753f59
9 changed files with 79 additions and 46 deletions

View File

@ -135,12 +135,16 @@ function initLeaves() {
} }
} }
// initialize leaves and add random leaves after the DOM is loaded // initialize leaves and add random leaves
if (!leaves) return; // exit if leaves are disabled function initializeLeaves() {
initLeaves(); if (!leaves) return; // exit if leaves are disabled
toggleAutumn(); initLeaves();
toggleAutumn();
const screenWidth = window.innerWidth; // get the screen width to detect mobile devices const screenWidth = window.innerWidth; // get the screen width to detect mobile devices
if (randomLeaves && (screenWidth > 768 || randomLeavesMobile)) { // add random leaves only on larger screens, unless enabled for mobile devices if (randomLeaves && (screenWidth > 768 || randomLeavesMobile)) { // add random leaves only on larger screens, unless enabled for mobile devices
addRandomLeaves(leafCount); addRandomLeaves(leafCount);
}
} }
initializeLeaves();

View File

@ -109,12 +109,16 @@ function initChristmas() {
} }
} }
// initialize christmas and add random christmas symbols after the DOM is loaded // initialize christmas and add random christmas symbols
if (!christmas) return; // exit if christmas is disabled function initializeChristmas() {
initChristmas(); if (!christmas) return; // exit if christmas is disabled
toggleChristmas(); initChristmas();
toggleChristmas();
const screenWidth = window.innerWidth; // get the screen width to detect mobile devices const screenWidth = window.innerWidth; // get the screen width to detect mobile devices
if (randomChristmas && (screenWidth > 768 || randomChristmasMobile)) { // add random christmas only on larger screens, unless enabled for mobile devices if (randomChristmas && (screenWidth > 768 || randomChristmasMobile)) { // add random christmas only on larger screens, unless enabled for mobile devices
addRandomChristmas(christmasCount); addRandomChristmas(christmasCount);
}
} }
initializeChristmas();

View File

@ -151,7 +151,11 @@ function startFireworks() {
}, intervalOfFireworks); // Interval between fireworks }, intervalOfFireworks); // Interval between fireworks
} }
// Initialize fireworks and add random fireworks after the DOM is loaded // Initialize fireworks and add random fireworks
if (!fireworks) return; // exit if fireworks are disabled function initializeFireworks() {
startFireworks(); if (!fireworks) return; // exit if fireworks are disabled
toggleFirework(); startFireworks();
toggleFirework();
}
initializeFireworks();

View File

@ -122,12 +122,16 @@ function createHalloween() {
} }
} }
// initialize halloween after the DOM is loaded // initialize halloween
if (!halloween) return; // exit if halloween is disabled function initializeHalloween() {
createHalloween(); if (!halloween) return; // exit if halloween is disabled
toggleHalloween(); createHalloween();
toggleHalloween();
const screenWidth = window.innerWidth; // get the screen width to detect mobile devices const screenWidth = window.innerWidth; // get the screen width to detect mobile devices
if (randomSymbols && (screenWidth > 768 || randomSymbolsMobile)) { // add random halloweens only on larger screens, unless enabled for mobile devices if (randomSymbols && (screenWidth > 768 || randomSymbolsMobile)) { // add random halloweens only on larger screens, unless enabled for mobile devices
addRandomSymbols(halloweenCount); addRandomSymbols(halloweenCount);
}
} }
initializeHalloween();

View File

@ -111,12 +111,16 @@ function createHearts() {
} }
// initialize hearts after the DOM is loaded // initialize hearts
if (!hearts) return; // exit if hearts is disabled function initializeHearts() {
createHearts(); if (!hearts) return; // exit if hearts is disabled
toggleHearts(); createHearts();
toggleHearts();
const screenWidth = window.innerWidth; // get the screen width to detect mobile devices const screenWidth = window.innerWidth; // get the screen width to detect mobile devices
if (randomSymbols && (screenWidth > 768 || randomSymbolsMobile)) { // add random heartss only on larger screens, unless enabled for mobile devices if (randomSymbols && (screenWidth > 768 || randomSymbolsMobile)) { // add random heartss only on larger screens, unless enabled for mobile devices
addRandomSymbols(heartsCount); addRandomSymbols(heartsCount);
}
} }
initializeHearts();

View File

@ -1,7 +1,7 @@
// theme-configs.js // theme-configs.js
const automateThemeSelection = false; // Set to false to disable automatic theme selection based on the current month const automateThemeSelection = false; // Set to false to disable automatic theme selection based on the current month
const defaultTheme = 'snowflakes'; // The theme to use if automatic theme selection is disabled const defaultTheme = 'snowfall'; // The theme to use if automatic theme selection is disabled
// theme configurations // theme configurations
const themeConfigs = { const themeConfigs = {

View File

@ -99,6 +99,12 @@ function animateSnowflake(snowflake) {
fall(); fall();
} }
// initialize snowfall after the DOM is loaded // initialize snowfall
if (!snowfall) return; // exit if snowfall is disabled function initializeSnowfall() {
createSnowflakes(); if (!snowfall) {
return; // exit if snowfall is disabled
}
createSnowflakes();
}
initializeSnowfall();

View File

@ -117,12 +117,16 @@ function initSnowflakes() {
} }
} }
// initialize snowflakes and add random snowflakes after the DOM is loaded // initialize snowflakes and add random snowflakes
if (!snowflakes) return; // exit if snowflakes are disabled function initializeSnowflakes() {
initSnowflakes(); if (!snowflakes) return; // exit if snowflakes are disabled
toggleSnowflakes(); initSnowflakes();
toggleSnowflakes();
const screenWidth = window.innerWidth; // get the screen width to detect mobile devices const screenWidth = window.innerWidth; // get the screen width to detect mobile devices
if (randomSnowflakes && (screenWidth > 768 || randomSnowflakesMobile)) { // add random snowflakes only on larger screens, unless enabled for mobile devices if (randomSnowflakes && (screenWidth > 768 || randomSnowflakesMobile)) { // add random snowflakes only on larger screens, unless enabled for mobile devices
addRandomSnowflakes(snowflakeCount); addRandomSnowflakes(snowflakeCount);
}
} }
initializeSnowflakes();

View File

@ -97,7 +97,10 @@ function animateSnowflake(snowflake) {
fall(); fall();
} }
// initialize snowstorm after the DOM is loaded // initialize snowstorm
if (!snowstorm) return; // exit if snowstorm is disabled function initializeSnowstorm() {
createSnowstorm(); if (!snowstorm) return; // exit if snowstorm is disabled
createSnowstorm();
}
initializeSnowstorm();