Refactor birthday.js to improve configuration handling and enhance clarity for symbol counts and confetti settings
This commit is contained in:
@@ -1,11 +1,10 @@
|
|||||||
const config = window.SeasonalsPluginConfig?.Birthday || {};
|
const config = window.SeasonalsPluginConfig?.Birthday || {};
|
||||||
|
|
||||||
const birthday = config.EnableBirthday !== undefined ? config.EnableBirthday : true;
|
const birthday = config.EnableBirthday !== undefined ? config.EnableBirthday : true; // enable/disable birthday symbols
|
||||||
const symbolCount = config.SymbolCount || 5;
|
const symbolCount = config.SymbolCount !== undefined ? config.SymbolCount : 15; // count of balloons
|
||||||
const useRandomSymbols = config.EnableRandomSymbols !== undefined ? config.EnableRandomSymbols : true;
|
const enableDifferentDuration = config.EnableDifferentDuration !== undefined ? config.EnableDifferentDuration : true; // enable different duration for the symbols
|
||||||
const enableRandomMobile = config.EnableRandomSymbolsMobile !== undefined ? config.EnableRandomSymbolsMobile : false;
|
const symbolCountMobile = config.SymbolCountMobile !== undefined ? config.SymbolCountMobile : 5; // count of mobile balloons
|
||||||
const enableDifferentDuration = config.EnableDifferentDuration !== undefined ? config.EnableDifferentDuration : true;
|
const baseConfettiCount = config.ConfettiCount !== undefined ? config.ConfettiCount : 60; // count of confetti
|
||||||
|
|
||||||
|
|
||||||
const birthdayImages = [
|
const birthdayImages = [
|
||||||
'../Seasonals/Resources/birthday_assets/balloon_blue.gif',
|
'../Seasonals/Resources/birthday_assets/balloon_blue.gif',
|
||||||
@@ -142,15 +141,8 @@ function createBirthday() {
|
|||||||
|
|
||||||
// Cake and Garland have been removed
|
// Cake and Garland have been removed
|
||||||
|
|
||||||
const standardCount = 15;
|
|
||||||
const totalSymbols = symbolCount + standardCount;
|
|
||||||
|
|
||||||
let isMobile = window.matchMedia("only screen and (max-width: 768px)").matches;
|
let isMobile = window.matchMedia("only screen and (max-width: 768px)").matches;
|
||||||
let finalCount = totalSymbols;
|
let finalCount = isMobile ? symbolCountMobile : symbolCount;
|
||||||
|
|
||||||
if (isMobile) {
|
|
||||||
finalCount = enableRandomMobile ? totalSymbols : standardCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
const useRandomDuration = enableDifferentDuration !== false;
|
const useRandomDuration = enableDifferentDuration !== false;
|
||||||
|
|
||||||
@@ -254,8 +246,7 @@ function createBirthday() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Party Confetti
|
// Party Confetti
|
||||||
const baseConfettiCount = config.ConfettiCount !== undefined ? config.ConfettiCount : 60;
|
const confettiCount = baseConfettiCount;
|
||||||
const confettiCount = isMobile ? Math.floor(baseConfettiCount / 2) : baseConfettiCount;
|
|
||||||
const allColors = ['#e6194b', '#3cb44b', '#ffe119', '#4363d8', '#f58231', '#911eb4', '#46f0f0', '#f032e6', '#bcf60c', '#fabebe', '#008080', '#e6beff', '#9a6324', '#fffac8', '#800000', '#aaffc3', '#808000', '#ffd8b1', '#000075', '#808080', '#ffffff', '#000000'];
|
const allColors = ['#e6194b', '#3cb44b', '#ffe119', '#4363d8', '#f58231', '#911eb4', '#46f0f0', '#f032e6', '#bcf60c', '#fabebe', '#008080', '#e6beff', '#9a6324', '#fffac8', '#800000', '#aaffc3', '#808000', '#ffd8b1', '#000075', '#808080', '#ffffff', '#000000'];
|
||||||
|
|
||||||
for (let i = 0; i < confettiCount; i++) {
|
for (let i = 0; i < confettiCount; i++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user