-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
29 lines (24 loc) · 964 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const monthSelect = document.getElementById('month-select');
const tournamentList = document.querySelector('.tournament-list');
const tournaments = Array.from(document.querySelectorAll('.tournament'));
function compareDates(a, b) {
const dateA = new Date(a.dataset.startdate);
const dateB = new Date(b.dataset.startdate);
return dateA - dateB;
}
tournaments.sort(compareDates);
tournaments.forEach(tournament => tournamentList.appendChild(tournament));
monthSelect.addEventListener('change', () => {
const selectedMonth = monthSelect.value;
tournaments.forEach(tournament => {
const tournamentDate = new Date(tournament.dataset.startdate);
const tournamentMonth = tournamentDate.getMonth() + 1;
if (selectedMonth === 'all') {
tournament.style.display = 'block';
} else if (selectedMonth == tournamentMonth) {
tournament.style.display = 'block';
} else {
tournament.style.display = 'none';
}
});
});