Archiving old website
This commit is contained in:
parent
8856faae67
commit
8739af9050
45 changed files with 285 additions and 120 deletions
81
script.js
81
script.js
|
@ -1,21 +1,3 @@
|
|||
function randomBackground(backgrounds) {
|
||||
let background = selectRandom(backgrounds);
|
||||
console.log("Choosen random background image:", 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";
|
||||
}
|
||||
|
||||
function selectRandom(array) {
|
||||
let choosen = array[Math.floor(Math.random() * array.length)];
|
||||
return choosen;
|
||||
}
|
||||
|
||||
function copyText(text) {
|
||||
try {
|
||||
|
@ -25,66 +7,3 @@ function copyText(text) {
|
|||
console.error('Failed to copy "' + text + '":', error);
|
||||
}
|
||||
}
|
||||
|
||||
function strBetweenStrings(startStr, endStr, str) {
|
||||
pos = str.indexOf(startStr) + startStr.length;
|
||||
return str.substring(pos, str.indexOf(endStr, pos));
|
||||
}
|
||||
|
||||
function getStringOfPageContent(url, callbackFunction) {
|
||||
$.get(url, function(data) {
|
||||
callbackFunction(data);
|
||||
});
|
||||
};
|
||||
|
||||
function getFilesInFolder(pageContent) { // Needs auto file indexing
|
||||
// console.log(pageContent);
|
||||
let contentArray = pageContent.split("\n");
|
||||
|
||||
let files = [];
|
||||
|
||||
for (let line in contentArray) {
|
||||
if (contentArray[line].includes("<li>")) {
|
||||
files.push(strBetweenStrings('"', '"', contentArray[line]));
|
||||
}
|
||||
}
|
||||
|
||||
files.shift();
|
||||
// console.log(files);
|
||||
|
||||
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)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue