summaryrefslogtreecommitdiff
path: root/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'app.js')
-rw-r--r--app.js22
1 files changed, 10 insertions, 12 deletions
diff --git a/app.js b/app.js
index a74104c..8ffe96c 100644
--- a/app.js
+++ b/app.js
@@ -2,7 +2,7 @@
state = {};
isLoading = 0;
- const loading = (val) => {
+ let loading = (val) => {
isLoading = val;
loader.$cls(isLoading ? "" : "hidden");
}
@@ -13,15 +13,13 @@
error = String(err);
app.reload();
}
- function errClose() {
- }
- window.onerror = (message, source, lineNumber, colno, err) => {
+ window.onerror = (message) => {
setError(message);
};
- window.onunhandledrejection = (event) => {
- setError(event.reason);
+ window.onunhandledrejection = (e) => {
+ setError(e.reason);
};
- let parseini = (data) => Object.fromEntries(data.split("\n").map(x=>x.trim()).filter(x=>x).map(x=>x.split("=")));
+ let parseini = (data) => fromEntries(data.split("\n").map(x=>x.trim()).filter(x=>x).map(x=>x.split("=")));
let buildini = (data, prefix="") => entries(data).map(([k,v])=>`${prefix}${k}=${v}\n`).join();
let resptext = r => {
if (!r.ok){
@@ -46,7 +44,7 @@
.finally(() => loading(0));
}
reboot = (data, prefix) => {
- var ok = 0;
+ let ok = 0;
loading(1);
cmd("reboot\n")
.then(() => {
@@ -61,7 +59,7 @@
};
function CErr(text) {
- var el = div(
+ let el = div(
div("✖").$cls("close").$click(errClose),
span("⚠ "),
text,
@@ -88,7 +86,7 @@
}
function CSettingInput(f) {
- var inp = input("text")
+ let inp = input("text")
.$attr("id","form__"+f.id)
.$attr("name",f.id)
.$attr("required",!!f.required)
@@ -110,7 +108,7 @@
function CSettings(section) {
let s = config.sections[section];
let form_ = form(
- table(...s.fields.map(x => CSettingInput(x))).$cls("settings"),
+ table(...s.fields.map(x => CSettingInput(x))),
input("submit").$value("Save")
);
form_.onsubmit = (e) => {e.preventDefault(); setconfig({});}
@@ -137,7 +135,7 @@
button("Reboot").$click(reboot),
).$cls("center"),
),
- ...Object.fromEntries(entries(config.sections).map(([id, _]) => [`/${id}`, () => CSettings(id)])),
+ ...fromEntries(entries(config.sections).map(([id, _]) => [`/${id}`, () => CSettings(id)])),
"": () => div(
h1("Not Found"),
p("The requested page is not available.")