From abf393191c6ca4e8c5548b63646a65110ac0f6b7 Mon Sep 17 00:00:00 2001 From: sthag Date: Sun, 2 Nov 2025 09:18:12 +0100 Subject: [PATCH] style: Reformat and comment --- source/code/hippie/app.js | 7 +++++-- source/code/windows.js | 8 +++----- source/screens/demo/examples/ui/windows.liquid | 2 -- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/source/code/hippie/app.js b/source/code/hippie/app.js index 299dd72..73aa723 100644 --- a/source/code/hippie/app.js +++ b/source/code/hippie/app.js @@ -239,6 +239,7 @@ class TimeDisplay { this.interval = interval || 1000; this.isPaused = false; this.locale = navigator.language || 'en-US'; + this.updateTime(); console.group('Time information'); @@ -251,6 +252,7 @@ class TimeDisplay { return time.toLocaleTimeString(this.locale, this.options); } + // TODO: Zeit nur im Sekundentakt aktualisieren wenn Sekunden angezeigt werden async updateTime() { while (true) { if (!this.isPaused) { @@ -261,12 +263,10 @@ class TimeDisplay { } } - // Method to pause updates pause() { this.isPaused = true; } - // Method to resume updates resume() { this.isPaused = false; } @@ -276,6 +276,7 @@ class DateDisplay { constructor(element, options) { this.element = element; this.options = options || {year: 'numeric', month: 'long', day: 'numeric'}; + this.updateDate(); this.checkForDateChange(); @@ -291,12 +292,14 @@ class DateDisplay { updateDate() { const now = new Date(); + this.element.textContent = this.formatDate(now); } getTimeUntilNextMidnight() { const now = new Date(); const nextMidnight = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1); + return nextMidnight - now; } diff --git a/source/code/windows.js b/source/code/windows.js index e928e97..d28a677 100644 --- a/source/code/windows.js +++ b/source/code/windows.js @@ -210,14 +210,12 @@ class DragAdv { const rect = this.placeholder.getBoundingClientRect(); const windowWidth = window.innerWidth; const windowHeight = window.innerHeight; - const distances = { - left: rect.left, - right: windowWidth - rect.right, top: rect.top, - bottom: windowHeight - rect.bottom + right: windowWidth - rect.right, + bottom: windowHeight - rect.bottom, + left: rect.left }; - const closestEdge = Object.keys(distances).reduce((a, b) => distances[a] < distances[b] ? a : b); this.setPosition(closestEdge, this.barSize); diff --git a/source/screens/demo/examples/ui/windows.liquid b/source/screens/demo/examples/ui/windows.liquid index 90fd8ea..ac1b71f 100644 --- a/source/screens/demo/examples/ui/windows.liquid +++ b/source/screens/demo/examples/ui/windows.liquid @@ -68,11 +68,9 @@ tags: timeDisplay.pause(); console.info('Pause time'); }); - document.getElementById('resumeButton').addEventListener('click', () => { timeDisplay.resume(); console.info('Resume time'); }); - {% endblock %} \ No newline at end of file