Usermod config level up, step 2: Working!

- remove settings_um2
- remove addToConfigMenu
- settings.htm: add isO and ldS (inspired by settings_um.htm): add usermod buttons to urows
settings_um.htm: check url um var and if set show only this usermod. Only show globalGPIOs if no usermod
This commit is contained in:
Ewowi
2022-09-01 22:37:52 +02:00
parent 7bb50da4b8
commit 42ec2725f8
9 changed files with 292 additions and 655 deletions

View File

@@ -26,6 +26,34 @@
alert("Loading of configuration script failed.\nIncomplete page data!");
});
}
function isO(i) { return (i && typeof i === 'object' && !Array.isArray(i)); }
// load settings and insert values into DOM
function ldS() {
var url = (loc?`http://${locip}`:'') + '/cfg.json';
fetch(url, {
method: 'get'
})
.then(res => {
if (!res.ok) gId('lserr').style.display = "inline";
return res.json();
})
.then(json => {
umCfg = json.um;
urows="";
if (isO(umCfg)) {
for (const [k,o] of Object.entries(umCfg)) {
urows += `<button type="submit" onclick="window.location=\'./settings/um?um=${k}\'">${k} (UM)</button>`;
}
}
gId("configMenu").innerHTML = urows;
var url = (loc?`http://${locip}`:'') + '/settings/s.js?p=0';
loadJS(url, false); // If we set async false, file is loaded and executed, then next statement is processed
})
.catch((error)=>{
gId('lserr').style.display = "inline";
console.log(error);
});
}
function S(){
if (window.location.protocol == "file:") {
loc = true;
@@ -35,10 +63,8 @@
localStorage.setItem('locIp', locip);
}
}
var url = (loc?`http://${locip}`:'') + '/settings/s.js?p=0';
loadJS(url, false); // If we set async false, file is loaded and executed, then next statement is processed
gId("configMenu").innerHTML = '<button type="submit" onclick="window.location=\'./settings/ar?um=1\'">Audio Reactive (UM)</button>\
<button type="submit" onclick="window.location=\'./settings/ar?um=2\'">Weather mod (UM)</button>';
//WLEDSR: add ldS and move loadJS there (like in settings_um)
ldS();
}
</script>
<style>