From f411e07fb411e4276fd54ffde93453027f582ed0 Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Mon, 12 Apr 2021 23:00:22 +0200 Subject: [PATCH] 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 0b62fcfe3..cdbf1c3f1 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;