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:
@@ -45,7 +45,7 @@
|
||||
}
|
||||
}
|
||||
ldS();
|
||||
if (!numM) gId("um").innerHTML = "No Usermods installed.";
|
||||
if (!numM) gId("um").innerHTML = ""; //WLEDSR: Do not display no usermods installed
|
||||
}
|
||||
// https://stackoverflow.com/questions/3885817/how-do-i-check-that-a-number-is-float-or-integer
|
||||
function isF(n) { return n === +n && n !== (n|0); }
|
||||
@@ -191,10 +191,21 @@
|
||||
urows="";
|
||||
if (isO(umCfg)) {
|
||||
for (const [k,o] of Object.entries(umCfg)) {
|
||||
urows += `<hr><h3>${k}</h3>`;
|
||||
addField(k,'unknown',o);
|
||||
//WLEDSR: read url parameter. e.g. um=AudioReactive and if set only add the usermod with the same name
|
||||
const queryString = window.location.search;
|
||||
const urlParams = new URLSearchParams(queryString);
|
||||
const userMod = urlParams.get('um')
|
||||
|
||||
if (userMod == "" || userMod == k) {
|
||||
urows += `<div id=${k}><hr><h3>${k}</h3>`;
|
||||
addField(k,'unknown',o);
|
||||
urows += `</div> <!--ewowi-->`;
|
||||
}
|
||||
}
|
||||
}
|
||||
//WLEDSR: only show globalGPIOs if no usermod info is shown (url without um parameter)
|
||||
gId("globalGPIOs").style.display = urows===""?"block":"none";
|
||||
|
||||
if (urows==="") urows = "Usermods configuration not found.<br>Press <i>Save</i> to initialize defaults.";
|
||||
gId("um").innerHTML = urows;
|
||||
var url = (loc?`http://${locip}`:'') + '/settings/s.js?p=8';
|
||||
@@ -219,8 +230,10 @@
|
||||
<div class="helpB"><button type="button" onclick="H()">?</button></div>
|
||||
<button type="button" onclick="B()">Back</button><button type="submit">Save</button><br>
|
||||
<span id="lssuc" style="color:green; display:none">✔ Configuration saved!</span>
|
||||
<span id="lserr" style="color:red; display:none">⚠ Could not load configuration.</span><hr>
|
||||
<span id="lserr" style="color:red; display:none">⚠ Could not load configuration.</span>
|
||||
</div>
|
||||
<div id="globalGPIOs" style="display:none;"> <!--WLEDSR: show in ldS-->
|
||||
<hr>
|
||||
<h2>Usermod Setup</h2>
|
||||
Global I<sup>2</sup>C GPIOs (HW)<br>
|
||||
<i style="color: orange;">(only changable on ESP32, change requires reboot!)</i><br>
|
||||
@@ -232,6 +245,7 @@
|
||||
MOSI:<input type="number" min="-1" max="33" name="MOSI" onchange="check(this,'if')" class="s" placeholder="MOSI">
|
||||
MISO:<input type="number" min="-1" max="33" name="MISO" onchange="check(this,'if')" class="s" placeholder="MISO">
|
||||
SCLK:<input type="number" min="-1" max="33" name="SCLK" onchange="check(this,'if')" class="s" placeholder="SCLK">
|
||||
</div>
|
||||
<div id="um">Loading settings...</div>
|
||||
<hr><button type="button" onclick="B()">Back</button><button type="submit">Save</button>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user