Reverted to Yes No blank version. No extra menus
This commit is contained in:
parent
977fb5bc05
commit
d3a5af2117
@ -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;
|
||||
|
||||
@ -108,9 +108,7 @@
|
||||
<div class="table-container">
|
||||
<div id="attendance-table"></div>
|
||||
</div>
|
||||
<div style="display: flex; justify-content: center; margin-top: 1em;">
|
||||
<button id="show-matches-btn" style="background: #948979; color: #222831; border: none; padding: 0.7em 1.5em; border-radius: 4px; font-weight: bold; font-size: 1em; transition: background 0.2s; cursor: pointer;">Show</button>
|
||||
</div>
|
||||
|
||||
<script src="/static/app.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user