Initial commit
This commit is contained in:
commit
29f9d7c880
25 changed files with 985 additions and 0 deletions
20
js/vanilla.spaceapi.js
Normal file
20
js/vanilla.spaceapi.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
Include spaceapi status | Chaostreff Backnang | @paddy
|
||||
*/
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
|
||||
var spaceapi_uri = "/spaceapi/";
|
||||
var refresh_time = 60000;
|
||||
|
||||
setInterval(function refresh_time() {
|
||||
|
||||
fetch(spaceapi_uri).then(res => res.json()).then(data => {
|
||||
var openState = data.state.open;
|
||||
var lastchange = new Date((data.state.lastchange * 1000));
|
||||
document.querySelector('#spaceapi').innerHTML = "<img src='/spaceapi/" + ((openState)?"open":"closed") + ".png'><span><b>Der Space ist derzeit " + ((openState)?"geöffnet.</b>":("geschlossen</b><br/>" + ((data.state.message)?data.state.message:"Nächstes Treffen: siehe <a href='#termine'>Termine</a>"))) + "<br/>" + "<small>Letzte Statusänderung: " + lastchange.toLocaleString("de-DE") + "</small></span>";
|
||||
});
|
||||
|
||||
return refresh_time;
|
||||
}(), refresh_time);
|
||||
|
||||
});
|
Reference in a new issue