]> code.citadel.org Git - citadel.git/blobdiff - webcit-ng/static/js/view_calendar.js
Calendar view: initial call of REPORT method.
[citadel.git] / webcit-ng / static / js / view_calendar.js
index 1ac05266a0a5aa1d3dcdac9829f42e5840d4b57e..f5c53fc19b4142b2341712b4e60a1b1c75beb027 100644 (file)
@@ -3,25 +3,40 @@
 // 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() {
-       fetch(
-               "/ctdl/r/" + escapeHTMLURI(current_room) + "/calendar::"
-       )
+
+       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 => {
-               document.getElementById("ctdl-main").innerHTML = JSON.stringify(j);
-       })
+       //.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>`;