From 8bf6cc427a6a67e09da839dac9ee2530e94e582e Mon Sep 17 00:00:00 2001 From: Nils Pukropp Date: Sun, 15 Mar 2026 11:48:33 +0100 Subject: [PATCH] fixed error loading data --- ayto/index.html | 148 ++++++++++++++++++++++++------------------------ 1 file changed, 75 insertions(+), 73 deletions(-) diff --git a/ayto/index.html b/ayto/index.html index 8dd5afe..d829593 100644 --- a/ayto/index.html +++ b/ayto/index.html @@ -233,14 +233,12 @@
- + +
- +
- - -
@@ -275,68 +273,11 @@
- +
- - -
-
- -

2. Truth Booth

-
-
-
- - -
- - -
-
-
- - -
-
- -

3. Matching Night

-
-
-
- -
- Lichter (Beams) -
- - - -
-
- - -
-
-
-
-
- - -
- + -
+ + +
@@ -516,7 +511,6 @@ initialPossibilitiesText.textContent = `${group1Names.length} in Gruppe A • ${group2Names.length} in Gruppe B`; inputSections.classList.remove("hidden"); - inputSections.classList.add("grid"); statusDashboard.classList.remove("hidden"); gridSection.classList.remove("hidden"); @@ -644,7 +638,6 @@ ceremonies: ceremonies.map(c => ({ pairs: c.pairs, beams: c.beams })) }; - // The browser proxy resolves /api/solve to the backend automatically const res = await fetch('/api/solve', { method: 'POST', headers: { 'Content-Type': 'application/json' }, @@ -694,7 +687,7 @@ badgeStyle = 'background: rgba(255,51,51,0.05); color: var(--error); opacity: 0.4;'; textContent = '0%'; } else { - // Dynamic heatmap using CSS color-mix + // Unified heatmap using CSS color-mix const mixColor = `color-mix(in srgb, var(--success) ${prob}%, var(--error))`; badgeStyle = `background: color-mix(in srgb, ${mixColor} 15%, transparent); color: ${mixColor}; font-weight: 800; border: 1px solid color-mix(in srgb, ${mixColor} 30%, transparent);`; } @@ -727,13 +720,22 @@ const s = JSON.parse(ev.target.result); g1NamesText.value = s.group1Names.join('\n'); g2NamesText.value = s.group2Names.join('\n'); - handleSetupContestants(true); // skip initial calc + + // First, setup the contestants but skip auto-calc + handleSetupContestants(true); + + // Second, load truth booths and ceremonies into state truthBooths = s.truthBooths || []; ceremonies = s.ceremonies || []; + + // Third, render the UI for both truthBooths.forEach(renderTruthBoothUI); ceremonies.forEach((c, i) => renderCeremonyUI(c, i + 1)); - handleCalculate(); // Calc once all data is loaded + + // Fourth, trigger ONE final calculation + handleCalculate(); } catch(err) { + console.error(err); showError("Fehler beim Laden der Datei. Ist sie beschädigt?"); } }; @@ -742,7 +744,7 @@ }); // Event Listeners - setupButton.addEventListener("click", handleSetupContestants); + setupButton.addEventListener("click", () => handleSetupContestants()); tbForm.addEventListener("submit", handleAddTruthBooth); ceremonyForm.addEventListener("submit", handleAddCeremony); calculateButton.addEventListener("click", handleCalculate);