From 56796e7e9b2b700530cd7b068f5599d7251328bd Mon Sep 17 00:00:00 2001 From: Manuel Piroch Date: Sun, 21 Apr 2024 06:16:27 -0300 Subject: [PATCH 01/12] add gifplayer.htm --- tools/cdata.js | 5 +- wled00/data/gifplayer/gifplayer.htm | 1132 +++++++++++++++++++++++++++ wled00/wled_server.cpp | 10 + 3 files changed, 1146 insertions(+), 1 deletion(-) create mode 100644 wled00/data/gifplayer/gifplayer.htm diff --git a/tools/cdata.js b/tools/cdata.js index 561d390ef8..5e2bd45ac5 100644 --- a/tools/cdata.js +++ b/tools/cdata.js @@ -224,6 +224,8 @@ writeHtmlGzipped("wled00/data/simple.htm", "wled00/html_simple.h", 'simple'); writeHtmlGzipped("wled00/data/pixart/pixart.htm", "wled00/html_pixart.h", 'pixart'); writeHtmlGzipped("wled00/data/cpal/cpal.htm", "wled00/html_cpal.h", 'cpal'); writeHtmlGzipped("wled00/data/pxmagic/pxmagic.htm", "wled00/html_pxmagic.h", 'pxmagic'); +writeHtmlGzipped("wled00/data/gifplayer/gifplayer.htm", "wled00/html_gifplayer.h", 'gifplayer'); + /* writeChunks( "wled00/data", @@ -247,7 +249,8 @@ writeChunks( filter: "html-minify-ui", } ], - "wled00/html_simplex.h" + "wled00/html_simplex.h", + "wled00/html_gifplayer.h" ); */ writeChunks( diff --git a/wled00/data/gifplayer/gifplayer.htm b/wled00/data/gifplayer/gifplayer.htm new file mode 100644 index 0000000000..4c011698e9 --- /dev/null +++ b/wled00/data/gifplayer/gifplayer.htm @@ -0,0 +1,1132 @@ + + + + + + GIF Player + + + + +
+
+
+ GIFPLAYER +
+
+
+
+
+ +
+
+ +
+
+ +
+
+
+ + +
+
+ +

+ +
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ + + diff --git a/wled00/wled_server.cpp b/wled00/wled_server.cpp index b6e786e6d0..e27aa3fe11 100644 --- a/wled00/wled_server.cpp +++ b/wled00/wled_server.cpp @@ -9,6 +9,9 @@ #ifdef WLED_ENABLE_PIXART #include "html_pixart.h" #endif +#ifndef WLED_DISABLE_GIFPLAYER + #include "html_gifplayer.h" +#endif #include "html_cpal.h" /* @@ -410,6 +413,13 @@ void initServer() }); #endif + #ifndef WLED_DISABLE_GIFPLAYER + static const char _gifplayer_htm[] PROGMEM = "/gifplayer.htm"; + server.on(_gifplayer_htm, HTTP_GET, [](AsyncWebServerRequest *request) { + handleStaticContent(request, FPSTR(_gifplayer_htm), 200, FPSTR(CONTENT_TYPE_HTML), PAGE_gifplayer, PAGE_gifplayer_L); + }); + #endif + server.on("/cpal.htm", HTTP_GET, [](AsyncWebServerRequest *request){ if (handleFileRead(request, "/cpal.htm")) return; if (handleIfNoneMatchCacheHeader(request)) return; From d3a6016905fb3ee24a0634543c6c94e3ffcdf640 Mon Sep 17 00:00:00 2001 From: Manuel Piroch Date: Sun, 21 Apr 2024 14:16:09 -0300 Subject: [PATCH 02/12] add GIF button in palettes pane --- wled00/data/index.htm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/wled00/data/index.htm b/wled00/data/index.htm index 57fca4cf8e..b926cfe5e4 100644 --- a/wled00/data/index.htm +++ b/wled00/data/index.htm @@ -185,6 +185,9 @@ +
+ +

Color palette

From 250a759d46f6c9af0c2bdb18b8ba7108a1059e74 Mon Sep 17 00:00:00 2001 From: Manuel Piroch Date: Sun, 21 Apr 2024 14:33:10 -0300 Subject: [PATCH 03/12] small fixes - loading spinner now showing on upload - hostname value now trimmed and checked for change before refresh - remove invisible upload button --- wled00/data/gifplayer/gifplayer.htm | 35 ++++++++--------------------- 1 file changed, 9 insertions(+), 26 deletions(-) diff --git a/wled00/data/gifplayer/gifplayer.htm b/wled00/data/gifplayer/gifplayer.htm index 4c011698e9..6e7e4039ad 100644 --- a/wled00/data/gifplayer/gifplayer.htm +++ b/wled00/data/gifplayer/gifplayer.htm @@ -574,18 +574,6 @@ style="display: none" />
-
-
- -
@@ -952,24 +940,30 @@

method: "POST", body: formData, }; + showLoading(); try { const response = await fetch(url, options); if (!response.ok) { throw new Error(response.status); } toast(`${file.name} successfully uploaded`, "success"); - images(); - storage(); } catch (error) { const msg = `Error uploading image: ${error}`; console.error(msg); toast(msg, "error"); + } finally { + await images(); + await storage(); + hideLoading(); } } // reload all info on change of hostname input hostname.addEventListener("blur", async () => { - WLED_URL = `${protocol}//${hostname.value}`; + hostname.value = hostname.value.trim(); + newWledUrl = `${protocol}//${hostname.value}`; + if (WLED_URL == newWledUrl) { return; } + WLED_URL = newWledUrl // replace url in browser var url = window.location.protocol + @@ -1000,8 +994,6 @@

false ); - gId("btnUpload").addEventListener("click", upload, false); - gId("dropzone").addEventListener("dragover", (e) => { e.preventDefault(); }); @@ -1015,8 +1007,6 @@

source.files = e.dataTransfer.files; const { name } = source.files[0]; - // gId("dropzoneLabel").textContent = `Image ${name} selected!`; - btnUpload.removeAttribute("disabled"); upload(); }); @@ -1033,14 +1023,7 @@

return; } const { name } = e.target.files[0]; - // dropzoneLabel.textContent = `Image ${name} selected!`; - btnUpload.removeAttribute("disabled"); - console.log("test"); upload(); - } else { - // dropzoneLabel.textContent = - // "Drag and drop a file here or click to select a file"; - btnUpload.setAttribute("disabled", ""); } }); From 0882e31c0d4ac174b383110b39d68a64ea45501e Mon Sep 17 00:00:00 2001 From: Manuel Piroch Date: Sun, 21 Apr 2024 16:55:15 -0300 Subject: [PATCH 04/12] show ID of saved preset --- wled00/data/gifplayer/gifplayer.htm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wled00/data/gifplayer/gifplayer.htm b/wled00/data/gifplayer/gifplayer.htm index 6e7e4039ad..831c47d7ec 100644 --- a/wled00/data/gifplayer/gifplayer.htm +++ b/wled00/data/gifplayer/gifplayer.htm @@ -915,7 +915,7 @@

const { success } = await response.json(); if (success) { - toast("Request sent successfully"); + toast(`Saved as preset with ID ${id}`); window.parent.postMessage("loadPresets", WLED_URL); } } catch (error) { From babc389a45d63835ca459ab5dbbcb6982ec57fa5 Mon Sep 17 00:00:00 2001 From: Manuel Piroch Date: Wed, 24 Apr 2024 11:08:40 -0300 Subject: [PATCH 05/12] turn hostname red on error, reduce connection timeouts --- wled00/data/gifplayer/gifplayer.htm | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/wled00/data/gifplayer/gifplayer.htm b/wled00/data/gifplayer/gifplayer.htm index 831c47d7ec..a2da51325b 100644 --- a/wled00/data/gifplayer/gifplayer.htm +++ b/wled00/data/gifplayer/gifplayer.htm @@ -221,6 +221,10 @@ text-align: center; } + #hostname.error { + color: var(--error-light); + } + .dropzone { border: 1px dashed var(--gray-light); background-color: var(--gray-dark); @@ -574,7 +578,6 @@ style="display: none" /> -