This commit is contained in:
kleines Filmröllchen 2024-11-18 12:31:22 +01:00
commit a486b7bbb7
Signed by: filmroellchen
SSH key fingerprint: SHA256:NarU6J/XgCfEae4rbei0YIdN2pYaYDccarK6R53dnc8
11 changed files with 426 additions and 0 deletions

31
static/main.js Normal file
View file

@ -0,0 +1,31 @@
import hackcal from "./dbkcalendar.js";
const refreshRate = 60 * 1000;
function checkSpace() {
const icon = document.getElementById("space-image");
let openText = "";
fetch("https://spaceapi.ctbk.de/")
.then((response) => response.json())
.then((data) => {
if (data.state.open) {
openText = "Offen";
icon.src = data.state.icon.open;
} else {
openText = "Geschlossen";
icon.src = data.state.icon.closed;
}
icon.alt = "Der Space ist " + openText;
console.log("Icon: " + icon.src);
})
.catch((error) => {
console.error(error);
});
}
const interval = setInterval(() => {
checkSpace();
}, refreshRate);
document.addEventListener("DOMContentLoaded", checkSpace);
document.addEventListener("DOMContentLoaded", hackcal);