diff --git a/static/app.js b/static/app.js index a195e77..6c167c2 100644 --- a/static/app.js +++ b/static/app.js @@ -15,7 +15,7 @@ function saveData() { }); } -let matchViewMode = 'future'; // 'all' or 'future' + function renderTable() { const container = document.getElementById('attendance-table'); @@ -54,30 +54,19 @@ function renderTable() { // Assume 20xx for years < 100 return new Date(2000 + y, m - 1, d); } - const pastDates = data.dates.filter(date => parseDate(date) <= today); - const futureDates = data.dates.filter(date => parseDate(date) > today); - // Find most recent past date (last match) - const lastMatch = pastDates.length > 0 ? pastDates.reduce((a, b) => parseDate(a) > parseDate(b) ? a : b) : null; - // Find next match (soonest future date) - const nextMatch = futureDates.length > 0 ? futureDates.reduce((a, b) => parseDate(a) < parseDate(b) ? a : b) : null; - // Filter dates based on view mode - let filteredDates = []; - if (matchViewMode === 'all') { - filteredDates = data.dates; - } else { - filteredDates = data.dates.filter(date => parseDate(date) > today); - } - // Find closest date to today for scroll + // (No filtering or extra logic, just render all dates in order) + // Render all dates in original chronological order let closestIdx = 0; let minDiff = Infinity; - filteredDates.forEach((date, rowIdx) => { + data.dates.forEach((date, rowIdx) => { const diff = Math.abs(parseDate(date) - today); if (diff < minDiff) { minDiff = diff; closestIdx = rowIdx; } }); - filteredDates.forEach((date, rowIdx) => { + // Only render all dates in order + data.dates.forEach((date, rowIdx) => { const tr = document.createElement('tr'); if (rowIdx === closestIdx) tr.id = 'current-match-row'; // Date cell @@ -163,37 +152,4 @@ function renderTable() { }, 0); } -document.getElementById('add-date').onclick = function() { - const date = prompt('Enter date (DD/MM/YY):'); - // Check format: DD/MM/YY - const dateRegex = /^\d{2}\/\d{2}\/\d{2}$/; - if (!dateRegex.test(date)) { - alert('Date must be in DD/MM/YY format.'); - return; - } - if (date && !data.dates.includes(date)) { - data.dates.push(date); - saveData(); - renderTable(); - } -}; - -window.onload = () => { - fetchData(); - document.addEventListener('DOMContentLoaded', () => { - 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(); - }; - } - }); -}; +window.onload = fetchData; diff --git a/templates/index.html b/templates/index.html index 4a6c642..bf5af3f 100644 --- a/templates/index.html +++ b/templates/index.html @@ -108,9 +108,7 @@