10 years later #1
3 changed files with 8 additions and 9 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -68,11 +68,9 @@ tags:
|
|||
timeDisplay.pause();
|
||||
console.info('Pause time');
|
||||
});
|
||||
|
||||
document.getElementById('resumeButton').addEventListener('click', () => {
|
||||
timeDisplay.resume();
|
||||
console.info('Resume time');
|
||||
});
|
||||
|
||||
</script>
|
||||
{% endblock %}
|
||||
Loading…
Add table
Add a link
Reference in a new issue