big update

This commit is contained in:
Daniel Ledda
2023-07-26 22:40:44 +02:00
parent d0af60f7f4
commit 70cc228bcb
23 changed files with 4068 additions and 8812 deletions

View File

@@ -7,12 +7,12 @@ class TimerWidget extends UIComponent {
private readonly display: HTMLElement;
private skeleton: GridWidget;
private nextUpdateTime: number;
private timerRef: number;
private lastUpdateRef: number;
private timerRef: HTMLElement;
private lastUpdateRef: HTMLElement;
constructor(gridProps: GridProps) {
super();
this.display = <this.MainDisplay ctx={this}/>;
this.display = <this.MainDisplay />;
this.skeleton = new GridWidget({
...gridProps,
className: "timer-widget",
@@ -32,20 +32,20 @@ class TimerWidget extends UIComponent {
}
private updateUpdateText() {
this.fromRef(this.lastUpdateRef).innerText = new Date(getAppState().lastUpdateTime * 1000 + getAppState().utcOffset * 60 * 60 * 1000).toLocaleString();
this.lastUpdateRef.innerText = new Date(getAppState().lastUpdateTime * 1000 + getAppState().utcOffset * 60 * 60 * 1000).toLocaleString();
}
private MainDisplay({ ctx }: { ctx: TimerWidget }) {
ctx.timerRef = ctx.makeRef(<div className={"countdown"}/>);
ctx.lastUpdateRef = ctx.makeRef(
private MainDisplay = () => {
this.timerRef = <div className={"countdown"}/>;
this.lastUpdateRef =
<span className={"last-update"}>
{new Date(getAppState().lastUpdateTime).toLocaleString()}
</span>);
</span>;
return (<div>
{ctx.fromRef(ctx.timerRef)}
{this.timerRef}
<div>
<div className={"last-update"}>Last update was at:</div>
<div>{ctx.fromRef(ctx.lastUpdateRef)}</div>
<div>{this.lastUpdateRef}</div>
</div>
</div>);
}
@@ -53,9 +53,9 @@ class TimerWidget extends UIComponent {
private refreshTimer() {
const now = new Date().getTime() / 1000;
if (now <= this.nextUpdateTime) {
this.fromRef(this.timerRef).innerText = `${(this.nextUpdateTime - now).toFixed(2)}s`;
this.timerRef.innerText = `${(this.nextUpdateTime - now).toFixed(2)}s`;
} else {
this.fromRef(this.timerRef).innerText = "0.00s";
this.timerRef.innerText = "0.00s";
}
}
@@ -64,4 +64,4 @@ class TimerWidget extends UIComponent {
}
}
export default TimerWidget;
export default TimerWidget;