serve common.js via serveSettingsJS

this got lost while backporting upstream code
This commit is contained in:
Frank
2025-12-19 13:25:15 +01:00
parent eeb4973a2e
commit 10c20b7a4b

View File

@@ -11,6 +11,8 @@
#endif #endif
#ifdef WLED_ENABLE_PIXELFORGE #ifdef WLED_ENABLE_PIXELFORGE
#include "html_pixelforge.h" #include "html_pixelforge.h"
static const char _pixelforge_htm[] PROGMEM = "/pixelforge.htm";
static const char _common_js[] PROGMEM = "/common.js";
#endif #endif
#include "html_cpal.h" #include "html_cpal.h"
@@ -22,6 +24,7 @@ static const char s_unlock_cfg [] PROGMEM = "Please unlock settings using PIN co
static const char s_cache_control[] PROGMEM = "Cache-Control"; static const char s_cache_control[] PROGMEM = "Cache-Control";
//static const char s_no_store[] PROGMEM = "no-store"; //static const char s_no_store[] PROGMEM = "no-store";
//static const char s_expires[] PROGMEM = "Expires"; //static const char s_expires[] PROGMEM = "Expires";
static const char enc_gzip[] PROGMEM = "gzip";
/* /*
* Integrated HTTP web server page declarations * Integrated HTTP web server page declarations
@@ -452,19 +455,18 @@ void initServer()
#endif #endif
#ifdef WLED_ENABLE_PIXELFORGE #ifdef WLED_ENABLE_PIXELFORGE
static const char _pixelforge_htm[] PROGMEM = "/pixelforge.htm";
server.on(_pixelforge_htm, HTTP_GET, [](AsyncWebServerRequest *request) { server.on(_pixelforge_htm, HTTP_GET, [](AsyncWebServerRequest *request) {
//handleStaticContent(request, FPSTR(_pixelforge_htm), 200, FPSTR(CONTENT_TYPE_HTML), PAGE_pixelforge, PAGE_pixelforge_length); //handleStaticContent(request, FPSTR(_pixelforge_htm), 200, FPSTR(CONTENT_TYPE_HTML), PAGE_pixelforge, PAGE_pixelforge_length);
if (handleFileRead(request, FPSTR(_pixelforge_htm))) return; if (handleFileRead(request, FPSTR(_pixelforge_htm))) return;
if (handleIfNoneMatchCacheHeader(request)) return; if (handleIfNoneMatchCacheHeader(request)) return;
AsyncWebServerResponse *response = request->beginResponse_P(200, "text/html", PAGE_pixelforge, PAGE_pixelforge_L); AsyncWebServerResponse *response = request->beginResponse_P(200, FPSTR(CONTENT_TYPE_HTML), PAGE_pixelforge, PAGE_pixelforge_L);
response->addHeader(FPSTR(s_content_enc),"gzip"); response->addHeader(FPSTR(s_content_enc),FPSTR(enc_gzip));
setStaticContentCacheHeaders(response); setStaticContentCacheHeaders(response);
request->send(response); request->send(response);
}); });
server.on("/common.js", HTTP_GET, [](AsyncWebServerRequest *request){ server.on(_common_js, HTTP_GET, [](AsyncWebServerRequest *request){
AsyncWebServerResponse *response = request->beginResponse_P(200, "application/javascript", JS_common, JS_common_length); AsyncWebServerResponse *response = request->beginResponse_P(200, FPSTR(CONTENT_TYPE_JAVASCRIPT), JS_common, JS_common_length);
response->addHeader(FPSTR(s_content_enc),"gzip"); response->addHeader(FPSTR(s_content_enc),FPSTR(enc_gzip));
setStaticContentCacheHeaders(response); setStaticContentCacheHeaders(response);
request->send(response); request->send(response);
}); });
@@ -618,6 +620,18 @@ void serveSettingsJS(AsyncWebServerRequest* request)
{ {
char buf[SETTINGS_STACK_BUF_SIZE+37] = { '\0' }; // WLEDMM ensure buffer is cleared initially char buf[SETTINGS_STACK_BUF_SIZE+37] = { '\0' }; // WLEDMM ensure buffer is cleared initially
buf[0] = 0; buf[0] = 0;
#ifdef WLED_ENABLE_PIXELFORGE
// serve common.js if requested by subPage = 254 (.js)
if (request->url().indexOf(FPSTR(_common_js)) > 0) {
AsyncWebServerResponse *response = request->beginResponse_P(200, FPSTR(CONTENT_TYPE_JAVASCRIPT), JS_common, JS_common_length);
response->addHeader(FPSTR(s_content_enc),FPSTR(enc_gzip));
setStaticContentCacheHeaders(response);
request->send(response);
return;
}
#endif
byte subPage = request->arg(F("p")).toInt(); byte subPage = request->arg(F("p")).toInt();
if (subPage > 10) { if (subPage > 10) {
strcpy_P(buf, PSTR("alert('Settings for this request are not implemented.');")); strcpy_P(buf, PSTR("alert('Settings for this request are not implemented.');"));