diff --git a/public/index.php b/public/index.php index a380de0..952e653 100644 --- a/public/index.php +++ b/public/index.php @@ -204,20 +204,31 @@ $news_items = $stmt->fetchAll(); diff --git a/public/js/app.js b/public/js/app.js index be8a33e..397e42f 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -983,6 +983,25 @@ function reverseGeocode(contributionId, lat, lng) { .catch(function () {}); } +// Filters News Items in Sidebar by Search Term +function filterNews() { + const searchTerm = document.getElementById('news-search-input').value.toLowerCase(); + const newsItems = document.querySelectorAll('#news-list .news-item'); + + newsItems.forEach(function (item) { + const title = item.dataset.title || ''; + const content = item.dataset.content || ''; + const author = item.dataset.author || ''; + + // Shows Item if Search Term matches Title, Content or Author + if (!searchTerm || title.indexOf(searchTerm) !== -1 || content.indexOf(searchTerm) !== -1 || author.indexOf(searchTerm) !== -1) { + item.style.display = ''; + } else { + item.style.display = 'none'; + } + }); +} + // ===================================================================== // Block 16: Application Startup