diff --git a/public/index.php b/public/index.php index e39fac9..f1e7224 100644 --- a/public/index.php +++ b/public/index.php @@ -131,9 +131,9 @@ $news_items = $stmt->fetchAll();
@@ -148,17 +148,12 @@ $news_items = $stmt->fetchAll(); @@ -176,9 +171,44 @@ $news_items = $stmt->fetchAll(); + + + + - + - - - - diff --git a/public/js/app.js b/public/js/app.js index 89fb140..f68997b 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -346,7 +346,7 @@ function loadContributions() { layerControl.addOverlay(contributionsLayer, ' Beiträge'); // Update Sidebar List and Statistics updateContributionsList(); - updateStatistics(); + buildCategoryFilter(); }); } @@ -766,7 +766,7 @@ function updateContributionsList() { // Builds HTML if (filtered.length === 0) { - container.innerHTML = 'Keine Beiträge gefunden.
'; + container.innerHTML = 'Keine Beiträge gefunden.
'; return; } @@ -830,22 +830,33 @@ document.getElementById('list-search-input').addEventListener('input', function // Block 12: Sidebar Category Filter and Statistics // ===================================================================== -// Builds Category Filter Checkboxes +// Builds Category Filter Checkboxes with Counts function buildCategoryFilter() { const container = document.getElementById('category-filter'); + + const counts = {}; + contributionsData.forEach(function (f) { + const cat = f.properties.category; + counts[cat] = (counts[cat] || 0) + 1; + }); + + const total = contributionsData.length; let html = ''; for (const key in CATEGORIES) { const cat = CATEGORIES[key]; const checked = activeFilters.indexOf(key) !== -1 ? 'checked' : ''; + const count = counts[key] || 0; - html += '' + - ''; + html += ''; } + html += '' + total + ' Beiträge insgesamt
'; + container.innerHTML = html; } @@ -892,34 +903,6 @@ function toggleCategoryFilter(checkbox) { updateContributionsList(); } -// Updates Statistics in Home Tab -function updateStatistics() { - const container = document.getElementById('stats-container'); - const total = contributionsData.length; - - // Counts per Category - const counts = {}; - contributionsData.forEach(function (f) { - const cat = f.properties.category; - counts[cat] = (counts[cat] || 0) + 1; - }); - - let html = '' + total + ' Beiträge insgesamt
'; - - for (const key in CATEGORIES) { - const cat = CATEGORIES[key]; - const count = counts[key] || 0; - if (count > 0) { - html += '