]> code.citadel.org Git - citadel.git/blob - webcit-ng/static/js/views.js
to, cc, subject in mail_compose()
[citadel.git] / webcit-ng / static / js / views.js
1 // Copyright (c) 2016-2022 by the citadel.org team
2 //
3 // This program is open source software.  Use, duplication, or
4 // disclosure are subject to the GNU General Public License v3.
5
6
7
8 // Clear the sidebar buttons of any style indicating that one is selected
9 function clear_sidebar_selection() {
10         var items = document.getElementById("ctdl-sidebar").getElementsByTagName("*");
11         for (var i = items.length; i--;) {
12                 if (items[i].id.includes("ctdl-sidebar-button-")) {
13                         items[i].classList.remove("ctdl-sidebar-button-selected");
14                 }
15         }
16         document.getElementById("ctdl_mail_folder_list").style.display = "none";
17 }
18
19
20 // This function is the dispatcher that determines the correct view for a room,
21 // and calls the correct renderer.  Greater/Less than bounds are accepted.
22 function render_room_view(gt_msg, lt_msg) {
23
24         document.getElementById("ctdl-newmsg-button").style.display = "none";           // the view renderer will set this
25         clear_sidebar_selection();
26
27         switch(current_view) {
28
29                 // The "forum" module displays rooms with the "VIEW_BBS" view as classic style web forums.
30                 case views.VIEW_BBS:
31                         document.getElementById("ctdl-sidebar-button-forums").classList.add("ctdl-sidebar-button-selected");
32                         document.getElementById("ctdl-main").innerHTML = "<div id=\"ctdl-mrp\" class=\"ctdl-forum-reading-pane\"></div>";
33                         forum_readmessages("ctdl-mrp", gt_msg, lt_msg);
34                         break;
35
36                 // The "mail" module displays rooms with the VIEW_MAILBOX view as a webmail program.
37                 case views.VIEW_MAILBOX:
38                         document.getElementById("ctdl-sidebar-button-mail").classList.add("ctdl-sidebar-button-selected");
39                         document.getElementById("ctdl-main").innerHTML = "";
40                         mail_display();
41                         break;
42
43                 default:
44                         document.getElementById("ctdl-main").innerHTML =
45                                 "<center>The view for " + current_room + " is " + current_view + " but there is no renderer.</center>";
46                         break;
47         }
48
49         // Show the mail folder list only when the Mail view is active.
50         if (current_view == views.VIEW_MAILBOX) {
51                 document.getElementById("ctdl_mail_folder_list").style.display = "block";
52         }
53
54 }
55
56
57 // This gets called when the user clicks the "enter message" or "post message" or "add item" button etc.
58 function entmsg_dispatcher() {
59         switch(current_view) {
60                 case views.VIEW_BBS:
61                         forum_entmsg();
62                         break;
63                 case views.VIEW_MAILBOX:
64                         mail_compose(false, "", 0, "", "", "");
65                         break;
66                 default:
67                         break;
68         }
69 }
70