diff --git a/build.js b/build.js index 43223b6..7e7e64c 100644 --- a/build.js +++ b/build.js @@ -141,8 +141,9 @@ function createWidgetJS(css, html, js) { .replace(/document\.querySelectorAll\(/g, 'this.container.querySelectorAll(') // Remove the DOMContentLoaded listener and class instantiation - we'll handle this in the widget wrapper .replace(/document\.addEventListener\('DOMContentLoaded'.*?\n.*?new DogCalorieCalculator.*?\n.*?\}\);/s, '') - // Remove duplicate theme/scale assignments that override options - .replace(/this\.theme = this\.getThemeFromURL\(\) \|\| 'system';\s*\n\s*this\.scale = this\.getScaleFromURL\(\) \|\| 1\.0;/g, '') + // Remove theme/scale assignments that would override widget options + .replace(/this\.theme = this\.getThemeFromURL\(\) \|\| CALCULATOR_CONFIG\.defaultTheme;/g, '') + .replace(/this\.scale = this\.getScaleFromURL\(\) \|\| CALCULATOR_CONFIG\.defaultScale;/g, '') // Add widget initialization methods .replace(/constructor\(\) \{/, `constructor(container, options = {}) { this.container = container; @@ -186,14 +187,14 @@ function createWidgetJS(css, html, js) { // Remove existing theme classes calculatorContainer.classList.remove('theme-light', 'theme-dark', 'theme-system'); // Add the selected theme class - if (['light', 'dark', 'system'].includes(this.options.theme)) { - calculatorContainer.classList.add('theme-' + this.options.theme); + if (['light', 'dark', 'system'].includes(this.theme)) { + calculatorContainer.classList.add('theme-' + this.theme); } } } applyScale() { - const scale = Math.max(0.5, Math.min(2.0, this.options.scale)); + const scale = Math.max(0.5, Math.min(2.0, this.scale)); if (scale !== 1.0) { this.container.style.transform = \`scale(\${scale})\`; this.container.style.transformOrigin = 'top left'; diff --git a/sundog-dog-food-calculator.js b/sundog-dog-food-calculator.js index 291c924..8d8832c 100644 --- a/sundog-dog-food-calculator.js +++ b/sundog-dog-food-calculator.js @@ -2106,8 +2106,8 @@ const CALCULATOR_CONFIG = { this.scale = this.options.scale; this.currentMER = 0; this.isImperial = false; - this.theme = this.getThemeFromURL() || CALCULATOR_CONFIG.defaultTheme; - this.scale = this.getScaleFromURL() || CALCULATOR_CONFIG.defaultScale; + + this.foodSources = []; this.maxFoodSources = CALCULATOR_CONFIG.maxFoodSources; this.mealsPerDay = 2;