initial mvc concept

This commit is contained in:
2024-12-11 21:01:11 +01:00
parent 4a8e0188b3
commit 8bd2cb72d0
14 changed files with 922 additions and 808 deletions

View File

@@ -0,0 +1,34 @@
declare var PUBLIC_URL: string;
export class TimeView {
esp_time: HTMLDivElement
rtc_time: HTMLDivElement
browser_time: HTMLDivElement
sync: HTMLButtonElement
constructor() {
this.esp_time = document.getElementById("esp_time") as HTMLDivElement;
this.rtc_time = document.getElementById("rtc_time") as HTMLDivElement;
this.browser_time = document.getElementById("browser_time") as HTMLDivElement;
this.sync = document.getElementById("time_upload") as HTMLButtonElement;
this.sync.onclick = this.syncTimeFromBrowser;
}
update(native: string, rtc: string) {
this.esp_time.innerText = native;
this.rtc_time.innerText = rtc;
var date = new Date();
this.browser_time.innerText = date.toISOString();
}
syncTimeFromBrowser() {
var value: SetTime = {
time: new Date().toISOString()
}
var pretty = JSON.stringify(value, undefined, 1);
fetch(PUBLIC_URL + "/time", {
method: "POST",
body: pretty
})
}
}