From 6a52a1dc636b89c6e6a734db26d91ca97f1ce3f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Kristan?= Date: Wed, 18 Aug 2021 13:41:54 +0200 Subject: [PATCH] Add option to load custom CSS and custom holidays.json --- wled00/data/index.js | 72 +- wled00/data/settings_ui.htm | 8 +- wled00/html_settings.h | 8 +- wled00/html_ui.h | 1673 ++++++++++++++++++----------------- wled00/wled.h | 2 +- 5 files changed, 892 insertions(+), 871 deletions(-) diff --git a/wled00/data/index.js b/wled00/data/index.js index 893e5b66..4e7ad6b7 100644 --- a/wled00/data/index.js +++ b/wled00/data/index.js @@ -26,7 +26,8 @@ var lastinfo = {}; var ws; var cfg = { theme:{base:"dark", bg:{url:""}, alpha:{bg:0.6,tab:0.8}, color:{bg:""}}, - comp :{colors:{picker: true, rgb: false, quick: true, hex: false}, labels:true, pcmbot:false, pid:true, seglen:false} + comp :{colors:{picker: true, rgb: false, quick: true, hex: false}, + labels:true, pcmbot:false, pid:true, seglen:false, css:true, hdays:false} }; var hol = [ [0,11,24,4,"https://aircoookie.github.io/xmas.png"], // christmas @@ -169,6 +170,19 @@ function loadBg(iUrl) }); } +function getHdayBg() +{ + var today = new Date(); + for (var i=0; i=hs && today { - return res.json(); - }) - .then(json => { - if (Array.isArray(json)) hol = json; - //TODO: do some parsing first - }) - .catch(function(error){ - console.log("holidays.json does not contain array of holidays. Defaults loaded."); - }) - .finally(()=>{ - var today = new Date(); - for (var i=0; i=hs && today { + return res.json(); + }) + .then(json => { + if (Array.isArray(json)) hol = json; + //TODO: do some parsing first + }) + .catch(function(error){ + console.log("holidays.json does not contain array of holidays. Defaults loaded."); + }) + .finally(()=>{ + iUrl = getHdayBg(); + if (iUrl!=="") loadBg(iUrl); + }); + } else { + iUrl = getHdayBg(); + if (iUrl!=="") loadBg(iUrl); + } } else - loadBg(cfg.theme.bg.url); - loadSkinCSS('skinCss'); + loadBg(iUrl); + if (cfg.comp.css) loadSkinCSS('skinCss'); var cd = gId('csl').children; for (var i = 0; i < cd.length; i++) cd[i].style.backgroundColor = "rgb(0, 0, 0)"; @@ -1210,7 +1222,7 @@ function requestJson(command=null) command.v = true; // force complete /json/si API response command.time = Math.floor(Date.now() / 1000); var t = d.getElementById('tt'); - if (command.transition===null && t.validity.valid) { + if (t.validity.valid && command.transition==null) { var tn = parseInt(t.value*10); if (tn != tr) command.transition = tn; } diff --git a/wled00/data/settings_ui.htm b/wled00/data/settings_ui.htm index 9c72c3ac..c387f81b 100644 --- a/wled00/data/settings_ui.htm +++ b/wled00/data/settings_ui.htm @@ -20,7 +20,9 @@ }, "pcmbot": "Show bottom tab bar in PC mode", "pid": "Show preset IDs", - "seglen": "Use LED Count instead of Stop LED on segments" + "seglen": "Set segment length instead of stop LED", + "css": "Enable custom CSS", + "hdays": "Enable custom Holidays list" }, "theme":{ "alpha": { @@ -237,7 +239,9 @@ BG image URL:
Random BG image:
-
Skinning CSS:
+ :
+
Custom CSS:
+ :
Holidays:

diff --git a/wled00/html_settings.h b/wled00/html_settings.h index 18e177a1..51fba807 100644 --- a/wled00/html_settings.h +++ b/wled00/html_settings.h @@ -192,7 +192,7 @@ const char PAGE_settings_dmx[] PROGMEM = R"=====()====="; // Autogenerated from wled00/data/settings_ui.htm, do not edit!! const char PAGE_settings_ui[] PROGMEM = R"=====(UI Settings