allow changing the year in stats again

This commit is contained in:
Philipp Hofer 2025-01-07 11:44:56 +01:00
parent 6237340f72
commit 0ebcd5a284

View File

@ -73,4 +73,31 @@
</div> </div>
</div> </div>
</div> </div>
<script>
function getYearFromURL() {
var queryParams = new URLSearchParams(window.location.search);
return queryParams.get('year');
}
function populateYears() {
var select = document.getElementById('yearSelect');
var currentYear = new Date().getFullYear();
var selectedYear = getYearFromURL() || currentYear;
for (var year = 1977; year <= currentYear; year++) {
var option = document.createElement('option');
option.value = option.textContent = year;
if (year == selectedYear) {
option.selected = true;
}
select.appendChild(option);
}
}
function changeYear() {
var selectedYear = document.getElementById('yearSelect').value;
window.location.href = '?year=' + selectedYear;
}
populateYears();
</script>
{% endblock content %} {% endblock content %}