Added halloween backgrounds.

This commit is contained in:
The Wobbler 2023-10-24 19:40:17 +02:00
parent b349f68bea
commit 7bcdbf2b2e
9 changed files with 65 additions and 47 deletions

View file

@ -2,7 +2,11 @@ function randomBackground(backgrounds) {
let background = selectRandom(backgrounds);
console.log("Choosen random background image:", background);
document.getElementById("background").style.backgroundImage = "url(https://i21k.de/emil/backgrounds/" + background + ")";
if (!background.includes("backgrounds/")) {
background = "backgrounds/" + background
}
document.getElementById("background").style.backgroundImage = "url(" + background + ")";
// let div_height = document.getElementById("background").offsetHeight;
// let half_div_height = (0 - div_height) / 2;
// document.getElementById("background").style.backgroundPosition = "0% " + half_div_height.toString() + "px";
@ -51,5 +55,36 @@ function getFilesInFolder(pageContent) { // Needs auto file indexing
return files;
};
function setBackground(bla = "") {
let currentDate = new Date();
let currentMonth = currentDate.getMonth();
let currentDay = currentDate.getDay();
if (currentMonth == 9) {
if (currentDay > 0 && currentDay < 20) {
getStringOfPageContent(bla + "backgrounds/halloween", function(pageContent) {
let backgrounds = getFilesInFolder(pageContent);
let backgroundNumber = 0;
while (backgroundNumber < backgrounds.length) {
backgrounds[backgroundNumber] = bla + "backgrounds/halloween/" + backgrounds[backgroundNumber];
backgroundNumber++;
}
randomBackground(backgrounds);
});
}
} else {
getStringOfPageContent("backgrounds", function(pageContent) {
let backgrounds = getFilesInFolder(pageContent);
randomBackground(backgrounds);
});
}
}
// getStringOfPageContent("backgrounds", getFilesInFolder)