From f411e07fb411e4276fd54ffde93453027f582ed0 Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Mon, 12 Apr 2021 23:00:22 +0200 Subject: [PATCH 1/2] Easier holiday/special events handling for background images. --- wled00/data/index.js | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/wled00/data/index.js b/wled00/data/index.js index 0b62fcfe..cdbf1c3f 100644 --- a/wled00/data/index.js +++ b/wled00/data/index.js @@ -151,13 +151,25 @@ function cTheme(light) { function loadBg(iUrl) { let bg = d.getElementById('bg'); - let img = d.createElement("img"); - img.src = iUrl; - if (iUrl == "") { - var today = new Date(); - if (today.getMonth() == 11 && (today.getDate() > 23 && today.getDate() < 28)) img.src = "https://aircoookie.github.io/xmas.png"; - else if (today.getMonth() == 3 && (today.getDate() > 3 && today.getDate() < 6)) img.src = "https://aircoookie.github.io/easter.png"; - } + let img = d.createElement("img"); + img.src = iUrl; + if (iUrl == "") { + var today = new Date(); + var hol = [ + [0,11,24,5,"https://aircoookie.github.io/xmas.png"], // christmas + [0,2,17,1,"https://images.alphacoders.com/491/491123.jpg"], // st. Patrick's day + [2022,3,16,3,"https://aircoookie.github.io/easter.png"], + [2023,3,8,3,"https://aircoookie.github.io/easter.png"], + [2024,2,30,3,"https://aircoookie.github.io/easter.png"] + ] + for (var i=0; i=hs && today<=he) img.src = hol[i][4]; + } + } img.addEventListener('load', (event) => { var a = parseFloat(cfg.theme.alpha.bg); if (isNaN(a)) a = 0.6; From afe5f1946405be6073d2033574a590645bac5c2c Mon Sep 17 00:00:00 2001 From: cschwinne Date: Wed, 14 Apr 2021 00:44:07 +0200 Subject: [PATCH 2/2] Update holiday BG durations Fix semicolons --- wled00/data/index.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/wled00/data/index.js b/wled00/data/index.js index cdbf1c3f..6501a5f4 100644 --- a/wled00/data/index.js +++ b/wled00/data/index.js @@ -156,16 +156,16 @@ function loadBg(iUrl) { if (iUrl == "") { var today = new Date(); var hol = [ - [0,11,24,5,"https://aircoookie.github.io/xmas.png"], // christmas + [0,11,24,4,"https://aircoookie.github.io/xmas.png"], // christmas [0,2,17,1,"https://images.alphacoders.com/491/491123.jpg"], // st. Patrick's day - [2022,3,16,3,"https://aircoookie.github.io/easter.png"], - [2023,3,8,3,"https://aircoookie.github.io/easter.png"], - [2024,2,30,3,"https://aircoookie.github.io/easter.png"] - ] + [2022,3,17,2,"https://aircoookie.github.io/easter.png"], + [2023,3,9,2,"https://aircoookie.github.io/easter.png"], + [2024,2,31,2,"https://aircoookie.github.io/easter.png"] + ]; for (var i=0; i=hs && today<=he) img.src = hol[i][4]; }