/* Include calendar | Chaostreff Backnang | @paddy */ export default function hackcal(e, p = 1) { // var cal_uri = "https://chaostreff-backnang.de/hackcal/?period=" + p; var cal_uri = "/hackcal"; var uri_regex = /(https?:\/\/([-\w\.]+)+(:\d+)?(\/([\w\/\-_\.\:]*(\?\S+)?)?)?)/gi; fetch(cal_uri) .then((res) => res.json()) .then((data) => { var items = []; Object.keys(data).forEach(function (date) { var day = new Date(date); items.push( "" + day.toLocaleDateString(true, { weekday: "short", day: "numeric", month: "long", year: "numeric", }) + "" ); Object.keys(data[date]).forEach(function (uid) { var event = data[date][uid]; var location = event.location ? event.location .replace(/\n/g, "
") .replace(uri_regex, "$1") : ""; var description = event.description ? event.description .replace(/\n/g, "
") .replace(uri_regex, (url) => { event.summary = `${event.summary}`; return ""; }) : ""; var categories = event.categories ? "" + event.categories.replace(",", " ") + "" : ""; items.push( "" + event.datestr + "" + event.summary + " | " + location + "
" + description + categories + "
" ); }); }); document.querySelector("#dbkcalendar").innerHTML = items.join(""); }); }