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
if (!leaves) return; // exit if leaves are disabled
initLeaves();
toggleAutumn();
// initialize leaves and add random leaves
function initializeLeaves() {
if (!leaves) return; // exit if leaves are disabled
initLeaves();
toggleAutumn();
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
addRandomLeaves(leafCount);
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
addRandomLeaves(leafCount);
}
}
initializeLeaves();

View File

@ -109,12 +109,16 @@ function initChristmas() {
}
}
// initialize christmas and add random christmas symbols after the DOM is loaded
if (!christmas) return; // exit if christmas is disabled
initChristmas();
toggleChristmas();
// initialize christmas and add random christmas symbols
function initializeChristmas() {
if (!christmas) return; // exit if christmas is disabled
initChristmas();
toggleChristmas();
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
addRandomChristmas(christmasCount);
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
addRandomChristmas(christmasCount);
}
}
initializeChristmas();

View File

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

View File

@ -122,12 +122,16 @@ function createHalloween() {
}
}
// initialize halloween after the DOM is loaded
if (!halloween) return; // exit if halloween is disabled
createHalloween();
toggleHalloween();
// initialize halloween
function initializeHalloween() {
if (!halloween) return; // exit if halloween is disabled
createHalloween();
toggleHalloween();
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
addRandomSymbols(halloweenCount);
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
addRandomSymbols(halloweenCount);
}
}
initializeHalloween();

View File

@ -111,12 +111,16 @@ function createHearts() {
}
// initialize hearts after the DOM is loaded
if (!hearts) return; // exit if hearts is disabled
createHearts();
toggleHearts();
// initialize hearts
function initializeHearts() {
if (!hearts) return; // exit if hearts is disabled
createHearts();
toggleHearts();
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
addRandomSymbols(heartsCount);
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
addRandomSymbols(heartsCount);
}
}
initializeHearts();

View File

@ -1,7 +1,7 @@
// theme-configs.js
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
const themeConfigs = {

View File

@ -99,6 +99,12 @@ function animateSnowflake(snowflake) {
fall();
}
// initialize snowfall after the DOM is loaded
if (!snowfall) return; // exit if snowfall is disabled
createSnowflakes();
// initialize snowfall
function initializeSnowfall() {
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
if (!snowflakes) return; // exit if snowflakes are disabled
initSnowflakes();
toggleSnowflakes();
// initialize snowflakes and add random snowflakes
function initializeSnowflakes() {
if (!snowflakes) return; // exit if snowflakes are disabled
initSnowflakes();
toggleSnowflakes();
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
addRandomSnowflakes(snowflakeCount);
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
addRandomSnowflakes(snowflakeCount);
}
}
initializeSnowflakes();

View File

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