X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit-ng%2Fstatic%2Fjs%2Fview_calendar.js;h=28fcbd68cbb028ffc8344db3a321d9bbfd5fb4b9;hb=HEAD;hp=b6d135d368be13e6ba0fcea1ad816f08dd563eab;hpb=eae58320fe6fabe7ae035c18561c90bb5138fb82;p=citadel.git diff --git a/webcit-ng/static/js/view_calendar.js b/webcit-ng/static/js/view_calendar.js index b6d135d36..76de28902 100644 --- a/webcit-ng/static/js/view_calendar.js +++ b/webcit-ng/static/js/view_calendar.js @@ -1,12 +1,227 @@ // This module handles the view for "calendar" rooms. // -// Copyright (c) 2016-2023 by the citadel.org team +// Copyright (c) 2016-2024 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. + + +function XXXXXview_render_calendar() { + + let options = { + method: "REPORT", + headers: { + "Content-Type" : "application/xml; charset=utf-8" + }, + body: ` + + + + + + + + + ` + }; + + fetch("/ctdl/r/" + escapeHTMLURI(current_room), options) + .then(response => { + if (response.ok) { + return(response.text()); + } + else { + throw new Error(`${response.status} ${response.statusText}`); + } + }) + //.then(str => document.getElementById("ctdl-main").innerHTML = escapeHTML(str)) + .then(str => new window.DOMParser().parseFromString(str, "text/xml")) + .then(xmlcal => { + document.getElementById("ctdl-main").innerHTML = "calendar items:
"; + let root = xmlcal.documentElement; + let children = root.childNodes; + for (let i=0; i"; + } + } + + }) + .catch(error => { + console.log(error); + document.getElementById("ctdl-main").innerHTML = `
${error}
`; + }); +} + +var date_being_displayed = new Date(); +var days_being_displayed = 7; /* 1 = day view; 5 = work week view; 7 = week view */ +var start_of_week = 1; /* 0 = Sunday; 1 = Monday */ + +// Update the calendar display (we might have changed dates, or added/removed data) +function update_calendar_display() { + + // Clone the "date_being_displayed" and scope it locally for this function. + let this_column_date = new Date(date_being_displayed); + + // If displaying a whole week, start the week on the correct day of the week (usually Sunday or Monday) + if (days_being_displayed == 7) { + while (this_column_date.getDay() != start_of_week) { + this_column_date.setDate(this_column_date.getDate() - 1); + } + } + + // If displaying a work week, start the week on Monday + if (days_being_displayed == 5) { + while (this_column_date.getDay() != 1) { + this_column_date.setDate(this_column_date.getDate() - 1); + } + } + + // Go through every day on the screen (up to a week I guess) + for (let i=0; iDay |  + 3-Day |  + WorkWeek |  + Week |  + ←Y |  + ←M |  + ←W |  + ←D |  + today |  + D→ |  + W→ |  + M→ |  + Y→  + `; + document.getElementById("ctdl-calendar-nav").style.display = "block"; + + let caldisplay = ""; + caldisplay += `
`; // top level container + caldisplay += `
`; // the row of labels above the calendar content + + // This section renders the day labels at the top of the screen + caldisplay += `
`; // container for ruler+days + caldisplay += `
`; // the hours ruler on the left side of the screen + caldisplay += "
"; // closes ctdl-calendar-ruler + for (let i=0; iHi!
`; + } + caldisplay += "
"; // closes ctdl-calendar-week + + caldisplay += `
`; // closes ctdl-calendar-toplabels + caldisplay += `
`; // the actual boxes of content below the labels + caldisplay += `
`; // container for ruler+days + caldisplay += `
`; // the hours ruler on the left side of the screen + for (let i=0; i<24; ++i) { + caldisplay += i + "
"; + }; + caldisplay += `
`; // closes ctdl-calendar-ruler + + // This section renders the day boxes. + for (let i=0; iHi!
`; + } + caldisplay += "
"; // closes ctdl-calendar-week + caldisplay += ""; // closes ctdl-calendar-content + caldisplay += ""; // closes ctdl-calendar-container + document.getElementById("ctdl-main").innerHTML = caldisplay; + + // Start on today. + go_to_today(); }