2024-01-18 14:26:34 +01:00
|
|
|
document.addEventListener("DOMContentLoaded", function () {
|
|
|
|
const update = function () {
|
|
|
|
fetch("https://spaceapi.c3re.de/")
|
|
|
|
.then(function (response) {
|
|
|
|
return response.json();
|
|
|
|
})
|
|
|
|
.then(function (data) {
|
2024-01-27 10:13:23 +01:00
|
|
|
let body=document.getElementsByTagName("body")[0];
|
|
|
|
if (data.state.open) {
|
|
|
|
body.classList.remove("door_closed");
|
|
|
|
body.classList.add("door_open");
|
|
|
|
} else {
|
|
|
|
body.classList.remove("door_open");
|
|
|
|
body.classList.add("door_closed");
|
|
|
|
}
|
2024-01-18 14:26:34 +01:00
|
|
|
document
|
|
|
|
.getElementById("ds-img")
|
|
|
|
.setAttribute(
|
|
|
|
"src",
|
|
|
|
data.state.open ? data.state.icon.open : data.state.icon.closed
|
|
|
|
);
|
|
|
|
document.getElementById("ds-status").innerHTML = data.state.open
|
|
|
|
? "Geöffnet"
|
|
|
|
: "Geschlossen";
|
2024-01-08 21:25:56 +01:00
|
|
|
|
2024-01-18 14:26:34 +01:00
|
|
|
document.getElementById("ds-temp").innerHTML =
|
|
|
|
"" +
|
|
|
|
data.sensors.temperature[0].value +
|
|
|
|
data.sensors.temperature[0].unit;
|
|
|
|
const lastchange = new Date(data.state.lastchange * 1000);
|
|
|
|
document.getElementById("ds-date").innerHTML =
|
|
|
|
lastchange.getDate().toString().padStart(2, "0") +
|
|
|
|
"." +
|
|
|
|
(lastchange.getMonth() + 1).toString().padStart(2, "0") +
|
|
|
|
"." +
|
|
|
|
lastchange.getFullYear() +
|
|
|
|
" " +
|
|
|
|
lastchange.getHours().toString().padStart(2, "0") +
|
|
|
|
":" +
|
|
|
|
lastchange.getMinutes().toString().padStart(2, "0");
|
|
|
|
});
|
|
|
|
};
|
|
|
|
update();
|
|
|
|
setInterval(update, 10000);
|
2024-01-08 21:25:56 +01:00
|
|
|
});
|