summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Makefile11
-rw-r--r--config.js44
-rw-r--r--config.toml37
-rw-r--r--toml2json.py4
5 files changed, 50 insertions, 47 deletions
diff --git a/.gitignore b/.gitignore
index 731d6ff..3b580fc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
/main.js
/main.css
+/config.js
diff --git a/Makefile b/Makefile
index cc377ac..e92fc58 100644
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,13 @@
-all: main.js main.css
+all: main.js main.css config.js
main.js: ka.js app.js
- cat $? | esbuild --minify --loader=js > $@
+ cat $^ | esbuild --minify --loader=js > $@
main.css: style.css
- cat $? | esbuild --minify --loader=css > $@
+ cat $^ | esbuild --minify --loader=css > $@
+
+config.js: config.toml
+ echo -n "config=" > $@
+ python3 ./toml2json.py < $< >> $@
+ echo -n ";" >> $@
diff --git a/config.js b/config.js
deleted file mode 100644
index 814371e..0000000
--- a/config.js
+++ /dev/null
@@ -1,44 +0,0 @@
-config = {
- device: "Device Name",
- swVersion: "1.0",
- hwVersion: "1.0",
- sections: {
- network: {
- title: "Network",
- fields: [
- {
- id: "macaddr",
- type: "mac",
- title: "MAC address",
- pattern: "[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}",
- invalidmsg: "Enter MAC address. E.g. 00:11:22:33:44:55",
- required: true,
- },
- {
- id: "ipaddr",
- type: "ip",
- title: "IP address",
- pattern: "\\d+.\\d+.\\d+.\\d+",
- hint: "192.168.4.2",
- invalidmsg: "Enter IP address. E.g. 192.168.4.2",
- required: true,
- },
- {
- id: "netmask",
- type: "netmask",
- title: "Netmask",
- pattern: "\\d+.\\d+.\\d+.\\d+",
- hint: "255.255.255.0",
- invalidmsg: "Enter network mask. E.g. 255.255.255.0",
- required: true,
- },
- {
- id: "gateway",
- type: "ip",
- title: "Gateway",
- pattern: "\\d+.\\d+.\\d+.\\d+",
- },
- ],
- },
- },
-}
diff --git a/config.toml b/config.toml
new file mode 100644
index 0000000..f5546a7
--- /dev/null
+++ b/config.toml
@@ -0,0 +1,37 @@
+device = "Device Name"
+swVersion = "1.0"
+hwVersion = "1.0"
+
+[sections]
+
+[sections.network]
+title = "Network"
+
+[[sections.network.fields]]
+id = "macaddr"
+title = "MAC address"
+pattern = "[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}"
+invalidmsg = "Enter MAC address. E.g. 00:11:22:33:44:55"
+required = true
+
+[[sections.network.fields]]
+id = "ipaddr"
+title = "IP address"
+pattern = "\\d+.\\d+.\\d+.\\d+"
+hint = "192.168.4.2"
+invalidmsg = "Enter IP address. E.g. 192.168.4.2"
+required = true
+
+[[sections.network.fields]]
+id = "netmask"
+title = "Netmask"
+pattern = "\\d+.\\d+.\\d+.\\d+"
+hint = "255.255.255.0"
+invalidmsg = "Enter network mask. E.g. 255.255.255.0"
+required = true
+
+[[sections.network.fields]]
+id = "gateway"
+type = "ip"
+title = "Gateway"
+pattern = "\\d+.\\d+.\\d+.\\d+"
diff --git a/toml2json.py b/toml2json.py
new file mode 100644
index 0000000..320b414
--- /dev/null
+++ b/toml2json.py
@@ -0,0 +1,4 @@
+import sys, json, tomllib
+
+data = tomllib.load(open(0,'rb',closefd=False))
+json.dump(data, sys.stdout, separators=(',',':'))