Autoformating and cleanup
This commit is contained in:
parent
e4a65f3077
commit
a3cd0c9fd6
@ -644,7 +644,9 @@ const ConnectionMixin = (SuperClass) => {
|
|||||||
constructor() {
|
constructor() {
|
||||||
super(...arguments);
|
super(...arguments);
|
||||||
this.connected = false;
|
this.connected = false;
|
||||||
this.connectionPromise = new Promise(resolve => { this._connectionResolve = resolve; });
|
this.connectionPromise = new Promise((resolve) => {
|
||||||
|
this._connectionResolve = resolve;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
LOG(...args) {
|
LOG(...args) {
|
||||||
const dt = new Date();
|
const dt = new Date();
|
||||||
@ -787,12 +789,13 @@ const ConnectionMixin = (SuperClass) => {
|
|||||||
const oldID = localStorage[ID_STORAGE_KEY];
|
const oldID = localStorage[ID_STORAGE_KEY];
|
||||||
localStorage[ID_STORAGE_KEY] = id;
|
localStorage[ID_STORAGE_KEY] = id;
|
||||||
this.fireEvent("browser-mod-config-update");
|
this.fireEvent("browser-mod-config-update");
|
||||||
if (((_a = this.devices) === null || _a === void 0 ? void 0 : _a[oldID]) !== undefined && ((_b = this.devices) === null || _b === void 0 ? void 0 : _b[this.deviceID]) === undefined) {
|
if (((_a = this.devices) === null || _a === void 0 ? void 0 : _a[oldID]) !== undefined &&
|
||||||
|
((_b = this.devices) === null || _b === void 0 ? void 0 : _b[this.deviceID]) === undefined) {
|
||||||
(async () => {
|
(async () => {
|
||||||
await this.connection.sendMessage({
|
await this.connection.sendMessage({
|
||||||
type: "browser_mod/reregister",
|
type: "browser_mod/reregister",
|
||||||
deviceID: oldID,
|
deviceID: oldID,
|
||||||
data: Object.assign(Object.assign({}, this.devices[oldID]), { deviceID: this.deviceID })
|
data: Object.assign(Object.assign({}, this.devices[oldID]), { deviceID: this.deviceID }),
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
@ -808,7 +811,7 @@ const ScreenSaverMixin = (SuperClass) => {
|
|||||||
super();
|
super();
|
||||||
this._listeners = {};
|
this._listeners = {};
|
||||||
this._brightness = 255;
|
this._brightness = 255;
|
||||||
const panel = this._panel = document.createElement("div");
|
const panel = (this._panel = document.createElement("div"));
|
||||||
panel.setAttribute("browser-mod", "");
|
panel.setAttribute("browser-mod", "");
|
||||||
panel.attachShadow({ mode: "open" });
|
panel.attachShadow({ mode: "open" });
|
||||||
const styleEl = document.createElement("style");
|
const styleEl = document.createElement("style");
|
||||||
@ -926,7 +929,7 @@ const MediaPlayerMixin = (SuperClass) => {
|
|||||||
muted: this.player.muted,
|
muted: this.player.muted,
|
||||||
src: this.player.src,
|
src: this.player.src,
|
||||||
state,
|
state,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -3,18 +3,21 @@ import voluptuous as vol
|
|||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
|
|
||||||
from homeassistant.components.websocket_api import (
|
from homeassistant.components.websocket_api import (
|
||||||
websocket_command,
|
|
||||||
result_message,
|
|
||||||
event_message,
|
event_message,
|
||||||
async_register_command,
|
async_register_command,
|
||||||
)
|
)
|
||||||
|
|
||||||
from homeassistant.components import websocket_api
|
from homeassistant.components import websocket_api
|
||||||
|
|
||||||
from .const import WS_CONNECT, WS_REGISTER, WS_UNREGISTER, WS_REREGISTER, WS_UPDATE, DOMAIN
|
from .const import (
|
||||||
from .helpers import get_devices, create_entity, get_config, is_setup_complete
|
WS_CONNECT,
|
||||||
|
WS_REGISTER,
|
||||||
|
WS_UNREGISTER,
|
||||||
|
WS_REREGISTER,
|
||||||
|
WS_UPDATE,
|
||||||
|
DOMAIN,
|
||||||
|
)
|
||||||
|
|
||||||
from .coordinator import Coordinator
|
|
||||||
from .device import getDevice, deleteDevice
|
from .device import getDevice, deleteDevice
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
@ -42,14 +45,11 @@ async def async_setup_connection(hass):
|
|||||||
dev = getDevice(hass, deviceID)
|
dev = getDevice(hass, deviceID)
|
||||||
dev.update_settings(hass, store.get_device(deviceID).asdict())
|
dev.update_settings(hass, store.get_device(deviceID).asdict())
|
||||||
dev.connection = (connection, msg["id"])
|
dev.connection = (connection, msg["id"])
|
||||||
await store.set_device(deviceID,
|
await store.set_device(
|
||||||
last_seen=datetime.now(
|
deviceID, last_seen=datetime.now(tz=timezone.utc).isoformat()
|
||||||
tz=timezone.utc
|
)
|
||||||
).isoformat()
|
|
||||||
)
|
|
||||||
listener(store.asdict())
|
listener(store.asdict())
|
||||||
|
|
||||||
|
|
||||||
@websocket_api.websocket_command(
|
@websocket_api.websocket_command(
|
||||||
{
|
{
|
||||||
vol.Required("type"): WS_REGISTER,
|
vol.Required("type"): WS_REGISTER,
|
||||||
@ -60,12 +60,9 @@ async def async_setup_connection(hass):
|
|||||||
async def handle_register(hass, connection, msg):
|
async def handle_register(hass, connection, msg):
|
||||||
deviceID = msg["deviceID"]
|
deviceID = msg["deviceID"]
|
||||||
store = hass.data[DOMAIN]["store"]
|
store = hass.data[DOMAIN]["store"]
|
||||||
await store.set_device(deviceID,
|
await store.set_device(deviceID, enabled=True)
|
||||||
enabled=True
|
|
||||||
)
|
|
||||||
connection.send_result(msg["id"])
|
connection.send_result(msg["id"])
|
||||||
|
|
||||||
|
|
||||||
@websocket_api.websocket_command(
|
@websocket_api.websocket_command(
|
||||||
{
|
{
|
||||||
vol.Required("type"): WS_UNREGISTER,
|
vol.Required("type"): WS_UNREGISTER,
|
||||||
@ -117,7 +114,6 @@ async def async_setup_connection(hass):
|
|||||||
deviceSettings.update(data)
|
deviceSettings.update(data)
|
||||||
await store.set_device(deviceID, **deviceSettings)
|
await store.set_device(deviceID, **deviceSettings)
|
||||||
|
|
||||||
|
|
||||||
@websocket_api.websocket_command(
|
@websocket_api.websocket_command(
|
||||||
{
|
{
|
||||||
vol.Required("type"): WS_UPDATE,
|
vol.Required("type"): WS_UPDATE,
|
||||||
@ -129,16 +125,14 @@ async def async_setup_connection(hass):
|
|||||||
async def handle_update(hass, connection, msg):
|
async def handle_update(hass, connection, msg):
|
||||||
deviceID = msg["deviceID"]
|
deviceID = msg["deviceID"]
|
||||||
store = hass.data[DOMAIN]["store"]
|
store = hass.data[DOMAIN]["store"]
|
||||||
devices = hass.data[DOMAIN]["devices"]
|
|
||||||
|
|
||||||
if store.get_device(deviceID).enabled:
|
if store.get_device(deviceID).enabled:
|
||||||
dev = getDevice(hass, deviceID)
|
dev = getDevice(hass, deviceID)
|
||||||
dev.data.update(msg.get("data", {}))
|
dev.data.update(msg.get("data", {}))
|
||||||
dev.coordinator.async_set_updated_data(dev.data)
|
dev.coordinator.async_set_updated_data(dev.data)
|
||||||
|
|
||||||
|
|
||||||
async_register_command(hass, handle_connect)
|
async_register_command(hass, handle_connect)
|
||||||
async_register_command(hass, handle_register)
|
async_register_command(hass, handle_register)
|
||||||
async_register_command(hass, handle_unregister)
|
async_register_command(hass, handle_unregister)
|
||||||
async_register_command(hass, handle_reregister)
|
async_register_command(hass, handle_reregister)
|
||||||
async_register_command(hass, handle_update)
|
async_register_command(hass, handle_update)
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.helpers.update_coordinator import (CoordinatorEntity, DataUpdateCoordinator, UpdateFailed)
|
from homeassistant.helpers.update_coordinator import (
|
||||||
|
DataUpdateCoordinator,
|
||||||
|
)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
class Coordinator(DataUpdateCoordinator):
|
|
||||||
|
|
||||||
|
class Coordinator(DataUpdateCoordinator):
|
||||||
def __init__(self, hass, deviceID):
|
def __init__(self, hass, deviceID):
|
||||||
super().__init__(
|
super().__init__(
|
||||||
hass,
|
hass,
|
||||||
|
@ -1,78 +1,15 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.helpers.entity import Entity, async_generate_entity_id
|
|
||||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
DATA_DEVICES,
|
|
||||||
DATA_ALIASES,
|
|
||||||
DATA_ADDERS,
|
|
||||||
CONFIG_DEVICES,
|
|
||||||
DATA_CONFIG,
|
|
||||||
CONFIG_PREFIX,
|
|
||||||
CONFIG_DISABLE,
|
|
||||||
CONFIG_DISABLE_ALL,
|
|
||||||
DATA_SETUP_COMPLETE,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
from .coordinator import Coordinator
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def get_devices(hass):
|
|
||||||
return hass.data[DOMAIN][DATA_DEVICES]
|
|
||||||
|
|
||||||
|
|
||||||
def get_alias(hass, deviceID):
|
|
||||||
for k, v in hass.data[DOMAIN][DATA_ALIASES].items():
|
|
||||||
if v == deviceID:
|
|
||||||
return k
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def get_config(hass, deviceID):
|
|
||||||
config = hass.data[DOMAIN][DATA_CONFIG].get(CONFIG_DEVICES, {})
|
|
||||||
return config.get(deviceID, config.get(deviceID.replace("-", "_"), {}))
|
|
||||||
|
|
||||||
|
|
||||||
def create_entity(hass, platform, deviceID, connection):
|
|
||||||
conf = get_config(hass, deviceID)
|
|
||||||
if conf and (
|
|
||||||
platform in conf.get(CONFIG_DISABLE, [])
|
|
||||||
or CONFIG_DISABLE_ALL in conf.get(CONFIG_DISABLE, [])
|
|
||||||
):
|
|
||||||
return None
|
|
||||||
if not conf and (
|
|
||||||
platform in hass.data[DOMAIN][DATA_CONFIG].get(CONFIG_DISABLE, [])
|
|
||||||
or CONFIG_DISABLE_ALL in hass.data[DOMAIN][DATA_CONFIG].get(CONFIG_DISABLE, [])
|
|
||||||
):
|
|
||||||
return None
|
|
||||||
adder = hass.data[DOMAIN][DATA_ADDERS].get(platform)
|
|
||||||
if not adder:
|
|
||||||
return None
|
|
||||||
entity = adder(hass, deviceID, connection, get_alias(hass, deviceID))
|
|
||||||
return entity
|
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, async_add_devices, platform, cls):
|
|
||||||
if platform in hass.data[DOMAIN][DATA_ADDERS]:
|
|
||||||
return True
|
|
||||||
|
|
||||||
def adder(hass, deviceID, connection, alias=None):
|
|
||||||
entity = cls(hass, connection, deviceID, alias)
|
|
||||||
async_add_devices([entity])
|
|
||||||
return entity
|
|
||||||
|
|
||||||
hass.data[DOMAIN][DATA_ADDERS][platform] = adder
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
def is_setup_complete(hass):
|
|
||||||
return hass.data[DOMAIN][DATA_SETUP_COMPLETE]
|
|
||||||
|
|
||||||
|
|
||||||
class BrowserModEntity(CoordinatorEntity):
|
class BrowserModEntity(CoordinatorEntity):
|
||||||
def __init__(self, coordinator, deviceID, name):
|
def __init__(self, coordinator, deviceID, name):
|
||||||
super().__init__(coordinator)
|
super().__init__(coordinator)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
from homeassistant.components.light import LightEntity, ColorMode
|
from homeassistant.components.light import LightEntity, ColorMode
|
||||||
|
|
||||||
from .helpers import setup_platform, BrowserModEntity
|
from .helpers import BrowserModEntity
|
||||||
from .const import DOMAIN, DATA_ADDERS
|
from .const import DOMAIN, DATA_ADDERS
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import logging
|
|
||||||
from homeassistant.components import media_source
|
from homeassistant.components import media_source
|
||||||
from homeassistant.components.media_player import (
|
from homeassistant.components.media_player import (
|
||||||
SUPPORT_PLAY,
|
SUPPORT_PLAY,
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
import logging
|
import logging
|
||||||
import attr
|
import attr
|
||||||
from dataclasses import dataclass
|
|
||||||
|
|
||||||
from homeassistant.loader import bind_hass
|
|
||||||
|
|
||||||
STORAGE_VERSION = 1
|
STORAGE_VERSION = 1
|
||||||
STORAGE_KEY = "browser_mod.storage"
|
STORAGE_KEY = "browser_mod.storage"
|
||||||
@ -71,8 +68,8 @@ class BrowserModStore:
|
|||||||
|
|
||||||
async def updated(self):
|
async def updated(self):
|
||||||
self.dirty = True
|
self.dirty = True
|
||||||
for l in self.listeners:
|
for listener in self.listeners:
|
||||||
l(attr.asdict(self.data))
|
listener(attr.asdict(self.data))
|
||||||
await self.save()
|
await self.save()
|
||||||
|
|
||||||
def asdict(self):
|
def asdict(self):
|
||||||
|
@ -9,7 +9,9 @@ export const ConnectionMixin = (SuperClass) => {
|
|||||||
private _data;
|
private _data;
|
||||||
public connected = false;
|
public connected = false;
|
||||||
private _connectionResolve;
|
private _connectionResolve;
|
||||||
public connectionPromise = new Promise(resolve => { this._connectionResolve = resolve; });
|
public connectionPromise = new Promise((resolve) => {
|
||||||
|
this._connectionResolve = resolve;
|
||||||
|
});
|
||||||
|
|
||||||
LOG(...args) {
|
LOG(...args) {
|
||||||
const dt = new Date();
|
const dt = new Date();
|
||||||
@ -23,7 +25,7 @@ export const ConnectionMixin = (SuperClass) => {
|
|||||||
private incoming_message(msg) {
|
private incoming_message(msg) {
|
||||||
if (msg.command) {
|
if (msg.command) {
|
||||||
this.LOG("Command:", msg);
|
this.LOG("Command:", msg);
|
||||||
this.fireEvent(`command-${msg.command}`, msg)
|
this.fireEvent(`command-${msg.command}`, msg);
|
||||||
} else if (msg.result) {
|
} else if (msg.result) {
|
||||||
this.update_config(msg.result);
|
this.update_config(msg.result);
|
||||||
}
|
}
|
||||||
@ -103,7 +105,6 @@ export const ConnectionMixin = (SuperClass) => {
|
|||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private async _reregister(newData = {}) {
|
private async _reregister(newData = {}) {
|
||||||
await this.connection.sendMessage({
|
await this.connection.sendMessage({
|
||||||
type: "browser_mod/reregister",
|
type: "browser_mod/reregister",
|
||||||
@ -165,7 +166,10 @@ export const ConnectionMixin = (SuperClass) => {
|
|||||||
|
|
||||||
this.fireEvent("browser-mod-config-update");
|
this.fireEvent("browser-mod-config-update");
|
||||||
|
|
||||||
if (this.devices?.[oldID] !== undefined && this.devices?.[this.deviceID] === undefined) {
|
if (
|
||||||
|
this.devices?.[oldID] !== undefined &&
|
||||||
|
this.devices?.[this.deviceID] === undefined
|
||||||
|
) {
|
||||||
(async () => {
|
(async () => {
|
||||||
await this.connection.sendMessage({
|
await this.connection.sendMessage({
|
||||||
type: "browser_mod/reregister",
|
type: "browser_mod/reregister",
|
||||||
@ -173,9 +177,9 @@ export const ConnectionMixin = (SuperClass) => {
|
|||||||
data: {
|
data: {
|
||||||
...this.devices[oldID],
|
...this.devices[oldID],
|
||||||
deviceID: this.deviceID,
|
deviceID: this.deviceID,
|
||||||
}
|
},
|
||||||
})
|
});
|
||||||
})()
|
})();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Send update to backend to update device
|
// TODO: Send update to backend to update device
|
||||||
@ -183,4 +187,4 @@ export const ConnectionMixin = (SuperClass) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return BrowserModConnection;
|
return BrowserModConnection;
|
||||||
}
|
};
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
export const MediaPlayerMixin = (SuperClass) => {
|
export const MediaPlayerMixin = (SuperClass) => {
|
||||||
return class MediaPlayerMixinClass extends SuperClass {
|
return class MediaPlayerMixinClass extends SuperClass {
|
||||||
|
|
||||||
public player;
|
public player;
|
||||||
private _player_enabled;
|
private _player_enabled;
|
||||||
|
|
||||||
@ -14,7 +13,9 @@ export const MediaPlayerMixin = (SuperClass) => {
|
|||||||
this.player.addEventListener(ev, () => this._player_update());
|
this.player.addEventListener(ev, () => this._player_update());
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener("pointerdown", () => {
|
window.addEventListener(
|
||||||
|
"pointerdown",
|
||||||
|
() => {
|
||||||
this._player_enabled = true;
|
this._player_enabled = true;
|
||||||
if (!this.player.ended) this.player.play();
|
if (!this.player.ended) this.player.play();
|
||||||
},
|
},
|
||||||
@ -26,7 +27,9 @@ export const MediaPlayerMixin = (SuperClass) => {
|
|||||||
this.player.src = ev.detail.media_content_id;
|
this.player.src = ev.detail.media_content_id;
|
||||||
this.player.play();
|
this.player.play();
|
||||||
});
|
});
|
||||||
this.addEventListener("command-player-pause", (ev) => this.player.pause());
|
this.addEventListener("command-player-pause", (ev) =>
|
||||||
|
this.player.pause()
|
||||||
|
);
|
||||||
this.addEventListener("command-player-stop", (ev) => {
|
this.addEventListener("command-player-stop", (ev) => {
|
||||||
this.player.src = null;
|
this.player.src = null;
|
||||||
this.player.pause();
|
this.player.pause();
|
||||||
@ -38,34 +41,30 @@ export const MediaPlayerMixin = (SuperClass) => {
|
|||||||
this.addEventListener("command-player-mute", (ev) => {
|
this.addEventListener("command-player-mute", (ev) => {
|
||||||
if (ev.detail?.mute !== undefined)
|
if (ev.detail?.mute !== undefined)
|
||||||
this.player.muted = Boolean(ev.detail.mute);
|
this.player.muted = Boolean(ev.detail.mute);
|
||||||
else
|
else this.player.muted = !this.player.muted;
|
||||||
this.player.muted = !this.player.muted;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.connectionPromise.then(() => this._player_update());
|
this.connectionPromise.then(() => this._player_update());
|
||||||
}
|
}
|
||||||
|
|
||||||
private _player_update() {
|
private _player_update() {
|
||||||
const state =
|
const state = this._player_enabled
|
||||||
this._player_enabled
|
|
||||||
? this.player.src
|
? this.player.src
|
||||||
? this.player.ended
|
? this.player.ended
|
||||||
? "stopped"
|
? "stopped"
|
||||||
: this.player.paused
|
: this.player.paused
|
||||||
? "paused"
|
? "paused"
|
||||||
: "playing"
|
: "playing"
|
||||||
: "stopped"
|
: "stopped"
|
||||||
: "unavailable"
|
: "unavailable";
|
||||||
;
|
|
||||||
this.sendUpdate({
|
this.sendUpdate({
|
||||||
player: {
|
player: {
|
||||||
volume: this.player.volume,
|
volume: this.player.volume,
|
||||||
muted: this.player.muted,
|
muted: this.player.muted,
|
||||||
src: this.player.src,
|
src: this.player.src,
|
||||||
state,
|
state,
|
||||||
}
|
},
|
||||||
})
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
};
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
export const ScreenSaverMixin = (SuperClass) => {
|
export const ScreenSaverMixin = (SuperClass) => {
|
||||||
class ScreenSaverMixinClass extends SuperClass {
|
class ScreenSaverMixinClass extends SuperClass {
|
||||||
|
|
||||||
private _panel;
|
private _panel;
|
||||||
private _listeners = {};
|
private _listeners = {};
|
||||||
private _brightness = 255;
|
private _brightness = 255;
|
||||||
@ -8,7 +7,7 @@ export const ScreenSaverMixin = (SuperClass) => {
|
|||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
const panel = this._panel = document.createElement("div")
|
const panel = (this._panel = document.createElement("div"));
|
||||||
panel.setAttribute("browser-mod", "");
|
panel.setAttribute("browser-mod", "");
|
||||||
panel.attachShadow({ mode: "open" });
|
panel.attachShadow({ mode: "open" });
|
||||||
const styleEl = document.createElement("style");
|
const styleEl = document.createElement("style");
|
||||||
@ -29,7 +28,7 @@ export const ScreenSaverMixin = (SuperClass) => {
|
|||||||
:host([dark]) {
|
:host([dark]) {
|
||||||
background: rgba(0,0,0,1);
|
background: rgba(0,0,0,1);
|
||||||
}
|
}
|
||||||
`
|
`;
|
||||||
panel.shadowRoot.appendChild(styleEl);
|
panel.shadowRoot.appendChild(styleEl);
|
||||||
document.body.appendChild(panel);
|
document.body.appendChild(panel);
|
||||||
|
|
||||||
@ -54,10 +53,13 @@ export const ScreenSaverMixin = (SuperClass) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _screen_on(ev=undefined) {
|
private _screen_on(ev = undefined) {
|
||||||
if (ev?.detail?.brightness) {
|
if (ev?.detail?.brightness) {
|
||||||
this._brightness = ev.detail.brightness;
|
this._brightness = ev.detail.brightness;
|
||||||
this._panel.style.setProperty("--darkness", 1-ev.detail.brightness/255)
|
this._panel.style.setProperty(
|
||||||
|
"--darkness",
|
||||||
|
1 - ev.detail.brightness / 255
|
||||||
|
);
|
||||||
}
|
}
|
||||||
this._panel.removeAttribute("dark");
|
this._panel.removeAttribute("dark");
|
||||||
this.sendUpdate({
|
this.sendUpdate({
|
||||||
@ -67,15 +69,14 @@ export const ScreenSaverMixin = (SuperClass) => {
|
|||||||
|
|
||||||
for (const ev of ["pointerdown", "pointermove", "keydown"]) {
|
for (const ev of ["pointerdown", "pointermove", "keydown"]) {
|
||||||
if (this._listeners[ev]) {
|
if (this._listeners[ev]) {
|
||||||
window.removeEventListener(ev, this._listeners[ev])
|
window.removeEventListener(ev, this._listeners[ev]);
|
||||||
this._listeners[ev] = undefined;
|
this._listeners[ev] = undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return ScreenSaverMixinClass
|
return ScreenSaverMixinClass;
|
||||||
}
|
};
|
||||||
|
|
||||||
export const BrowserModScreensaverMixin = (C) =>
|
export const BrowserModScreensaverMixin = (C) =>
|
||||||
class extends C {
|
class extends C {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user