um settings: cpp: lowercase, js: initcap

This commit is contained in:
Ewoud
2022-11-21 17:45:53 +01:00
parent 18693dc96a
commit b0b78a9959
3 changed files with 227 additions and 221 deletions

View File

@@ -104,10 +104,15 @@
}
}
}
//WLEDMM util function
const initCap = (s) => {
if (typeof s !== 'string') return ''
return s.charAt(0).toUpperCase() + s.slice(1)
}
function addField(k,f,o,a=false) { //key, field, (sub)object, isArray
if (isO(o)) {
urows += '<hr class="sml">';
if (f!=='unknown' && !k.includes(":")) urows += `<p><u>${f}</u></p>`; //WLEDMM show group title
if (f!=='unknown' && !k.includes(":")) urows += `<p><u>${initCap(f)}</u></p>`; //WLEDMM show group title
for (const [s,v] of Object.entries(o)) {
// possibility to nest objects (only 1 level)
if (f!=='unknown' && !k.includes(":")) addField(k+":"+f,s,v);
@@ -136,7 +141,7 @@
t = "text"; c = `value="${o}" style="width:250px;"`;
break;
}
urows += ` ${f} `; //WLEDMM only show field (key is shown in grouping)
urows += ` ${initCap(f)} `; //WLEDMM only show field (key is shown in grouping)
// https://stackoverflow.com/questions/11657123/posting-both-checked-and-unchecked-checkboxes
if (t=="checkbox") urows += `<input type="hidden" name="${k}:${f}${a?"[]":""}" value="false">`;
else if (!a) urows += `<input type="hidden" name="${k}:${f}${a?"[]":""}" value="${t}">`;
@@ -181,9 +186,7 @@
// https://stackoverflow.com/questions/26440494/insert-text-after-this-input-element-with-javascript
//WLEDMM Add pre and post texts
function addInfo(name,el,txt, txt2="") {
console.log("addInfo", name, el, txt)
let obj = d.getElementsByName(name);
// console.log(obj);
if (!obj.length) return;
if (typeof el === "string" && obj[0]) obj[0].placeholder = el;
else if (obj[el]) {