Skip to content

Commit e26d517

Browse files
fix: improve styling
1 parent f19e533 commit e26d517

File tree

5 files changed

+28
-344
lines changed

5 files changed

+28
-344
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ set(ENV{BOARD_VARIANT} "../esp32-javascript/include/variants/my")
1010
# set ESP32_JS_PROJECT_NAME to define your project component name.
1111
# Place your component below ./components directory. Set to ""
1212
# if you don't have a project component yet.
13-
set(ENV{ESP32_JS_PROJECT_NAME} "esp32-home")
13+
set(ENV{ESP32_JS_PROJECT_NAME} "")
1414
#################################################
1515

1616
include($ENV{IDF_PATH}/tools/cmake/project.cmake)

components/esp32-javascript/modules/esp32-javascript/chunked.js

Lines changed: 0 additions & 162 deletions
Original file line numberDiff line numberDiff line change
@@ -121,165 +121,3 @@ function createChunkedEncodingConsumer(onData) {
121121
};
122122
}
123123
exports.createChunkedEncodingConsumer = createChunkedEncodingConsumer;
124-
/*
125-
126-
function selftest() {
127-
let consumer = createChunkedEncodingConsumer();
128-
console.log(
129-
consumer(new Uint8Array(["0".charCodeAt(0), 10, 13, 10, 13]), () => {
130-
throw Error("Should not be called.");
131-
}) === FINISHED
132-
);
133-
134-
consumer = createChunkedEncodingConsumer();
135-
console.log(
136-
consumer(
137-
new Uint8Array([
138-
"1".charCodeAt(0),
139-
10,
140-
13,
141-
"x".charCodeAt(0),
142-
10,
143-
13,
144-
"0".charCodeAt(0),
145-
10,
146-
13,
147-
10,
148-
13,
149-
]),
150-
(data: Uint8Array) =>
151-
console.log(data.length === 1 && data[0] === "x".charCodeAt(0))
152-
) === FINISHED
153-
);
154-
155-
consumer = createChunkedEncodingConsumer();
156-
console.log(
157-
consumer(
158-
new Uint8Array([
159-
"0".charCodeAt(0),
160-
"1".charCodeAt(0),
161-
10,
162-
13,
163-
"x".charCodeAt(0),
164-
10,
165-
13,
166-
"0".charCodeAt(0),
167-
10,
168-
13,
169-
10,
170-
13,
171-
]),
172-
(data: Uint8Array) =>
173-
console.log(data.length === 1 && data[0] === "x".charCodeAt(0))
174-
) === FINISHED
175-
);
176-
177-
consumer = createChunkedEncodingConsumer();
178-
console.log(
179-
consumer(
180-
new Uint8Array([
181-
"1".charCodeAt(0),
182-
"a".charCodeAt(0),
183-
10,
184-
13,
185-
"x".charCodeAt(0),
186-
"y".charCodeAt(0),
187-
"x".charCodeAt(0),
188-
"y".charCodeAt(0),
189-
"x".charCodeAt(0),
190-
"y".charCodeAt(0),
191-
"x".charCodeAt(0),
192-
"y".charCodeAt(0),
193-
"x".charCodeAt(0),
194-
"y".charCodeAt(0),
195-
"x".charCodeAt(0),
196-
"y".charCodeAt(0),
197-
"x".charCodeAt(0),
198-
"y".charCodeAt(0),
199-
"x".charCodeAt(0),
200-
"y".charCodeAt(0),
201-
"x".charCodeAt(0),
202-
"y".charCodeAt(0),
203-
"x".charCodeAt(0),
204-
"y".charCodeAt(0),
205-
"x".charCodeAt(0),
206-
"y".charCodeAt(0),
207-
"x".charCodeAt(0),
208-
"y".charCodeAt(0),
209-
"x".charCodeAt(0),
210-
"y".charCodeAt(0),
211-
10,
212-
13,
213-
"0".charCodeAt(0),
214-
10,
215-
13,
216-
10,
217-
13,
218-
]),
219-
(data: Uint8Array) =>
220-
console.log(
221-
data.length === 26 &&
222-
data[0] === "x".charCodeAt(0) &&
223-
data[1] === "y".charCodeAt(0)
224-
)
225-
) === FINISHED
226-
);
227-
228-
consumer = createChunkedEncodingConsumer();
229-
console.log(
230-
consumer(
231-
new Uint8Array([
232-
"1".charCodeAt(0),
233-
"a".charCodeAt(0),
234-
10,
235-
13,
236-
"x".charCodeAt(0),
237-
"y".charCodeAt(0),
238-
"x".charCodeAt(0),
239-
"y".charCodeAt(0),
240-
"x".charCodeAt(0),
241-
"y".charCodeAt(0),
242-
"x".charCodeAt(0),
243-
"y".charCodeAt(0),
244-
"x".charCodeAt(0),
245-
"y".charCodeAt(0),
246-
"x".charCodeAt(0),
247-
"y".charCodeAt(0),
248-
"x".charCodeAt(0),
249-
"y".charCodeAt(0),
250-
"x".charCodeAt(0),
251-
"y".charCodeAt(0),
252-
"x".charCodeAt(0),
253-
"y".charCodeAt(0),
254-
"x".charCodeAt(0),
255-
"y".charCodeAt(0),
256-
"x".charCodeAt(0),
257-
"y".charCodeAt(0),
258-
"x".charCodeAt(0),
259-
"y".charCodeAt(0),
260-
"x".charCodeAt(0),
261-
]),
262-
(data: Uint8Array) =>
263-
console.log(data.length === 25 && data[0] === "x".charCodeAt(0))
264-
) === READ_PAYL
265-
);
266-
console.log("test");
267-
console.log(
268-
consumer(
269-
new Uint8Array([
270-
"y".charCodeAt(0),
271-
10,
272-
13,
273-
"0".charCodeAt(0),
274-
10,
275-
13,
276-
10,
277-
13,
278-
]),
279-
(data: Uint8Array) =>
280-
console.log(data.length === 1 && data[0] === "y".charCodeAt(0))
281-
) === FINISHED
282-
);
283-
}
284-
selftest();
285-
*/

components/esp32-javascript/modules/esp32-javascript/chunked.ts

Lines changed: 0 additions & 163 deletions
Original file line numberDiff line numberDiff line change
@@ -119,166 +119,3 @@ export function createChunkedEncodingConsumer(
119119
return state === FINISHED;
120120
};
121121
}
122-
123-
/*
124-
125-
function selftest() {
126-
let consumer = createChunkedEncodingConsumer();
127-
console.log(
128-
consumer(new Uint8Array(["0".charCodeAt(0), 10, 13, 10, 13]), () => {
129-
throw Error("Should not be called.");
130-
}) === FINISHED
131-
);
132-
133-
consumer = createChunkedEncodingConsumer();
134-
console.log(
135-
consumer(
136-
new Uint8Array([
137-
"1".charCodeAt(0),
138-
10,
139-
13,
140-
"x".charCodeAt(0),
141-
10,
142-
13,
143-
"0".charCodeAt(0),
144-
10,
145-
13,
146-
10,
147-
13,
148-
]),
149-
(data: Uint8Array) =>
150-
console.log(data.length === 1 && data[0] === "x".charCodeAt(0))
151-
) === FINISHED
152-
);
153-
154-
consumer = createChunkedEncodingConsumer();
155-
console.log(
156-
consumer(
157-
new Uint8Array([
158-
"0".charCodeAt(0),
159-
"1".charCodeAt(0),
160-
10,
161-
13,
162-
"x".charCodeAt(0),
163-
10,
164-
13,
165-
"0".charCodeAt(0),
166-
10,
167-
13,
168-
10,
169-
13,
170-
]),
171-
(data: Uint8Array) =>
172-
console.log(data.length === 1 && data[0] === "x".charCodeAt(0))
173-
) === FINISHED
174-
);
175-
176-
consumer = createChunkedEncodingConsumer();
177-
console.log(
178-
consumer(
179-
new Uint8Array([
180-
"1".charCodeAt(0),
181-
"a".charCodeAt(0),
182-
10,
183-
13,
184-
"x".charCodeAt(0),
185-
"y".charCodeAt(0),
186-
"x".charCodeAt(0),
187-
"y".charCodeAt(0),
188-
"x".charCodeAt(0),
189-
"y".charCodeAt(0),
190-
"x".charCodeAt(0),
191-
"y".charCodeAt(0),
192-
"x".charCodeAt(0),
193-
"y".charCodeAt(0),
194-
"x".charCodeAt(0),
195-
"y".charCodeAt(0),
196-
"x".charCodeAt(0),
197-
"y".charCodeAt(0),
198-
"x".charCodeAt(0),
199-
"y".charCodeAt(0),
200-
"x".charCodeAt(0),
201-
"y".charCodeAt(0),
202-
"x".charCodeAt(0),
203-
"y".charCodeAt(0),
204-
"x".charCodeAt(0),
205-
"y".charCodeAt(0),
206-
"x".charCodeAt(0),
207-
"y".charCodeAt(0),
208-
"x".charCodeAt(0),
209-
"y".charCodeAt(0),
210-
10,
211-
13,
212-
"0".charCodeAt(0),
213-
10,
214-
13,
215-
10,
216-
13,
217-
]),
218-
(data: Uint8Array) =>
219-
console.log(
220-
data.length === 26 &&
221-
data[0] === "x".charCodeAt(0) &&
222-
data[1] === "y".charCodeAt(0)
223-
)
224-
) === FINISHED
225-
);
226-
227-
consumer = createChunkedEncodingConsumer();
228-
console.log(
229-
consumer(
230-
new Uint8Array([
231-
"1".charCodeAt(0),
232-
"a".charCodeAt(0),
233-
10,
234-
13,
235-
"x".charCodeAt(0),
236-
"y".charCodeAt(0),
237-
"x".charCodeAt(0),
238-
"y".charCodeAt(0),
239-
"x".charCodeAt(0),
240-
"y".charCodeAt(0),
241-
"x".charCodeAt(0),
242-
"y".charCodeAt(0),
243-
"x".charCodeAt(0),
244-
"y".charCodeAt(0),
245-
"x".charCodeAt(0),
246-
"y".charCodeAt(0),
247-
"x".charCodeAt(0),
248-
"y".charCodeAt(0),
249-
"x".charCodeAt(0),
250-
"y".charCodeAt(0),
251-
"x".charCodeAt(0),
252-
"y".charCodeAt(0),
253-
"x".charCodeAt(0),
254-
"y".charCodeAt(0),
255-
"x".charCodeAt(0),
256-
"y".charCodeAt(0),
257-
"x".charCodeAt(0),
258-
"y".charCodeAt(0),
259-
"x".charCodeAt(0),
260-
]),
261-
(data: Uint8Array) =>
262-
console.log(data.length === 25 && data[0] === "x".charCodeAt(0))
263-
) === READ_PAYL
264-
);
265-
console.log("test");
266-
console.log(
267-
consumer(
268-
new Uint8Array([
269-
"y".charCodeAt(0),
270-
10,
271-
13,
272-
"0".charCodeAt(0),
273-
10,
274-
13,
275-
10,
276-
13,
277-
]),
278-
(data: Uint8Array) =>
279-
console.log(data.length === 1 && data[0] === "y".charCodeAt(0))
280-
) === FINISHED
281-
);
282-
}
283-
selftest();
284-
*/

components/esp32-javascript/modules/esp32-javascript/configserver.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ function page(res, headline, text, cb, additionalHeadTags) {
130130
}
131131
res.setStatus(200);
132132
res.headers.set("content-type", "text/html");
133-
res.write("<!doctype html><html><head><title>esp32-javascript</title>\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, shrink-to-fit=no\">\n <style>\n body {\n font-family: monospace;\n font-size: 13pt;\n }\n .input {\n font-family: monospace;\n font-size: 13pt;\n }\n .fill {\n width: calc(100% - 146px);\n }\n .full {\n width: calc(100% - 16px);\n }\n .txt {\n height: 100px;\n }\n .formlabel {\n display: inline-block;\n width: 130px;\n }\n .formpad {\n padding: 8px;\n }\n .green {\n color: green;\n }\n .red {\n color: red;\n }\n .inline-form {\n display: inline;\n }\n .blink {\n animation: blinkanimation 1s linear infinite;\n }\n @keyframes blinkanimation {\n 50% {\n opacity: 0;\n }\n }\n </style>\n " + (additionalHeadTags ? additionalHeadTags : "") + "\n </head>\n <body><div><div><div><h1>" + headline + "</h1>");
133+
res.write("<!doctype html><html><head><title>esp32-javascript</title>\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, shrink-to-fit=no\">\n <style>\n body {\n font-family: monospace;\n font-size: 13pt;\n }\n .input {\n font-family: monospace;\n font-size: 13pt;\n }\n .fill {\n width: calc(100% - 146px);\n }\n .full {\n width: calc(100% - 16px);\n }\n .txt {\n height: 100px;\n }\n .formlabel {\n display: inline-block;\n }\n .formpad {\n padding: 8px;\n }\n .green {\n color: green;\n }\n .red {\n color: red;\n }\n .inline-form {\n display: inline;\n }\n .blink {\n animation: blinkanimation 1s linear infinite;\n }\n .nowrap {\n white-space: nowrap;\n }\n @keyframes blinkanimation {\n 50% {\n opacity: 0;\n }\n }\n </style>\n " + (additionalHeadTags ? additionalHeadTags : "") + "\n <script>\n function showpassword(label)\n {\n var inputId=label.parentElement.getAttribute(\"for\");\n document.getElementById(inputId).setAttribute(\"type\",\"text\");\n }\n </script>\n </head>\n <body><div><div><div><h1>" + headline + "</h1>");
134134
if (Array.isArray(text)) {
135135
res.write(text.join(""));
136136
}
@@ -216,12 +216,12 @@ function startConfigServer() {
216216
var config = configManager.config;
217217
page(res, "Setup", "" + (successMessage
218218
? "<div class=\"formpad green\">" + successMessage + "</div>"
219-
: "") + (errorMessage ? "<div class=\"formpad red\">" + errorMessage + "</div>" : "") + "<h2>Configuration</h2><h3>Wifi</h3><form action=\"/setup\" method=\"post\">\n <div class=\"formpad\"><label for=\"ssid\" class=\"formlabel\">SSID</label><input type=\"text\" name=\"ssid\" class=\"fill input\" value=\"" + (((_a = config.wifi) === null || _a === void 0 ? void 0 : _a.ssid) || "") + "\" /></div>\n <div class=\"formpad\"><label for=\"password\" class=\"formlabel\">Password</label><input type=\"text\" name=\"password\" class=\"fill input\" value=\"" + (((_b = config.wifi) === null || _b === void 0 ? void 0 : _b.password) || "") + "\" /></div>\n <div class=\"formpad\"><label for=\"bssid\" class=\"formlabel\">BSSID (optional)</label><input type=\"text\" name=\"bssid\" class=\"fill input\" value=\"" + (((_c = config.wifi) === null || _c === void 0 ? void 0 : _c.bssid) || "") + "\" /></div>\n <h3>Basic authentication</h3>\n <div class=\"formpad\"><label for=\"username\" class=\"formlabel\">Username</label><input type=\"text\" name=\"username\" class=\"fill input\" value=\"" + config.access.username + "\" /></div>\n <div class=\"formpad\"><label for=\"userpass\" class=\"formlabel\">Password</label><input type=\"text\" name=\"userpass\" class=\"fill input\" value=\"" + config.access.password + "\" /></div>\n <h3>JavaScript OTA</h3><div class=\"formpad\"><label for=\"url\" class=\"formlabel\">JS file url</label><input type=\"text\" name=\"url\" class=\"fill input\" value=\"" + (((_d = config.ota) === null || _d === void 0 ? void 0 : _d.url) || "") + "\" /></div>\n <div class=\"formpad\"><label for=\"offline\"><input type=\"checkbox\" name=\"offline\" value=\"true\" " + (((_e = config.ota) === null || _e === void 0 ? void 0 : _e.offline) ? "checked" : "") + "/> Offline Mode</label></div>\n <label for=\"script\" class=\"formpad\">Offline Script</label><div class=\"formpad\"><textarea name=\"script\" class=\"full input txt\">" + (((_f = config.ota) === null || _f === void 0 ? void 0 : _f.script) || "") + "</textarea></div>\n <div class=\"formpad\"><input type=\"submit\" value=\"Save\" class=\"formpad input\"/></div></form>\n <h2>Logs</h2>\n <div class=\"formpad\">\n <p>\n Showing last " + filelogging_1.LOG_FILE_NUM_LIMIT + " log files, with each having maximum of " + filelogging_1.LOG_FILE_SIZE_LIMIT / 1024 + " kB data.<br/>\n </p>\n " + getLogFileList()
219+
: "") + (errorMessage ? "<div class=\"formpad red\">" + errorMessage + "</div>" : "") + "<h2>Configuration</h2><h3>Wifi</h3><form action=\"/setup\" method=\"post\">\n <div class=\"formpad\"><label for=\"ssid\" class=\"formlabel\">SSID</label><br /><input type=\"text\" name=\"ssid\" class=\"full input\" value=\"" + (((_a = config.wifi) === null || _a === void 0 ? void 0 : _a.ssid) || "") + "\" /></div>\n <div class=\"formpad\"><label for=\"password\" class=\"formlabel\">Password (<a href=\"javascript:void(0)\" onclick=\"showpassword(this)\">Show</a>)</label><br /><input type=\"password\" name=\"password\" id=\"password\" class=\"full input\" value=\"" + (((_b = config.wifi) === null || _b === void 0 ? void 0 : _b.password) || "") + "\" /></div>\n <div class=\"formpad\"><label for=\"bssid\" class=\"formlabel\">BSSID (optional)</label></br /><input type=\"text\" name=\"bssid\" class=\"full input\" value=\"" + (((_c = config.wifi) === null || _c === void 0 ? void 0 : _c.bssid) || "") + "\" /></div>\n <h3>Basic authentication</h3>\n <div class=\"formpad\"><label for=\"username\" class=\"formlabel\">Username</label></br /><input type=\"text\" name=\"username\" class=\"full input\" value=\"" + config.access.username + "\" /></div>\n <div class=\"formpad\"><label for=\"userpass\" class=\"formlabel\">Password (<a href=\"javascript:void(0)\" onclick=\"showpassword(this)\">Show</a>)</label></br /><input type=\"password\" name=\"userpass\" id=\"userpass\" class=\"full input\" value=\"" + config.access.password + "\" /></div>\n <h3>JavaScript OTA</h3><div class=\"formpad\"><label for=\"url\" class=\"formlabel\">JS file url</label></br /><input type=\"text\" name=\"url\" class=\"full input\" value=\"" + (((_d = config.ota) === null || _d === void 0 ? void 0 : _d.url) || "") + "\" /></div>\n <div class=\"formpad\"><label for=\"offline\"><input type=\"checkbox\" name=\"offline\" value=\"true\" " + (((_e = config.ota) === null || _e === void 0 ? void 0 : _e.offline) ? "checked" : "") + "/> Offline Mode</label></div>\n <label for=\"script\" class=\"formpad\">Offline Script</label><div class=\"formpad\"><textarea name=\"script\" class=\"full input txt\">" + (((_f = config.ota) === null || _f === void 0 ? void 0 : _f.script) || "") + "</textarea></div>\n <div class=\"formpad\"><input type=\"submit\" value=\"Save\" class=\"formpad input\"/></div></form>\n <h2>Logs</h2>\n <div class=\"formpad\">\n <p>\n Showing last " + filelogging_1.LOG_FILE_NUM_LIMIT + " log files, with each having maximum of " + filelogging_1.LOG_FILE_SIZE_LIMIT / 1024 + " kB data.<br/>\n </p>\n " + getLogFileList()
220220
.map(function (e) {
221-
return e.filename + " (" + (e.size === undefined ? "?" : Math.floor(e.size / 1024)) + " kB) <form action=\"/viewlog\" method=\"post\" class=\"inline-form\"><button class=\"input\" type=\"submit\" name=\"file\" value=\"" + filelogging_1.FILE_LOGGING_DIRECTORY + "/" + e.filename + "\">View</button></form> <form action=\"/deletelog\" method=\"post\" class=\"inline-form\"><button class=\"input\" type=\"submit\" name=\"file\" value=\"" + filelogging_1.FILE_LOGGING_DIRECTORY + "/" + e.filename + "\">Delete</button></form><br />";
221+
return "<div>" + e.filename + " (" + (e.size === undefined ? "?" : Math.floor(e.size / 1024)) + " kB) <span class=\"nowrap\"><form action=\"/viewlog\" method=\"post\" class=\"inline-form\"><button class=\"input\" type=\"submit\" name=\"file\" value=\"" + filelogging_1.FILE_LOGGING_DIRECTORY + "/" + e.filename + "\">View</button></form>&nbsp;<form action=\"/deletelog\" method=\"post\" class=\"inline-form\"><button class=\"input\" type=\"submit\" name=\"file\" value=\"" + filelogging_1.FILE_LOGGING_DIRECTORY + "/" + e.filename + "\">Delete</button></form></span></div>";
222222
})
223223
.join("") + "\n </form>\n </div>\n \n " + (el_is_native_ota_supported()
224-
? "<h2>Native OTA Upgrade</h2>\n <form action=\"/native-ota\" method=\"post\" class=\"formpad\">\n <div class=\"formpad\"><label for=\"appbin\" class=\"formlabel\">URL to app binary</label><input type=\"text\" name=\"appbin\" class=\"fill input\" value=\"\" /></div>\n <div class=\"formpad\"><label for=\"modulesbin\" class=\"formlabel\">URL to modules binary</label><input type=\"text\" name=\"modulesbin\" class=\"fill input\" value=\"\" /></div>\n <div class=\"formpad\"><input type=\"submit\" value=\"Upgrade\" class=\"formpad input\" " + (upgradeStatus.status === "inprogress" ? "disabled" : "") + "/> " + (upgradeStatus.status !== "idle"
224+
? "<h2>Native OTA Upgrade</h2>\n <form action=\"/native-ota\" method=\"post\">\n <div class=\"formpad\"><label for=\"appbin\" class=\"formlabel\">URL to app binary</label><br /><input type=\"text\" name=\"appbin\" class=\"full input\" value=\"\" /></div>\n <div class=\"formpad\"><label for=\"modulesbin\" class=\"formlabel\">URL to modules binary</label><br /><input type=\"text\" name=\"modulesbin\" class=\"full input\" value=\"\" /></div>\n <div class=\"formpad\"><input type=\"submit\" value=\"Upgrade\" class=\"formpad input\" " + (upgradeStatus.status === "inprogress" ? "disabled" : "") + "/> " + (upgradeStatus.status !== "idle"
225225
? '<a href="/native-ota">Upgrade status</a>'
226226
: "") + "</div>\n </form>"
227227
: "") + "\n\n <h2>Request restart</h2>\n <form action=\"/restart\" method=\"post\"><div class=\"formpad\"><input type=\"submit\" value=\"Restart\" class=\"formpad input\"/></div></form>\n <h2>Uptime</h2>\n <div class=\"formpad\">\n Boot time: " + boot_1.getBootTime() + "\n </div>\n <div class=\"formpad\">\n Uptime (hours): " + Math.floor((Date.now() - boot_1.getBootTime().getTime()) / 10 / 60 / 60) /

0 commit comments

Comments
 (0)