LedBars/RpiLedBars/frontend/web/index_ui_handler.js

86 lines
2.6 KiB
JavaScript
Raw Permalink Normal View History

2022-07-20 16:57:01 +02:00
function wsSelectCallback(event) {
// todo: disable form on this != auto
if (event.target.nodeName == 'INPUT') {
console.log("ws:" + event.target.value);
ws_index = event.target.value;
}
}
2021-10-18 20:56:35 +02:00
function modeSelectCallback(event) {
// todo: disable form on this != auto
if (event.target.nodeName == 'INPUT') {
console.log("m:" + event.target.value);
if (socket.readyState == WebSocket.OPEN) {
socket.send("m:" + event.target.value);
}
}
}
function patternSelectCallback(event) {
// todo: disable form on this != auto
if (event.target.nodeName == 'INPUT') {
console.log("p:" + event.target.value);
if (socket.readyState == WebSocket.OPEN) {
socket.send("p:" + event.target.value);
}
}
}
function channelSelectCallback(event) {
if (event.target.nodeName == 'INPUT') {
2022-07-20 16:57:01 +02:00
console.log("h:" + event.target.value);
if (socket.readyState == WebSocket.OPEN) {
socket.send("h:" + event.target.value);
2021-10-18 20:56:35 +02:00
}
}
}
2022-07-20 16:57:01 +02:00
function sensitivityCallback(element) {
console.log("e:" + element.value);
if (socket.readyState == WebSocket.OPEN) {
socket.send("e:" + element.value);
}
rangeCallback(element);
}
function gravityCallback(element) {
console.log("g:" + element.value);
if (socket.readyState == WebSocket.OPEN) {
socket.send("g:" + element.value);
}
rangeCallback(element);
}
2021-10-18 20:56:35 +02:00
var eventd;
function colorModulateCallback(element) {
eventd = element;
if (element.checked) {
document.getElementById("modulationPicker").classList.remove("d-none");
} else {
document.getElementById("modulationPicker").classList.add("d-none");
}
console.log("s: " + element.checked);
2022-07-20 16:57:01 +02:00
if (socket.readyState == WebSocket.OPEN) {
socket.send("s:" + element.checked);
}
2021-10-18 20:56:35 +02:00
}
function colorChangeCallback(color) {
console.log("c: " + color.index + ", h: " + color.hsl.h + ", s: " + color.hsl.s + ", l: " + color.hsl.l + "}");
if (socket.readyState == WebSocket.OPEN) {
socket.send("c:" + color.index + "," + color.hsl.h + "," + color.hsl.s + "," + color.hsl.l);
}
}
2022-07-20 16:57:01 +02:00
function modulationColorChangeCallback(color) {
console.log("c: " + (color.index + 2) + ", h: " + color.hsl.h + ", s: " + color.hsl.s + ", l: " + color.hsl.l + "}");
if (socket.readyState == WebSocket.OPEN) {
socket.send("c:" + (color.index + 2) + "," + color.hsl.h + "," + color.hsl.s + "," + color.hsl.l);
}
}
2021-10-18 20:56:35 +02:00
function rangeCallback(element) {
eventd = this
element.parentNode.parentElement.getElementsByTagName('span')[0].innerText = element.value;
}