Refactor halloween.js and marioday.js to enhance clarity and maintainability of configuration handling [skip ci]

This commit is contained in:
CodeDevMLH
2026-02-28 00:00:54 +01:00
parent 9e5feafd64
commit 9d1a268875
2 changed files with 12 additions and 8 deletions

View File

@@ -1,12 +1,12 @@
const config = window.SeasonalsPluginConfig?.Halloween || {}; const config = window.SeasonalsPluginConfig?.Halloween || {};
const halloween = config.EnableHalloween !== undefined ? config.EnableHalloween : true; // enable/disable halloween const halloween = config.EnableHalloween !== undefined ? config.EnableHalloween : true; // enable/disable halloween
const randomSymbols = config.EnableRandomSymbols !== undefined ? config.EnableRandomSymbols : true; // enable more random symbols const randomSymbols = config.EnableRandomSymbols !== undefined ? config.EnableRandomSymbols : true; // enable random symbols
const randomSymbolsMobile = config.EnableRandomSymbolsMobile !== undefined ? config.EnableRandomSymbolsMobile : false; // enable random symbols on mobile devices (Warning: High values may affect performance) const randomSymbolsMobile = config.EnableRandomSymbolsMobile !== undefined ? config.EnableRandomSymbolsMobile : false; // enable random symbols on mobile
const enableDiffrentDuration = config.EnableDifferentDuration !== undefined ? config.EnableDifferentDuration : true; // enable different duration for the random halloween symbols const enableDiffrentDuration = config.EnableDifferentDuration !== undefined ? config.EnableDifferentDuration : true; // enable different durations
const enableSpiders = config.EnableSpiders !== undefined ? config.EnableSpiders : true; const enableSpiders = config.EnableSpiders !== undefined ? config.EnableSpiders : true; // enable/disable spiders
const enableMice = config.EnableMice !== undefined ? config.EnableMice : true; const enableMice = config.EnableMice !== undefined ? config.EnableMice : true; // enable/disable mice
const halloweenCount = config.SymbolCount || 25; // count of random extra symbols const halloweenCount = config.SymbolCount !== undefined ? config.SymbolCount : 25; // count of symbols
const images = [ const images = [
"../Seasonals/Resources/halloween_images/ghost_20x20.png", "../Seasonals/Resources/halloween_images/ghost_20x20.png",

View File

@@ -1,5 +1,9 @@
const config = window.SeasonalsPluginConfig?.MarioDay || {}; const config = window.SeasonalsPluginConfig?.MarioDay || {};
const marioday = config.EnableMarioDay !== undefined ? config.EnableMarioDay : true; const marioday = config.EnableMarioDay !== undefined ? config.EnableMarioDay : true; // enable/disable marioday
const letMarioJump = config.LetMarioJump !== undefined ? config.LetMarioJump : true; // optionally let mario jump occasionally
// Credit: https://gifs.alphacoders.com/gifs/view/2585
const marioImage = '../Seasonals/Resources/mario_assets/mario.gif';
let msgPrinted = false; let msgPrinted = false;
@@ -45,7 +49,7 @@ function createMarioDay(container) {
const mario = document.createElement('img'); const mario = document.createElement('img');
mario.className = 'mario-runner'; mario.className = 'mario-runner';
mario.src = '../Seasonals/Resources/mario_assets/mario.gif'; mario.src = marioImage;
wrapper.appendChild(mario); wrapper.appendChild(mario);
container.appendChild(wrapper); container.appendChild(wrapper);