109 lines
3.0 KiB
Plaintext
109 lines
3.0 KiB
Plaintext
{% import "includes/macros" as macros %}
|
|
|
|
{% extends "base" %}
|
|
|
|
{% block content %}
|
|
|
|
|
|
<div class="max-w-screen-lg w-full">
|
|
<h1 class="h1">
|
|
Statistik
|
|
<select
|
|
id="yearSelect"
|
|
onchange="changeYear()"
|
|
style="
|
|
background: transparent;
|
|
background-image: none;
|
|
text-decoration: underline;
|
|
"
|
|
></select>
|
|
</h1>
|
|
<div class="search-wrapper">
|
|
<label for="name" class="sr-only">Suche</label>
|
|
<input
|
|
type="search"
|
|
name="name"
|
|
id="filter-js"
|
|
class="search-bar"
|
|
placeholder="Suchen nach Namen..."
|
|
/>
|
|
</div>
|
|
|
|
<div id="filter-result-js" class="search-result"></div>
|
|
|
|
<div class="border-r border-l border-gray-200 dark:border-primary-600">
|
|
{% set_global km = 0 %} {% set_global index = 1 %} {% for s in stat %}
|
|
<div
|
|
class="border-t border-gray-200 dark:border-primary-600 {% if loop.last %} border-b {% endif %} bg-white dark:bg-primary-900 text-black dark:text-white flex justify-between items-center px-3 py-1"
|
|
data-filterable="true"
|
|
data-filter="{{ s.name }}"
|
|
>
|
|
<span class="text-sm text-gray-600 dark:text-gray-100 w-10">
|
|
{% if km != s.rowed_km %}
|
|
{{ loop.index }}
|
|
{% set_global index = loop.index %} {% else %}
|
|
{{ index }}
|
|
{% endif %}
|
|
</span>
|
|
<span class="grow">{{ s.name }}</span>
|
|
<span>{{ s.rowed_km }} km</span>
|
|
|
|
{% set_global km = s.rowed_km %}
|
|
</div>
|
|
{% endfor %}
|
|
<div
|
|
class="border-t border-gray-200 dark:border-primary-600 {% if loop.last %} border-b {% endif %} bg-white dark:bg-primary-900 text-black dark:text-white flex justify-between items-center px-3 py-1"
|
|
data-filterable="true"
|
|
data-filter="{{ guest_km.name }}"
|
|
>
|
|
<span class="text-sm text-gray-600 dark:text-gray-100 w-10">
|
|
</span>
|
|
<span class="grow">{{ guest_km.name }}</span>
|
|
<span>{{ guest_km.rowed_km }} km</span>
|
|
|
|
</div>
|
|
</div>
|
|
<div id="container" class="w-full"></div>
|
|
</div>
|
|
|
|
<script>
|
|
{% if personal %}
|
|
const data = [
|
|
{%- for p in personal %}
|
|
{ date: '{{p.date}}', km: {{p.km}} },
|
|
{%- endfor %}
|
|
]
|
|
sessionStorage.setItem('userStats', JSON.stringify(data));
|
|
{% endif %}
|
|
|
|
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;
|
|
}
|
|
|
|
// Call this function when the page loads
|
|
populateYears();
|
|
</script>
|
|
|
|
<script src="/public/logbook.js"></script>
|
|
{% endblock content%}
|