Implemented Lighting Control
This commit is contained in:
53
static/lighting.js
Normal file
53
static/lighting.js
Normal file
@@ -0,0 +1,53 @@
|
||||
function getFirst(item, className) {
|
||||
return item.getElementsByClassName(className)[0]
|
||||
}
|
||||
|
||||
for (lform of document.getElementsByTagName("form")) {
|
||||
var toggleBtn = getFirst(lform, "symb-btn")
|
||||
if (toggleBtn) {
|
||||
toggleBtn.onclick = (event) => {
|
||||
event.preventDefault(true);
|
||||
var parent = event.target.closest("form");
|
||||
var actionField = getFirst(parent, "action")
|
||||
actionField.value = "toggle";
|
||||
parent.submit();
|
||||
}
|
||||
}
|
||||
|
||||
var brightBar = getFirst(lform, "brightness")
|
||||
if (brightBar) {
|
||||
brightBar.onchange = (event) => {
|
||||
event.preventDefault(true);
|
||||
var parent = event.target.closest("form");
|
||||
var actionField = getFirst(parent, "action")
|
||||
actionField.value = "bright";
|
||||
parent.submit();
|
||||
}
|
||||
}
|
||||
|
||||
var ctInput = getFirst(lform, "ctsel")
|
||||
if (ctInput) {
|
||||
ctInput.onkeydown = (event) => {
|
||||
if (event.key == "Enter") {
|
||||
event.preventDefault(true);
|
||||
var parent = event.target.closest("form");
|
||||
var actionField = getFirst(parent, "action")
|
||||
actionField.value = "ctsel";
|
||||
parent.submit();
|
||||
}
|
||||
}
|
||||
console.log(ctInput)
|
||||
}
|
||||
|
||||
var hsInput = getFirst(lform, "hssel")
|
||||
if (hsInput) {
|
||||
hsInput.onchange = (event) => {
|
||||
event.preventDefault(true);
|
||||
var parent = event.target.closest("form");
|
||||
var actionField = getFirst(parent, "action")
|
||||
actionField.value = "hssel";
|
||||
parent.submit();
|
||||
}
|
||||
console.log(hsInput)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user