// Copyright (c) 2016-2023 by the citadel.org team
//
// This program is open source software. Use, duplication, or
-// disclosure are subject to the GNU General Public License v3.
+// disclosure is subject to the GNU General Public License v3.
// RENDERER FOR THIS VIEW
function view_render_calendar() {
- document.getElementById("ctdl-main").innerHTML = `STUB RENDERER FOR CALENDAR ROOM`;
- fetch(
- "/ctdl/r/" + escapeHTMLURI(current_room) + "/calendar::"
- )
- .then((response) => {
+ let options = {
+ method: "REPORT",
+ headers: {
+ "Content-Type" : "application/xml; charset=utf-8"
+ },
+ body: `
+ <CAL:calendar-query xmlns="DAV:" xmlns:CAL="urn:ietf:params:xml:ns:caldav">
+ <allprop />
+ <CAL:filter>
+ <CAL:comp-filter name="VCALENDAR">
+ <CAL:comp-filter name="VEVENT" />
+ </CAL:comp-filter>
+ </CAL:filter>
+ </CAL:calendar-query>
+ `
+ };
+
+ fetch("/ctdl/r/" + escapeHTMLURI(current_room), options)
+ .then(response => {
if (response.ok) {
- return(response.json());
+ return(response.text());
+ }
+ else {
+ throw new Error(`${response.status} ${response.statusText}`);
}
})
- .then((j) => {
- console.log("Something");
- })
- .catch((error) => {
- console.log("Error: " + error);
+ //.then(str => new window.DOMParser().parseFromString(str, "text/xml"))
+ .then(str => document.getElementById("ctdl-main").innerHTML = escapeHTML(str))
+ .catch(error => {
+ console.log(error);
+ document.getElementById("ctdl-main").innerHTML = `<div class="ctdl-fatal-error">${error}</div>`;
});
}