diff --git a/web/share/js/kvm/gpio.js b/web/share/js/kvm/gpio.js
index a412d579..e7b3c9e1 100644
--- a/web/share/js/kvm/gpio.js
+++ b/web/share/js/kvm/gpio.js
@@ -75,8 +75,6 @@ export function Gpio() {
$("gpio-menu-button").innerHTML = `${model.view.header.title} ↴`;
}
- let switches = [];
- let buttons = [];
let content = "
";
for (let row of model.view.table) {
if (row === null) {
@@ -87,7 +85,7 @@ export function Gpio() {
if (item.type === "output") {
item.scheme = model.scheme.outputs[item.channel];
}
- content += `| ${__createItem(item, switches, buttons)} | `;
+ content += `${__createItem(item)} | `;
}
content += "";
}
@@ -95,17 +93,21 @@ export function Gpio() {
content += "
";
$("gpio-menu").innerHTML = content;
- for (let channel of switches) {
- tools.setOnClick($(`gpio-switch-${channel}`), () => __switchChannel(channel));
- }
- for (let channel of buttons) {
- tools.setOnClick($(`gpio-button-${channel}`), () => __pulseChannel(channel));
+ for (let channel in model.scheme.outputs) {
+ let el = $(`gpio-switch-${channel}`);
+ if (el) {
+ tools.setOnClick(el, () => __switchChannel(channel));
+ }
+ el = $(`gpio-button-${channel}`);
+ if (el) {
+ tools.setOnClick(el, () => __pulseChannel(channel));
+ }
}
self.setState(__state);
};
- var __createItem = function(item, switches, buttons) {
+ var __createItem = function(item) {
if (item.type === "label") {
return item.text;
} else if (item.type === "input") {
@@ -116,7 +118,6 @@ export function Gpio() {
} else if (item.type === "output") {
let controls = [];
if (item.scheme["switch"]) {
- switches.push(item.channel);
controls.push(`
@@ -128,7 +129,6 @@ export function Gpio() {
`);
}
if (item.scheme.pulse.delay) {
- buttons.push(item.channel);
controls.push(` | `);
}
return ` `;
|