feat: Update DateDisplay

- formatDate now distinguishes direction
- Update task bar options with hierarchy
- Add direction to options
- Rename setPosition to setOptions
This commit is contained in:
sthag 2025-11-02 10:14:54 +01:00
parent 20b43b8d35
commit 77178886cd
2 changed files with 43 additions and 12 deletions

View file

@ -137,7 +137,14 @@ class DragAdv {
this.isDragging = false;
this.barSize = '64px';
// TODO: Erweitern auf allgemeine Möglichkeiten und dann aus JSON-Datei laden
this.options = options || {year: 'numeric', month: '2-digit', day: '2-digit'};
this.options = options || {
direction: 0,
date: {
year: 'numeric',
month: '2-digit',
day: '2-digit'
}
};
this.init();
}
@ -152,9 +159,9 @@ class DragAdv {
dateElement.id = 'date';
this.element.querySelector('.clock').appendChild(dateElement);
this.date = new DateDisplay(dateElement, this.options);
this.date = new DateDisplay(dateElement, this.options.date);
this.setPosition('bottom');
this.setOptions('bottom');
}
onMouseDown(event) {
@ -228,11 +235,11 @@ class DragAdv {
};
const closestEdge = Object.keys(distances).reduce((a, b) => distances[a] < distances[b] ? a : b);
this.setPosition(closestEdge);
this.date.changeFormat(this.options);
this.setOptions(closestEdge);
this.date.changeFormat(this.options.date, this.options.direction);
}
setPosition(position) {
setOptions(position) {
const attributes = {
top: {
className: 'top',
@ -285,12 +292,14 @@ class DragAdv {
switch (position) {
case 'right':
case 'left':
this.options = {year: '2-digit', month: '2-digit', day: '2-digit'};
this.options.date = {year: '2-digit', month: '2-digit', day: '2-digit'};
this.options.direction = 1;
break;
case 'top':
case 'bottom':
default:
this.options = {year: 'numeric', month: '2-digit', day: '2-digit'};
this.options.date = {year: 'numeric', month: '2-digit', day: '2-digit'};
this.options.direction = 0;
break;
}
}