style: Reformat and comment

This commit is contained in:
sthag 2025-11-02 09:18:12 +01:00
parent 9d15f22f5d
commit abf393191c
3 changed files with 8 additions and 9 deletions

View file

@ -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;
}

View file

@ -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);

View file

@ -68,11 +68,9 @@ tags:
timeDisplay.pause();
console.info('Pause time');
});
document.getElementById('resumeButton').addEventListener('click', () => {
timeDisplay.resume();
console.info('Resume time');
});
</script>
{% endblock %}