+// Copyright (c) 2016-2023 by the citadel.org team
//
-// Copyright (c) 2016-2022 by the citadel.org team
-//
-// This program is open source software. It runs great on the
-// Linux operating system (and probably elsewhere). You can use,
-// copy, and run it under the terms of the GNU General Public
-// License version 3. Richard Stallman is an asshole communist.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
+// This program is open source software. Use, duplication, or
+// disclosure are subject to the GNU General Public License v3.
-// List of defined views shamelessly swiped from libcitadel headers
-//
-var views = {
- VIEW_BBS : 0, // Bulletin board view
- VIEW_MAILBOX : 1, // Mailbox summary
- VIEW_ADDRESSBOOK : 2, // Address book view
- VIEW_CALENDAR : 3, // Calendar view
- VIEW_TASKS : 4, // Tasks view
- VIEW_NOTES : 5, // Notes view
- VIEW_WIKI : 6, // Wiki view
- VIEW_CALBRIEF : 7, // Brief Calendar view
- VIEW_JOURNAL : 8, // Journal view
- VIEW_DRAFTS : 9, // Drafts view
- VIEW_BLOG : 10, // Blog view
- VIEW_QUEUE : 11, // SMTP queue rooms
- VIEW_WIKIMD : 12, // markdown wiki (no longer implemented)
-};
-
-
-// This function is the dispatcher that determines the correct view for a room,
-// and calls the correct renderer. Greater/Less than bounds are accepted.
-//
-function render_room_view(gt_msg, lt_msg) {
+// Clear the sidebar buttons of any style indicating that one is selected
+function clear_sidebar_selection() {
+ var items = document.getElementById("ctdl-sidebar").getElementsByTagName("*");
+ for (var i = items.length; i--;) {
+ if (items[i].id.includes("ctdl-sidebar-button-")) {
+ items[i].classList.remove("ctdl-sidebar-button-selected");
+ }
+ }
+ document.getElementById("ctdl_mail_folder_list").style.display = "none";
+}
+
+
+// Clear any drop handlers that might have been set by the previous view
+function clear_drop_handlers() {
+}
+
+
+// Clear the top bar navigation buttons. The view renderer will set its own buttons.
+function clear_navigation_buttons() {
+ for (const d of ["ctdl-newmsg-button", "ctdl-ungoto-button", "ctdl-skip-button", "ctdl-goto-button", "ctdl-delete-button"]) {
+ document.getElementById(d).style.display = "none";
+ }
+}
+
+
+// This function is the dispatcher that determines the correct view for a room, and calls the correct renderer.
+function render_room_view() {
+
+ clear_navigation_buttons();
+ clear_sidebar_selection();
+ clear_drop_handlers();
+
+ document.getElementById("ctdl-main").innerHTML =
+ "<div class=\"ctdl-middle\">"
+ + _("Loading messages from server, please wait")
+ + "</div>";
+
switch(current_view) {
- case views.VIEW_MAILBOX: // FIXME view mail rooms as forums for now
+
+ // The "forum" module displays rooms with the "VIEW_BBS" view as classic style web forums.
case views.VIEW_BBS:
- document.getElementById("ctdl-main").innerHTML = "<div id=\"ctdl-mrp\" class=\"ctdl-msg-reading-pane\"></div>";
- forum_readmessages("ctdl-mrp", gt_msg, lt_msg);
+ document.getElementById("ctdl-sidebar-button-forums").classList.add("ctdl-sidebar-button-selected");
+ view_render_forums();
+ break;
+
+ // The "mail" module displays rooms with the VIEW_MAILBOX view as a webmail program.
+ case views.VIEW_MAILBOX:
+ case views.VIEW_DRAFTS:
+ document.getElementById("ctdl-sidebar-button-mail").classList.add("ctdl-sidebar-button-selected");
+ display_mail_folder_list("ctdl_mail_folder_list");
+ view_render_mail();
+ break;
+
+ // The "contacts" module displays rooms with the VIEW_ADDRESSBOOK view as a contacts manager.
+ case views.VIEW_ADDRESSBOOK:
+ view_render_contacts();
+ break;
+
+ case views.VIEW_CALENDAR:
+ case views.VIEW_CALBRIEF:
+ view_render_calendar();
+ break;
+
+ case views.VIEW_TASKS:
+ document.getElementById("ctdl-main").innerHTML =
+ `<div class="ctdl-middle">'${current_room}' is a task list but there is no renderer.</div>`;
+ break;
+
+ case views.VIEW_NOTES:
+ document.getElementById("ctdl-main").innerHTML =
+ `<div class="ctdl-middle">'${current_room}' is a notes list but there is no renderer.</div>`;
+ break;
+
+ case views.VIEW_WIKI:
+ document.getElementById("ctdl-main").innerHTML =
+ `<div class="ctdl-middle">'${current_room}' is a wiki but there is no renderer.</div>`;
+ break;
+
+ case views.VIEW_JOURNAL:
+ document.getElementById("ctdl-main").innerHTML =
+ `<div class="ctdl-middle">'${current_room}' is a journal but there is no renderer.</div>`;
+ break;
+
+ case views.VIEW_BLOG:
+ document.getElementById("ctdl-main").innerHTML =
+ `<div class="ctdl-middle">'${current_room}' is a blog but there is no renderer.</div>`;
break;
+
+ case views.VIEW_QUEUE:
+ document.getElementById("ctdl-main").innerHTML =
+ `<div class="ctdl-middle">'${current_room}' is the mail queue but there is no renderer.</div>`;
+ break;
+
default:
document.getElementById("ctdl-main").innerHTML =
- "The view for " + current_room + " is " + current_view + " but there is no renderer." ;
+ `<div class="ctdl-middle">The view for '${current_room}' is ${current_view} but there is no renderer.</div>`;
+ break;
+ }
+
+}
+
+
+// This gets called when the user clicks the "enter message" or "post message" or "add item" button etc.
+function entmsg_dispatcher() {
+ switch(current_view) {
+ case views.VIEW_BBS:
+ forum_entmsg();
+ break;
+ case views.VIEW_MAILBOX:
+ mail_compose("", 0, [], [], "");
+ break;
+ default:
break;
}
+}
+
+// This gets called when the user clicks the "delete" button etc.
+function delete_dispatcher() {
+ switch(current_view) {
+ case views.VIEW_MAILBOX:
+ mail_delete_selected();
+ break;
+ default:
+ break;
+ }
}
+
+