diff --git a/package-lock.json b/package-lock.json index 34bae75..7b28bc8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2288,9 +2288,6 @@ "arm" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2305,9 +2302,6 @@ "arm" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -2322,9 +2316,6 @@ "arm64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2339,9 +2330,6 @@ "arm64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -2356,9 +2344,6 @@ "loong64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2373,9 +2358,6 @@ "ppc64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2390,9 +2372,6 @@ "riscv64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2407,9 +2386,6 @@ "riscv64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -2424,9 +2400,6 @@ "s390x" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ diff --git a/src/index.ts b/src/index.ts index 2c214da..a67df3f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -36,6 +36,13 @@ let currentViewDate = new Date(); let selectedFood: FoodItem | null = null; // review here let currentUser: any | null = null; +type AlternativeResult = { + food: FoodItem; + quantityGrams: number; +}; + +let currentAlternatives: AlternativeResult[] = []; + // Initialize when page loads document.addEventListener('DOMContentLoaded', async function() { await initializeAuth(); @@ -477,11 +484,6 @@ const getFoodItemByName = (foodName: string): FoodItem => { return foodDataSearch[0]; } -type AlternativeResult = { - food: FoodItem; - quantityGrams: number; -}; - function findAlternatives( current: FoodItem, currentQuantityGrams: number, @@ -602,6 +604,7 @@ function updateAlternativesDisplay() { } const alternatives = findAlternatives(selectedFood, grams, foodDatabase); + currentAlternatives = alternatives; const escapeHtml = (text: string): string => text.replace(/&/g, '&').replace(//g, '>') @@ -610,12 +613,27 @@ function updateAlternativesDisplay() { if (alternatives.length === 0) { list.innerHTML = '