Merge pull request #1890 from blazoncek/holiday-list
Easier holiday/special events handling for background images.
This commit is contained in:
commit
3d2336aac1
@ -151,13 +151,25 @@ function cTheme(light) {
|
|||||||
|
|
||||||
function loadBg(iUrl) {
|
function loadBg(iUrl) {
|
||||||
let bg = d.getElementById('bg');
|
let bg = d.getElementById('bg');
|
||||||
let img = d.createElement("img");
|
let img = d.createElement("img");
|
||||||
img.src = iUrl;
|
img.src = iUrl;
|
||||||
if (iUrl == "") {
|
if (iUrl == "") {
|
||||||
var today = new Date();
|
var today = new Date();
|
||||||
if (today.getMonth() == 11 && (today.getDate() > 23 && today.getDate() < 28)) img.src = "https://aircoookie.github.io/xmas.png";
|
var hol = [
|
||||||
else if (today.getMonth() == 3 && (today.getDate() > 3 && today.getDate() < 6)) img.src = "https://aircoookie.github.io/easter.png";
|
[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,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<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) => {
|
img.addEventListener('load', (event) => {
|
||||||
var a = parseFloat(cfg.theme.alpha.bg);
|
var a = parseFloat(cfg.theme.alpha.bg);
|
||||||
if (isNaN(a)) a = 0.6;
|
if (isNaN(a)) a = 0.6;
|
||||||
|
Loading…
Reference in New Issue
Block a user