diff --git a/static/app.js b/static/app.js index eaefb61..a195e77 100644 --- a/static/app.js +++ b/static/app.js @@ -15,7 +15,7 @@ function saveData() { }); } -let matchViewMode = 'fromLast'; // 'fromLast', 'all', 'future' +let matchViewMode = 'future'; // 'all' or 'future' function renderTable() { const container = document.getElementById('attendance-table'); @@ -64,17 +64,8 @@ function renderTable() { let filteredDates = []; if (matchViewMode === 'all') { filteredDates = data.dates; - } else if (matchViewMode === 'future') { - filteredDates = data.dates.filter(date => parseDate(date) > today); } else { - // Default: show from last played match and all after - const pastDates = data.dates.filter(date => parseDate(date) <= today); - const lastMatch = pastDates.length > 0 ? pastDates.reduce((a, b) => parseDate(a) > parseDate(b) ? a : b) : null; - let found = false; - filteredDates = data.dates.filter(date => { - if (date === lastMatch) found = true; - return found; - }); + filteredDates = data.dates.filter(date => parseDate(date) > today); } // Find closest date to today for scroll let closestIdx = 0; @@ -189,43 +180,20 @@ document.getElementById('add-date').onclick = function() { window.onload = () => { fetchData(); - // Menu bar event listeners document.addEventListener('DOMContentLoaded', () => { - const showAll = document.getElementById('show-all-matches'); - const showFuture = document.getElementById('show-future-matches'); - const dropdown = document.querySelector('.menu-bar .dropdown'); - const dropdownContent = document.getElementById('show-menu-dropdown'); - const showMenuBtn = document.getElementById('show-menu-btn'); - let menuOpen = false; - - function openMenu() { - dropdownContent.style.opacity = '1'; - dropdownContent.style.visibility = 'visible'; - dropdownContent.style.pointerEvents = 'auto'; - showMenuBtn.setAttribute('aria-expanded', 'true'); - menuOpen = true; - } - function closeMenu() { - dropdownContent.style.opacity = ''; - dropdownContent.style.visibility = ''; - dropdownContent.style.pointerEvents = ''; - showMenuBtn.setAttribute('aria-expanded', 'false'); - menuOpen = false; - } - - if (dropdown && dropdownContent && showMenuBtn) { - showMenuBtn.onclick = (e) => { - e.stopPropagation(); - dropdown.classList.toggle('open'); - }; - // Close menu when clicking elsewhere - document.addEventListener('click', (e) => { - if (!dropdown.contains(e.target)) { - dropdown.classList.remove('open'); + const showBtn = document.getElementById('show-matches-btn'); + if (showBtn) { + showBtn.textContent = 'Show All Matches'; + showBtn.onclick = () => { + if (matchViewMode === 'future') { + matchViewMode = 'all'; + showBtn.textContent = 'Show Future Matches'; + } else { + matchViewMode = 'future'; + showBtn.textContent = 'Show All Matches'; } - }); + renderTable(); + }; } - if (showAll) showAll.onclick = () => { matchViewMode = 'all'; renderTable(); if (dropdown) dropdown.classList.remove('open'); }; - if (showFuture) showFuture.onclick = () => { matchViewMode = 'future'; renderTable(); if (dropdown) dropdown.classList.remove('open'); }; }); }; diff --git a/templates/index.html b/templates/index.html index 3fe3a38..c1a8e57 100644 --- a/templates/index.html +++ b/templates/index.html @@ -100,27 +100,16 @@ table { min-width: 400px; } } -