Add fullykiosk browser special cases
This commit is contained in:
@@ -1,16 +1,15 @@
|
||||
export const FullyKioskMixin = (C) =>
|
||||
class extends C {
|
||||
get isFully() {
|
||||
export const FullyMixin = (C) => {
|
||||
return class FullyMixinClass extends C {
|
||||
private _fully_screensaver = false;
|
||||
|
||||
get fully() {
|
||||
return window.fully !== undefined;
|
||||
}
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
if (!this.isFully) return;
|
||||
|
||||
this._fullyMotion = false;
|
||||
this._motionTimeout = undefined;
|
||||
if (!this.fully) return;
|
||||
|
||||
for (const ev of [
|
||||
"screenOn",
|
||||
@@ -21,74 +20,49 @@ export const FullyKioskMixin = (C) =>
|
||||
"unplugged",
|
||||
"networkReconnect",
|
||||
"onMotion",
|
||||
"onDaydreamStart",
|
||||
"onDaydreamStop",
|
||||
]) {
|
||||
window.fully.bind(ev, `window.browser_mod.fully_update("${ev}");`);
|
||||
window.fully.bind(ev, `window.browser_mod.fullyEvent("${ev}");`);
|
||||
}
|
||||
|
||||
window.fully.bind(
|
||||
"onScreensaverStart",
|
||||
`window.browser_mod.fully_screensaver = true; window.browser_mod.screen_update();`
|
||||
`window.browser_mod._fully_screensaver = true; window.browser_mod.fullyEvent();`
|
||||
);
|
||||
window.fully.bind(
|
||||
"onScreensaverStop",
|
||||
`window.browser_mod.fully_screensaver = false; window.browser_mod.screen_update();`
|
||||
`window.browser_mod._fully_screensaver = false; window.browser_mod.fullyEvent();`
|
||||
);
|
||||
|
||||
this._keepingAlive = false;
|
||||
return;
|
||||
}
|
||||
|
||||
fully_update(event?) {
|
||||
if (!this.isFully) return;
|
||||
if (event === "screenOn") {
|
||||
window.clearTimeout(this._keepAliveTimer);
|
||||
if (!this._keepingAlive) this.screen_update();
|
||||
} else if (event === "screenOff") {
|
||||
this.screen_update();
|
||||
this._keepingAlive = false;
|
||||
if (this.config.force_stay_awake) {
|
||||
this._keepAliveTimer = window.setTimeout(() => {
|
||||
this._keepingAlive = true;
|
||||
window.fully.turnScreenOn();
|
||||
window.fully.turnScreenOff();
|
||||
}, 270000);
|
||||
}
|
||||
} else if (event === "onMotion") {
|
||||
this.fullyMotionTriggered();
|
||||
get fully_screen() {
|
||||
return this._fully_screensaver === false && window.fully?.getScreenOn();
|
||||
}
|
||||
set fully_screen(state) {
|
||||
if (state) {
|
||||
window.fully?.turnScreenOn();
|
||||
window.fully?.stopScreensaver();
|
||||
} else {
|
||||
window.fully?.turnScreenOff();
|
||||
}
|
||||
|
||||
this.sendUpdate({
|
||||
fully: {
|
||||
battery: window.fully.getBatteryLevel(),
|
||||
charging: window.fully.isPlugged(),
|
||||
motion: this._fullyMotion,
|
||||
ip: window.fully.getIp4Address(),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
startCamera() {
|
||||
if (this._fullyCameraTimer !== undefined) return;
|
||||
this._fullyCameraTimer = window.setInterval(() => {
|
||||
this.sendUpdate({
|
||||
camera: window.fully.getCamshotJpgBase64(),
|
||||
});
|
||||
}, 200);
|
||||
get fully_brightness() {
|
||||
return window.fully?.getScreenBrightness();
|
||||
}
|
||||
stopCamera() {
|
||||
window.clearInterval(this._fullyCameraTimer);
|
||||
this._fullyCameraTimer = undefined;
|
||||
set fully_brightness(br) {
|
||||
window.fully?.setScreenBrightness(br);
|
||||
}
|
||||
|
||||
fullyMotionTriggered() {
|
||||
if (this._keepingAlive) return;
|
||||
this._fullyMotion = true;
|
||||
this.startCamera();
|
||||
clearTimeout(this._motionTimeout);
|
||||
this._motionTimeout = setTimeout(() => {
|
||||
this._fullyMotion = false;
|
||||
this.stopCamera();
|
||||
this.fully_update();
|
||||
}, 5000);
|
||||
this.fully_update();
|
||||
get fully_camera() {
|
||||
return window.fully?.getCamshotJpgBase64();
|
||||
}
|
||||
|
||||
fullyEvent(event = undefined) {
|
||||
this.fireEvent("fully-update", { event });
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user