diff --git a/VERSION b/VERSION index 50e2ad9..0b078c5 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1129 \ No newline at end of file +1130 \ No newline at end of file diff --git a/backend/static/index.html b/backend/static/index.html index f171379..fe40e45 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 b162e31..51efb28 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 = '1129'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen +const APP_VER = '1130'; // ← 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/worlds.js b/backend/static/js/worlds.js index c85881f..02b21cf 100644 --- a/backend/static/js/worlds.js +++ b/backend/static/js/worlds.js @@ -981,6 +981,7 @@ window.Worlds = (() => { } let _bgUrl = null; // aktuell gesetztes Hintergrundbild + let _bgBrightness = null; // gemessene Roh-Helligkeit des Bildes (0–255) für adaptive Abdunklung function _isDarkMode() { const t = document.documentElement.getAttribute('data-theme'); @@ -1020,10 +1021,44 @@ window.Worlds = (() => { // Orientierungswechsel → Bild neu setzen window.matchMedia('(orientation: portrait)').addEventListener('change', _applyBgOrientation); - // Theme-Wechsel → Overlay-Intensität anpassen - new MutationObserver(_applyBgOrientation) + // Theme-Wechsel → Overlay-Intensität + adaptive Abdunklung neu anwenden + new MutationObserver(() => { _applyBgOrientation(); _applyAdaptiveDim(); }) .observe(document.documentElement, { attributeFilter: ['data-theme'] }); + // Durchschnittliche Helligkeit (0–255) eines geladenen Bildes via Mini-Canvas. + // Gibt null zurück bei CORS-Tainting oder Fehler (→ Fallback-Abdunklung). + function _measureBrightness(img) { + try { + const c = document.createElement('canvas'); + const w = c.width = 32, h = c.height = 32; + const ctx = c.getContext('2d', { willReadFrequently: true }); + ctx.drawImage(img, 0, 0, w, h); + const data = ctx.getImageData(0, 0, w, h).data; + let sum = 0; + for (let i = 0; i < data.length; i += 4) { + sum += 0.299 * data[i] + 0.587 * data[i + 1] + 0.114 * data[i + 2]; + } + return sum / (data.length / 4); + } catch { return null; } + } + + // Setzt --wbg-dim adaptiv: helles Bild → mehr Abdunklung (Lesbarkeit), + // dunkles Bild → wenig. Im Dark Mode liegt zusätzlich ein 0.45-Overlay + // über dem Bild, daher wirkt es dort dunkler (effektive Helligkeit ↓). + function _applyAdaptiveDim() { + let b = _bgBrightness; + if (b == null) b = 110; // neutraler Default wenn Messung fehlschlug + if (_isDarkMode()) b *= 0.55; // 0.45-Bild-Overlay reduziert sichtbare Helligkeit + let dim; + if (b <= 90) dim = 0.14; + else if (b >= 190) dim = 0.48; + else dim = 0.14 + (b - 90) / 100 * (0.48 - 0.14); + const val = dim.toFixed(2); + ['wp-jetzt', 'wp-hund', 'wp-welt'].forEach(id => { + document.getElementById(id)?.style.setProperty('--wbg-dim', val); + }); + } + function _applyBgImage(url) { const ov = document.getElementById('worlds-overlay'); const track = document.getElementById('worlds-track'); @@ -1033,6 +1068,8 @@ window.Worlds = (() => { toLoad.onload = () => { _hasBgPhoto = true; _bgUrl = url; + _bgBrightness = _measureBrightness(toLoad); + _applyAdaptiveDim(); _applyBgOrientation(); const hint = document.getElementById('wh-photo-hint'); if (hint) { @@ -1054,6 +1091,8 @@ window.Worlds = (() => { } else { _hasBgPhoto = false; _bgUrl = null; + _bgBrightness = 20; // dunkler Fallback-Gradient → minimale Abdunklung + _applyAdaptiveDim(); track.style.backgroundImage = ''; ov.style.backgroundImage = 'linear-gradient(160deg,#1a1f35 0%,#16213e 33%,#1a2535 67%,#0f1921 100%)'; ov.style.backgroundSize = '100% 100%'; diff --git a/backend/static/landing.html b/backend/static/landing.html index 8febaa4..dbcbae3 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 8b38373..fefbf33 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 = '1129'; +const VER = '1130'; const CACHE_VERSION = `by-v${VER}`; const CACHE_STATIC = `${CACHE_VERSION}-static`; const CACHE_TILES = 'ban-yaro-tiles-v1'; // bleibt über SW-Updates erhalten