Huge restructuring of frontend code. 1.2.0 prerelease

This commit is contained in:
2020-10-24 00:32:14 +02:00
parent b645a1ff94
commit 91a4cea453
12 changed files with 506 additions and 413 deletions

39
js/fullyKiosk.js Normal file
View File

@@ -0,0 +1,39 @@
export const FullyKioskMixin = (C) => class extends C {
get isFully() {
return window.fully !== undefined;
}
constructor() {
super();
if (!this.isFully) return;
this._fullyMotion = false;
this._motionTimeout = undefined;
for (const event of ["screenOn", "screenOff", "pluggedAC", "pluggedUSB", "onBatteryLevelChanged", "unplugged", "networkReconnect"]) {
fully.bind(event, "window.browser_mod.fully_update();");
}
fully.bind("onMotion", "window.browser_mod.fullyMotionTriggered();");
}
fully_update() {
if(!this.isFully) return
this.sendUpdate({fully: {
battery: fully.getBatteryLevel(),
charging: fully.isPlugged(),
motion: this._fullyMotion,
}})
}
fullyMotionTriggered() {
this._fullyMotion = true;
clearTimeout(this._motionTimeout);
this._motionTimeout = setTimeout(() => {
this._fullyMotion = false;
this.fully_update();
}, 5000);
this.fully_update();
}
}