From 27a97dec16cd3b62db66ae54fe45849ae4dc86c2 Mon Sep 17 00:00:00 2001 From: Ted Hess Date: Sun, 16 Apr 2023 15:51:11 -0400 Subject: [PATCH] Static web pages: - Move loading .js scripts from to for faster rendering - Enable back-button support for file system/editor navigation - Close WebSocket when navigating away from /cp/serial - Use better looking Blinka icon. --- .../shared/web_workflow/static/blinka_16x16.ico | Bin 318 -> 0 bytes .../shared/web_workflow/static/blinka_32x32.ico | Bin 0 -> 4414 bytes .../shared/web_workflow/static/directory.html | 2 +- .../shared/web_workflow/static/directory.js | 10 ++++++++++ .../shared/web_workflow/static/serial.html | 3 ++- supervisor/shared/web_workflow/static/serial.js | 11 +++++++++++ .../shared/web_workflow/static/welcome.html | 2 +- supervisor/shared/web_workflow/web_workflow.c | 4 ++-- 8 files changed, 27 insertions(+), 5 deletions(-) delete mode 100644 supervisor/shared/web_workflow/static/blinka_16x16.ico create mode 100644 supervisor/shared/web_workflow/static/blinka_32x32.ico diff --git a/supervisor/shared/web_workflow/static/blinka_16x16.ico b/supervisor/shared/web_workflow/static/blinka_16x16.ico deleted file mode 100644 index ff2937dfee32c98d6a34162b96e5d8b4ee8aafe6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 318 zcmZ{fu}T9$6h-gGfMo^?+sIUlrL$d-4Ve+GC01)2wlI}NB3RjM`m7&dXJ?ZEi)q5* zhxiG`N<HYMX~zRyXl#7ft3uVT~Gu!kQNqyfCl5U>@S)=YSSD0G17(^w%NaXQTuC Pb%9L^{7eaRP19`w1vX@( diff --git a/supervisor/shared/web_workflow/static/blinka_32x32.ico b/supervisor/shared/web_workflow/static/blinka_32x32.ico new file mode 100644 index 0000000000000000000000000000000000000000..5aca98376a1f7e593ebd9cf41a808512c2135635 GIT binary patch literal 4414 zcmd^BX;4#F6n=SG-XmlONeGrD5E6J{RVh+e928U#MG!$jWvO+UsvWh`x&VqGNx*en zx=qox7Dqv{kPwo%fZC$dDwVpRtz{HzTkSs8QhG0)%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QW)Z>J2a=dTriuvezBmu16`tM2fm7Q@d4^iqII-xFpwHGI zn9CL}QE*1vdj2PX{PIuqOe5dracsciH6OlAZATvE8rj6ykqdIjal2 z0S0S~PwHb-5?OQ-tU-^KTG@XNrEVSvo|HIP?H;7ZhYeZkhSqh-{reE!5di;1zk$#Y zCe7rOnlzFYJ6Z#Hm$GoidKB=2HBCwm`BbZVeZY4ukmG%1uz7p2URs6c9j-Gjj^oQV zsdDb3@k2e`C$1I5ML5U0Qs0C1GAp^?!*`=|Nm(vWz3j*j*8ucum2;r0^-6Aca=Gv) zc%}&;!+_*S2tlnnJnz0EKeRmw-Y!@9ob!XQBwiv}^u9MkaXHvM=!<3YX;+2#5Cj5pp?FEK750S3BgeSDtaE^ zXUM@xoV6yBFKfzvY20V&Lr0yC - @@ -21,4 +20,5 @@
+📁  + diff --git a/supervisor/shared/web_workflow/static/directory.js b/supervisor/shared/web_workflow/static/directory.js index a89d5e5602..2068ca38ea 100644 --- a/supervisor/shared/web_workflow/static/directory.js +++ b/supervisor/shared/web_workflow/static/directory.js @@ -267,3 +267,13 @@ new_directory_name.oninput = () => { } window.onhashchange = refresh_list; + +window.addEventListener("pageshow", function (event) { + var historyTraversal = event.persisted || + (typeof window.performance != "undefined" && + window.performance.navigation.type === 2); + if (historyTraversal) { + // Handle page restore. + window.location.reload(); + } +}); diff --git a/supervisor/shared/web_workflow/static/serial.html b/supervisor/shared/web_workflow/static/serial.html index 9193953443..24fb3a3d32 100644 --- a/supervisor/shared/web_workflow/static/serial.html +++ b/supervisor/shared/web_workflow/static/serial.html @@ -4,7 +4,6 @@ Simple client - @@ -16,11 +15,13 @@
Ctrl +
+ diff --git a/supervisor/shared/web_workflow/static/serial.js b/supervisor/shared/web_workflow/static/serial.js index 5c644795a0..52cde95396 100644 --- a/supervisor/shared/web_workflow/static/serial.js +++ b/supervisor/shared/web_workflow/static/serial.js @@ -72,6 +72,17 @@ input.addEventListener("beforeinput", function(e) { } }); +window.addEventListener("unload", function() { + if (ws.readyState == WebSocket.OPEN) { + ws.close(); + } +}); + +let ctrl_b = document.querySelector("#b"); +ctrl_b.onclick = function() { + ws.send("\x02"); +} + let ctrl_c = document.querySelector("#c"); ctrl_c.onclick = function() { ws.send("\x03"); diff --git a/supervisor/shared/web_workflow/static/welcome.html b/supervisor/shared/web_workflow/static/welcome.html index efbb30e312..ffd23b72e9 100644 --- a/supervisor/shared/web_workflow/static/welcome.html +++ b/supervisor/shared/web_workflow/static/welcome.html @@ -4,7 +4,6 @@ CircuitPython - @@ -30,5 +29,6 @@

Here are other CircuitPython devices on your network:

+ diff --git a/supervisor/shared/web_workflow/web_workflow.c b/supervisor/shared/web_workflow/web_workflow.c index d24547dd09..30ff2004a7 100644 --- a/supervisor/shared/web_workflow/web_workflow.c +++ b/supervisor/shared/web_workflow/web_workflow.c @@ -1002,7 +1002,7 @@ STATIC_FILE(edit_js); STATIC_FILE(style_css); STATIC_FILE(serial_html); STATIC_FILE(serial_js); -STATIC_FILE(blinka_16x16_ico); +STATIC_FILE(blinka_32x32_ico); static void _reply_static(socketpool_socket_obj_t *socket, _request *request, const uint8_t *response, size_t response_len, const char *content_type) { uint32_t total_length = response_len; @@ -1303,7 +1303,7 @@ static bool _reply(socketpool_socket_obj_t *socket, _request *request) { } else if (strcmp(request->path, "/favicon.ico") == 0) { // TODO: Autogenerate this based on the blinka bitmap and change the // palette based on MAC address. - _REPLY_STATIC(socket, request, blinka_16x16_ico); + _REPLY_STATIC(socket, request, blinka_32x32_ico); } else { _reply_missing(socket, request); }