Usermods: add removeOptions e.g. for pin MCLK

- add replaceOption to analogmic
- fix: right default for audio reactive scl
- pinmanager add case UM_Battery
This commit is contained in:
Ewoud
2023-01-02 21:42:19 +01:00
parent 49b8bf389d
commit 86ceca5de7
4 changed files with 219 additions and 202 deletions

View File

@@ -229,6 +229,22 @@
}
}
}
//WLEDMM: removeOptions to remove options e.g. mclk
function removeOptions(name,el,valFrom,valTo) {
let obj = d.getElementsByName(name);
if (obj[el]) {
let select = obj[el];
for (let i=0; i<select.options.length; i++) {
let c = select.options[i];
if (c.value >= valFrom && c.value <= valTo) {
select.removeChild(c);
i--; //decrease i by one because the index has been adjusted
}
//https://www.javascripttutorial.net/javascript-dom/javascript-add-remove-options/
//https://www.javascripttutorial.net/javascript-dom/javascript-remove-items-from-a-select-conditionally/
}
}
}
// https://stackoverflow.com/questions/26440494/insert-text-after-this-input-element-with-javascript
function addInfo(name,el,txt, txt2="") {
let obj = d.getElementsByName(name);