Easier holiday/special events handling for background images.
This commit is contained in:
parent
c4201d9a2a
commit
f411e07fb4
@ -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<hol.length; i++) {
|
||||
var yr = hol[i][0]==0 ? today.getFullYear() : hol[i][0];
|
||||
var hs = new Date(yr,hol[i][1],hol[i][2]);
|
||||
var he = new Date(hs)
|
||||
he.setDate(he.getDate() + hol[i][3]);
|
||||
if (today>=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;
|
||||
|
Loading…
Reference in New Issue
Block a user