|
@@ -18,9 +18,10 @@ function fetchconfig(url) {
|
|
|
.then(text => {
|
|
|
var map = new Map();
|
|
|
for (const c of text.split(/[\r\n]+/)) {
|
|
|
- const eqs = c.indexOf("=");
|
|
|
- if (eqs > 0) {
|
|
|
- map.set(c.slice(0, eqs), c.slice(eqs+1));
|
|
|
+ var m = c.match(/^\s*("(?:[^"]|"")*"|[^"]+)\s*=(.*)$/);
|
|
|
+ if (m) {
|
|
|
+ var k = m[1].replaceAll(/(^"|"$|(")")/g, "$2");
|
|
|
+ map.set(k, m[2]);
|
|
|
}
|
|
|
}
|
|
|
return map;
|
|
@@ -82,22 +83,25 @@ function loadform(form, url) {
|
|
|
.catch(() => {});
|
|
|
}
|
|
|
|
|
|
-// Insert status data from a map
|
|
|
-function initstatus(map)
|
|
|
+// Replace HTML element contents with the contents of a map
|
|
|
+function fillin(map,html)
|
|
|
{
|
|
|
for (const [key,val] of map) {
|
|
|
var e = document.getElementById(key);
|
|
|
if (e) {
|
|
|
- e.innerText = val;
|
|
|
+ if (html)
|
|
|
+ e.innerHTML = val;
|
|
|
+ else
|
|
|
+ e.innerText = val;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// Load status data
|
|
|
-function loaddata(url)
|
|
|
+// Load status or HTML data
|
|
|
+function load(url,html)
|
|
|
{
|
|
|
fetchconfig(url)
|
|
|
- .then(map => { initdata(map) })
|
|
|
+ .then(map => { initdata(map,map) })
|
|
|
.catch(() => {});
|
|
|
}
|
|
|
|
|
@@ -154,12 +158,10 @@ function enablebutton(id,on) {
|
|
|
// Flip the status of an INPUT element between text and password
|
|
|
function showpwd(id,me) {
|
|
|
var pwd = getelem(id);
|
|
|
- const was_visible = pwd.getAttribute('type') == 'text';
|
|
|
- const new_type = was_visible ? 'password' : 'text';
|
|
|
- const new_icon = was_visible ? 'show' : 'hide';
|
|
|
-
|
|
|
+ const now_visible = me.classList.toggle('hide');
|
|
|
+ me.classList.toggle('show',!now_visible);
|
|
|
+ const new_type = now_visible ? 'text' : 'password';
|
|
|
pwd.setAttribute('type', new_type);
|
|
|
- me.innerHTML = new_icon;
|
|
|
}
|
|
|
|
|
|
// Hack to include an HTML files. Sadly, does not support
|