Skip to content

Commit 37416aa

Browse files
committed
shortened java code
1 parent e97d84b commit 37416aa

File tree

1 file changed

+13
-28
lines changed

1 file changed

+13
-28
lines changed

wled00/data/settings_wifi.htm

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -157,29 +157,17 @@
157157
function aR(id, mac) {
158158
if (!/^[0-9A-F]{12}$/i.test(mac)) return; // check for valid hex string
159159
if (rC >= 10) return;
160-
let inputs = gId('rml').getElementsByTagName('input');
161-
for (let i = 0; i < inputs.length; i++) {
162-
if (inputs[i].value === mac) return;
160+
let inputs = d.querySelectorAll("#rml input");
161+
for (let i of (inputs || [])) {
162+
if (i.value === mac) return;
163163
}
164-
let list = gId('rml');
165-
let row = cE('div');
166-
let inp = cE('input');
167-
inp.type = 'text';
168-
inp.name = id;
169-
inp.value = mac;
170-
inp.maxLength = 12;
171-
inp.minLength = 12;
172-
inp.onchange = uR;
173-
row.appendChild(inp);
174-
let btn = d.createElement('button');
175-
btn.type = 'button';
176-
//btn.className = 'btn btn-xs';
177-
btn.innerText = '-';
178-
btn.onclick = function() {
179-
rR(row);
180-
};
181-
row.appendChild(btn);
182-
list.appendChild(row);
164+
let l = gId('rml'), r = cE('div'), i = cE('input');
165+
i.type = 'text'; i.name = id; i.value = mac; i.maxLength = 12; i.minLength = 12; i.onchange = uR;
166+
r.appendChild(i);
167+
let b = cE('button');
168+
b.type = 'button'; b.innerText = '-'; b.onclick = () => rR(r);
169+
r.appendChild(b);
170+
l.appendChild(r);
183171
rC++;
184172
uR();
185173
}
@@ -191,12 +179,9 @@
191179
// update remote list
192180
function uR() {
193181
let macs = [];
194-
let inputs = gId('rml').getElementsByTagName('input');
195-
for (let i = 0; i < inputs.length; i++) {
196-
if (inputs[i].value && inputs[i].value !== '') {
197-
macs.push(inputs[i].value);
198-
}
199-
}
182+
d.querySelectorAll('#rml input').forEach(o => {
183+
if (o.value) macs.push(o.value);
184+
});
200185
gId('rmacs').value = JSON.stringify(macs);
201186
return true; // Allow form submission to continue
202187
}

0 commit comments

Comments
 (0)