HabitTracker/templates/index.html

106 lines
3.6 KiB
HTML
Raw Normal View History

2024-01-12 10:57:58 +01:00
{% extends 'layouts/main.html' %}
{% block content %}
<h1>{{ title }}</h1>
2024-01-12 10:57:58 +01:00
<h3>{{ utc_dt }}</h3>
2024-01-23 11:17:24 +01:00
<style>
#heatmap {
display: grid;
grid-template-columns: repeat(7, 0fr); /* 7 Tage in einer Woche */
gap: 5px;
}
2024-01-23 11:17:24 +01:00
.day {
width: 50px; /* Ändere die Breite nach Bedarf */
height: 50px; /* Ändere die Höhe nach Bedarf */
border: 1px solid #ccc;
display: flex;
align-items: center;
justify-content: center;
}
</style>
2024-01-19 10:27:08 +01:00
2024-01-23 11:17:24 +01:00
<div class="row">
2024-01-23 11:17:24 +01:00
<div class="col-md-4 col-12" id="heatmap"></div>
<script>
// Funktion zur Rückgabe des Montagsdatums
function getMonday(date) {
const day = date.getDay();
const diff = date.getDate() - day + (day === 0 ? -6 : 1); // Anpassung für Sonntag
return new Date(date.setDate(diff));
}
2024-01-23 11:17:24 +01:00
// Simulierte Aktivitätsdaten (ersetze dies durch deine echten Daten)
const activityData = [9, 5, 4, 3, 2, 1, 9, 5, 36, 75, 8, 9, 1, 0, 23, 0, 0, 0, 64, 0, 0, 64, 0, 0, 19, 84];
// Funktion zum Erstellen der Heatmap
function createHeatmap(data) {
const heatmapContainer = document.getElementById('heatmap');
// Aktuelles Datum des Montags
const currentDate = new Date();
const mondayDate = getMonday(currentDate);
for (let i = 0; i < 7; i++) {
const dayElement = document.createElement('div');
dayElement.classList.add('day');
dayElement.textContent = currentDate.toLocaleDateString('de-DE', {weekday: 'short'});
heatmapContainer.appendChild(dayElement);
currentDate.setDate(currentDate.getDate() + 1);
}
// Aktuelles Datum des Montags in der neuen linken Spalte
for (let i = 0; i < 7; i++) {
const dayElement = document.createElement('div');
dayElement.classList.add('day');
//dayElement.textContent = mondayDate.toLocaleDateString('de-DE');
heatmapContainer.appendChild(dayElement);
for (let j = 0; j < 4; j++) {
const opacity = data[i * 7 + j] / Math.max(...data); // Berechne die Opazität basierend auf Aktivitätsanzahl
const dayElement = document.createElement('div');
dayElement.classList.add('day');
dayElement.style.backgroundColor = `rgba(0, 255, 0, ${opacity})`;
heatmapContainer.appendChild(dayElement);
}
}
}
2024-01-23 11:17:24 +01:00
// Erstelle die Heatmap mit den simulierten Daten
createHeatmap(activityData);
</script>
2024-01-23 11:17:24 +01:00
<div class="col-md-8 col-12">
<div class="row">
<h2 class="col-10">Task List</h2>
<a class="col-2 btn btn-primary" role="button" href="/habit">
Task erstellen
</a>
2024-01-19 10:27:08 +01:00
</div>
2024-01-23 11:17:24 +01:00
<ul class="task-list row">
{% for habit in habits %}
<li class="row col-md-4">
<div class="col-auto">
<input type="checkbox" class="task-checkbox" id="{{habit.id}}">
</div>
2024-01-19 10:27:08 +01:00
2024-01-23 11:17:24 +01:00
<div class="col" style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis">
{{ habit.name }}
</div>
2024-01-19 10:27:08 +01:00
2024-01-23 11:17:24 +01:00
</li>
2024-01-19 10:27:08 +01:00
2024-01-23 11:17:24 +01:00
<div class="col-md-8" style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis">
{{ habit.note }}
</div>
2024-01-17 11:17:35 +01:00
2024-01-23 11:17:24 +01:00
{% endfor %}
</ul>
</div>
</div>
2024-01-12 10:57:58 +01:00
{% endblock %}