Initial commit
This commit is contained in:
commit
29f9d7c880
25 changed files with 985 additions and 0 deletions
26
js/vanilla.dbkcalendar.js
Normal file
26
js/vanilla.dbkcalendar.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
Include calendar | Chaostreff Backnang | @paddy
|
||||
*/
|
||||
document.addEventListener("DOMContentLoaded", hackcal);
|
||||
|
||||
function hackcal(p=1) {
|
||||
var cal_uri = "/hackcal/?period="+p;
|
||||
var uri_regex = /(https?:\/\/([-\w\.]+)+(:\d+)?(\/([\w\/\-_\.\:]*(\?\S+)?)?)?)/ig
|
||||
|
||||
fetch(cal_uri).then(res => res.json()).then(data => {
|
||||
var items = [];
|
||||
Object.keys(data).forEach(function (date) {
|
||||
var day = new Date(date);
|
||||
items.push("<div data-date='" + date + "'><span>" + day.toLocaleDateString(true, {weekday:'short', day:'numeric', month:'long', year: 'numeric'}) + "</span></div>");
|
||||
Object.keys(data[date]).forEach(function (uid) {
|
||||
var event = data[date][uid];
|
||||
if(event.location) event.location = event.location.replace(/\n/g,"<br>").replace(uri_regex, "<a href='$1' target='_blank'>$1</a>");
|
||||
if(event.description) event.description = event.description.replace(/\n/g,"<br>").replace(uri_regex, (url) => {event.summary = `<a href='${url}' target='_blank'>${event.summary}</a>`; return "";});
|
||||
if(event.categories) event.categories = "<i>" + event.categories.replace(",", "</i> <i>") + "</i>";
|
||||
items.push("<div data-uid='" + uid + "'><span>" + event.datestr + "</span><span><b>" + event.summary + "</b> | " + ((event.location)?event.location:'') + "<br/>" + ((event.description)?event.description:'') + ((event.categories)?event.categories:'') + "</span></div>");
|
||||
});
|
||||
});
|
||||
document.querySelector('#dbkcalendar').innerHTML = items.join( "" );
|
||||
});
|
||||
}
|
||||
|
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