From 258ccf84ee6ed7b284e94e37651678c830895a65 Mon Sep 17 00:00:00 2001 From: rene Date: Thu, 4 Jun 2026 18:04:16 +0200 Subject: [PATCH] =?UTF-8?q?Feature:=20Alter=20flie=C3=9Ft=20in=20Kalorienb?= =?UTF-8?q?edarf=20ein=20(Lebensphasen-Faktoren)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Welpe <4 Mon ×3.0, Junghund 4-12 Mon ×2.0 (Wachstum, überschreibt Aktivität), Senior 7+ ×0.90, Hochbetagt 11+ ×0.85 des Erwachsenen-Faktors. Lebensphase wird im Ergebnis angezeigt. SW v1172 --- VERSION | 2 +- backend/static/index.html | 24 ++++++++++++------------ backend/static/js/app.js | 2 +- backend/static/js/pages/ernaehrung.js | 22 +++++++++++++++++++++- backend/static/landing.html | 2 +- backend/static/sw.js | 2 +- 6 files changed, 37 insertions(+), 17 deletions(-) diff --git a/VERSION b/VERSION index a65c2ed..316155c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1171 \ No newline at end of file +1172 \ No newline at end of file diff --git a/backend/static/index.html b/backend/static/index.html index 1a62f6c..a1f5f59 100644 --- a/backend/static/index.html +++ b/backend/static/index.html @@ -86,14 +86,14 @@ Ban Yaro - + - - - - - + + + + + @@ -617,11 +617,11 @@ - - - - - + + + + + @@ -631,7 +631,7 @@ - + diff --git a/backend/static/js/app.js b/backend/static/js/app.js index c739557..f109b72 100644 --- a/backend/static/js/app.js +++ b/backend/static/js/app.js @@ -3,7 +3,7 @@ Router, State-Management, Navigation, Initialisierung. ============================================================ */ -const APP_VER = '1171'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen +const APP_VER = '1172'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen const APP_VERSION = '1.6.0'; // ← semantische Version, wird bei make release gesetzt window.APP_VER = APP_VER; // global verfügbar für andere Module (z.B. offline-indicator) window.APP_VERSION = APP_VERSION; diff --git a/backend/static/js/pages/ernaehrung.js b/backend/static/js/pages/ernaehrung.js index f7fa7cb..5333884 100644 --- a/backend/static/js/pages/ernaehrung.js +++ b/backend/static/js/pages/ernaehrung.js @@ -122,6 +122,18 @@ window.Page_ernaehrung = (() => { return (years > 0 && years < 30) ? Math.round(years * 10) / 10 : ''; } + // Lebensphase aus Alter (Jahre): Welpen/Junghunde brauchen mehr (Wachstum), + // Senioren weniger. `growth` (absoluter RER-Faktor) überschreibt den + // Aktivitäts-Faktor; `mult` skaliert den Erwachsenen-Faktor. + function _lifeStage(alter) { + if (!alter || alter <= 0) return { label: '', mult: 1, growth: null }; + if (alter < 0.34) return { label: '🍼 Welpe (< 4 Mon.) — hoher Wachstumsbedarf', mult: 1, growth: 3.0 }; + if (alter < 1) return { label: '🐶 Junghund (4–12 Mon.) — erhöhter Bedarf', mult: 1, growth: 2.0 }; + if (alter >= 11) return { label: '🐕 Hochbetagt (11+ J.) — reduzierter Bedarf', mult: 0.85, growth: null }; + if (alter >= 7) return { label: '🐕 Senior (7+ J.) — leicht reduzierter Bedarf', mult: 0.90, growth: null }; + return { label: '', mult: 1, growth: null }; + } + function _renderRechner(el) { const dog = _appState.activeDog; @@ -269,6 +281,7 @@ window.Page_ernaehrung = (() => { function _berechne(el) { const gewicht = parseFloat(el.querySelector('#ern-gewicht').value); + const alter = parseFloat(el.querySelector('#ern-alter').value) || 0; const aktivitaet = el.querySelector('[data-akt].active')?.dataset.akt || 'normal'; const kastriert = el.querySelector('[data-kas].active')?.dataset.kas === 'ja'; @@ -284,7 +297,12 @@ window.Page_ernaehrung = (() => { aktiv: { intakt: 1.8, kastriert: 1.6 }, sport: { intakt: 2.1, kastriert: 1.9 }, }; - const kcal = Math.round(rer * faktoren[aktivitaet][kastriert ? 'kastriert' : 'intakt']); + // Lebensphase einrechnen: Welpe/Junghund = Wachstumsfaktor (überschreibt + // Aktivität), Senior = reduzierter Faktor. + const baseFactor = faktoren[aktivitaet][kastriert ? 'kastriert' : 'intakt']; + const stage = _lifeStage(alter); + const factor = stage.growth != null ? stage.growth : baseFactor * stage.mult; + const kcal = Math.round(rer * factor); _showResult(el, kcal); } @@ -297,6 +315,7 @@ window.Page_ernaehrung = (() => { const barf = Math.round(kcal / 1.5); // ~150 kcal/100g const kcalFormatted = kcal.toLocaleString('de-DE'); + const stageLabel = _lifeStage(parseFloat(el.querySelector('#ern-alter')?.value) || 0).label; const resultEl = el.querySelector('#ern-rechner-result'); resultEl.style.display = ''; @@ -306,6 +325,7 @@ window.Page_ernaehrung = (() => { border-radius:var(--radius-lg);margin-bottom:var(--space-4)">
ca. ${kcalFormatted} kcal
pro Tag
+ ${stageLabel ? `
${stageLabel}
` : ''}
diff --git a/backend/static/landing.html b/backend/static/landing.html index 7a08a37..d67ca24 100644 --- a/backend/static/landing.html +++ b/backend/static/landing.html @@ -4,7 +4,7 @@ - + Ban Yaro — Die Hunde-App für Deutschland, Österreich & Schweiz diff --git a/backend/static/sw.js b/backend/static/sw.js index f7baa95..563f4fc 100644 --- a/backend/static/sw.js +++ b/backend/static/sw.js @@ -4,7 +4,7 @@ ============================================================ */ // ← EINZIGE Stelle für die Version — STATIC_ASSETS und CACHE_VERSION leiten sich ab -const VER = '1171'; +const VER = '1172'; const CACHE_VERSION = `by-v${VER}`; const CACHE_STATIC = `${CACHE_VERSION}-static`; const CACHE_TILES = 'ban-yaro-tiles-v1'; // bleibt über SW-Updates erhalten