diff --git a/app/static/app/css/custom.css b/app/static/app/css/custom.css index 9d124b6..6e0d3e7 100644 --- a/app/static/app/css/custom.css +++ b/app/static/app/css/custom.css @@ -33,8 +33,8 @@ } #header-color-block { - border-bottom-left-radius: 2rem; - border-bottom-right-radius: 2rem; + border-bottom-left-radius: 3rem; + border-bottom-right-radius: 3rem; height: 7vh; } diff --git a/app/static/app/images/pause.png b/app/static/app/images/pause.png new file mode 100644 index 0000000..c29798e Binary files /dev/null and b/app/static/app/images/pause.png differ diff --git a/app/static/app/images/play.png b/app/static/app/images/play.png new file mode 100644 index 0000000..b308694 Binary files /dev/null and b/app/static/app/images/play.png differ diff --git a/app/static/app/images/refresh.png b/app/static/app/images/refresh.png new file mode 100644 index 0000000..3776c25 Binary files /dev/null and b/app/static/app/images/refresh.png differ diff --git a/app/static/app/images/settings.png b/app/static/app/images/settings.png new file mode 100644 index 0000000..8988b5c Binary files /dev/null and b/app/static/app/images/settings.png differ diff --git a/app/static/app/images/stop.png b/app/static/app/images/stop.png new file mode 100644 index 0000000..f4abaa4 Binary files /dev/null and b/app/static/app/images/stop.png differ diff --git a/app/static/app/js/serviceworker.js b/app/static/app/js/serviceworker.js index dced0bf..64dc129 100644 --- a/app/static/app/js/serviceworker.js +++ b/app/static/app/js/serviceworker.js @@ -1,25 +1,14 @@ var staticCacheName = "django-pwa-v" + new Date().getTime(); var filesToCache = [ - '/app', + '/app/home', ]; - -// Cache on install -// self.addEventListener("install", event => { -// this.skipWaiting(); -// event.waitUntil( -// caches.open(staticCacheName) -// .then(cache => { -// return cache.addAll(filesToCache); -// }) -// ) -// }); self.addEventListener("install", event => { this.skipWaiting(); event.waitUntil( caches.open(staticCacheName) .then(cache => { - return fetch('/app') - .then(response => cache.put('/app', new Response(response.body))); + return fetch('/app/home') + .then(response => cache.put('/app/home', new Response(response.body))); }) ) }); @@ -46,7 +35,7 @@ self.addEventListener("fetch", event => { return response || fetch(event.request); }) .catch(() => { - return caches.match('app'); + return caches.match('app/home'); }) ) }); \ No newline at end of file diff --git a/app/static/app/js/timer.js b/app/static/app/js/timer.js new file mode 100644 index 0000000..593d6a8 --- /dev/null +++ b/app/static/app/js/timer.js @@ -0,0 +1,77 @@ +let timerInterval; +const timerDisplay = document.getElementById('timerDisplay'); +const secondsDisplay = document.getElementById('secondsDisplay'); +const startButton = document.getElementById('startTimer'); +const resetButton = document.getElementById('resetTimer'); +const pauseButton = document.getElementById('pauseTimer'); + +// Funktion zum Anzeigen der Zeit +function displayTime(seconds) { + const hours = Math.floor(seconds / 3600); + const minutes = Math.floor((seconds % 3600) / 60); + const secs = seconds % 60; + timerDisplay.textContent = + String(hours).padStart(2, '0') + ":" + + String(minutes).padStart(2, '0'); + secondsDisplay.textContent = + ":" + + String(secs).padStart(2, '0'); +} + +function timerIsRunning() { + document.getElementById('startTimer').classList.add('d-none') + document.getElementById('pauseTimer').classList.remove('d-none') + document.getElementById('resetTimer').classList.remove('d-none') + document.getElementById('timerDisplay').style.color = 'rgb(131,169,96)' +} + +function timerIsReset() { + document.getElementById('startTimer').classList.remove('d-none') + document.getElementById('pauseTimer').classList.add('d-none') + document.getElementById('resetTimer').classList.add('d-none') + document.getElementById('timerDisplay').style.color = 'black' +} + +function timerIsPause() { + document.getElementById('startTimer').classList.remove('d-none') + document.getElementById('pauseTimer').classList.add('d-none') + document.getElementById('timerDisplay').style.color = 'rdb(43,100,110)' +} + +// Timer starten und Startzeit im localStorage speichern +startButton.addEventListener('click', () => { + const startTime = Date.now(); + localStorage.setItem('startTime', startTime); + timerIsRunning(); + startTimer(startTime); +}); + +// Timer zurücksetzen und Speicher leeren +resetButton.addEventListener('click', () => { + clearInterval(timerInterval); + localStorage.removeItem('startTime'); + timerIsReset(); + displayTime(0); +}); + +pauseButton.addEventListener('click', () => { + +}) + +// Timer-Funktion, die die vergangene Zeit seit dem Start berechnet +function startTimer(startTime) { + clearInterval(timerInterval); // Vorherigen Timer stoppen, falls vorhanden + timerInterval = setInterval(() => { + const elapsedSeconds = Math.floor((Date.now() - startTime) / 1000); + displayTime(elapsedSeconds); + }, 1000); +} + +// Überprüfen, ob ein Timer beim Laden der Seite bereits läuft +window.addEventListener('load', () => { + const savedStartTime = localStorage.getItem('startTime'); + if (savedStartTime) { + startTimer(parseInt(savedStartTime)); + timerIsRunning(); + } +}); \ No newline at end of file diff --git a/app/templates/app/base.html b/app/templates/app/base.html index 1a8fb66..5bc1d07 100644 --- a/app/templates/app/base.html +++ b/app/templates/app/base.html @@ -16,8 +16,14 @@
+
+
Timer
-00:00h
+00:00
+
+
+
+ Aktivitäten
+Aktivitäten