summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarin Ivanov <[email protected]>2024-08-21 02:18:14 +0300
committerMarin Ivanov <[email protected]>2024-08-21 02:18:14 +0300
commit4b32d0bab72927da861d072991fd57f68a32b48f (patch)
tree6c5380f30f76e7d1dd428376fe9bc469f8e58d73
parentc550c3bc1c6cce7bb8a4916348e91dfb71074919 (diff)
js minification optimisation
-rw-r--r--app.js28
-rw-r--r--ka.js8
2 files changed, 17 insertions, 19 deletions
diff --git a/app.js b/app.js
index b265f76..5a35abe 100644
--- a/app.js
+++ b/app.js
@@ -1,7 +1,6 @@
(() => {
- state = {};
- isLoading = 0;
-
+ let state = {};
+ let isLoading = 0;
let loading = (val) => {
isLoading = val;
loader.$cls(isLoading ? "" : "hidden");
@@ -9,7 +8,7 @@
loader.$click(() => loading(0));
let error = null;
- setError = (err) => {
+ let setError = (err) => {
error = String(err);
app.reload();
}
@@ -27,14 +26,14 @@
}
return r.text();
};
- getconfig = () => fetch("/cgi-bin/getconfig").then(resptext).then(x => parsetxt(x));
- cmd = (body) => fetch("/cgi-bin/cmd",{method:"POST",body}).then(resptext);
- setconfig = (data) => {
+ let getconfig = () => fetch("/cgi-bin/getconfig").then(resptext).then(x => parsetxt(x));
+ let cmd = (body) => fetch("/cgi-bin/cmd",{method:"POST",body}).then(resptext);
+ let setconfig = (data) => {
loading(1);
cmd(buildtxt(data)+"save\n")
.finally(() => loading(0))
};
- loadconfig = () => {
+ let loadconfig = () => {
loading(1);
getconfig("/cgi-bin/getconfig")
.then(x => {
@@ -43,7 +42,7 @@
})
.finally(() => loading(0));
}
- reboot = (data) => {
+ let reboot = (data) => {
let ok = 0;
loading(1);
cmd("reboot\n")
@@ -79,8 +78,8 @@
}
function CRouter(routes) {
return (h) => {
- const p = h.substr(1) || "/";
- const r = p in routes ? p : "";
+ let p = h.substr(1) || "/";
+ let r = p in routes ? p : "";
return routes[r]();
}
}
@@ -120,12 +119,11 @@
f,
)
}
-
- const navbar = CNav([
+ let navbar = CNav([
["#", "Home"],
...entries(config.sections).map(([id, x]) => [`#/${id}`, x.title]),
]);
- const router = CRouter({
+ let router = CRouter({
"/": () => div(
h1("Information"),
table(
@@ -144,7 +142,7 @@
p("The requested page is not available.")
),
});
- CApp = (h) => {
+ let CApp = (h) => {
loading(isLoading);
return [
div(error && CErr(String(error))),
diff --git a/ka.js b/ka.js
index 5dba500..95634cc 100644
--- a/ka.js
+++ b/ka.js
@@ -34,9 +34,9 @@ let {entries,fromEntries} = Object;
return this;
}
tag = (name, attrs, ...children) => {
- const el = doc.createElement(name);
+ let el = doc.createElement(name);
attrs && el.$attrs(attrs);
- for (const child of children.filter(x=>x)) {
+ for (let child of children.filter(x=>x)) {
el.appendChild((typeof(child) === 'string') ? doc.createTextNode(child) : child);
}
return el;
@@ -45,14 +45,14 @@ let {entries,fromEntries} = Object;
labelfor = (for_, ...children) => tag("label", {"for":for_}, ...children);
img = (src) => tag("img", {src});
input = (type) => tag("input", {type});
- const TRIVIAL = "main,section,nav,h1,h2,h3,p,b,div,span,form,select,button,table,tr,td";
+ let TRIVIAL = "main,section,nav,h1,h2,h3,p,b,div,span,form,select,button,table,tr,td";
for (let name of TRIVIAL.split(",")) {
window[name] = (...children) => tag(name, null, ...children);
}
mount = (root, app) => {
function reload() {
- const h = doc.location.hash || "#";
+ let h = doc.location.hash || "#";
root.replaceChildren(...app(h));
};
reload();