improved web API for live

added dark mode option
converted all forms to reponsive design
repaired menu with password protection #720, #716, #709
This commit is contained in:
lumapu 2023-03-03 00:14:13 +01:00
parent 53624e466b
commit 70cb0dcd45
19 changed files with 1082 additions and 589 deletions

View file

@ -33,23 +33,63 @@ iconSuccess = [
/**
* GENERIC FUNCTIONS
*/
function ml(tagName, ...args) {
var el = document.createElement(tagName);
if(args[0]) {
for(var name in args[0]) {
if(name.indexOf("on") === 0) {
el.addEventListener(name.substr(2).toLowerCase(), args[0][name], false)
} else {
el.setAttribute(name, args[0][name]);
}
}
}
if (!args[1]) {
return el;
}
return nester(el, args[1])
}
function nester(el, n) {
if (typeof n === "string") {
var t = document.createTextNode(n);
el.appendChild(t);
} else if (n instanceof Array) {
for(var i = 0; i < n.length; i++) {
if (typeof n[i] === "string") {
var t = document.createTextNode(n[i]);
el.appendChild(t);
} else if (n[i] instanceof Node){
el.appendChild(n[i]);
}
}
} else if (n instanceof Node){
el.appendChild(n)
}
return el;
}
function topnav() {
toggle("topnav", "mobile");
}
function parseNav(obj) {
for(i = 0; i < 7; i++) {
for(i = 0; i < 10; i++) {
if(i == 2)
continue;
var l = document.getElementById("nav"+i);
if(window.location.pathname == "/" + l.href.split('/').pop())
l.classList.add("active");
if(obj["menu_protEn"]) {
if(obj["menu_prot"]) {
if((((obj["menu_mask"] >> i) & 0x01) == 0x01) || (1 == i))
if(0 == i)
l.classList.remove("hide");
} else if(0 == i)
else if(i > 2) {
if(((obj["menu_mask"] >> (i-2)) & 0x01) == 0x00)
l.classList.remove("hide");
}
} else if(0 != i)
l.classList.remove("hide");
} else if(i > 1)
l.classList.remove("hide");
@ -72,7 +112,7 @@ function parseRssi(obj) {
icon = iconWifi1;
else if(obj["wifi_rssi"] <= -70)
icon = iconWifi2;
document.getElementById("wifiicon").replaceChildren(svg(icon, 32, 32, "#fff", null, obj["wifi_rssi"]));
document.getElementById("wifiicon").replaceChildren(svg(icon, 32, 32, "wifi", obj["wifi_rssi"]));
}
function setHide(id, hide) {
@ -201,11 +241,10 @@ function link(dst, text, target=null) {
return a;
}
function svg(data=null, w=24, h=24, color="#000", cl=null, tooltip=null) {
function svg(data=null, w=24, h=24, cl=null, tooltip=null) {
var s = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
s.setAttribute('width', w);
s.setAttribute('height', h);
s.setAttribute('fill', color);
s.setAttribute('viewBox', '0 0 16 16');
if(null != cl) s.setAttribute('class', cl);
if(null != data) {