]> code.citadel.org Git - citadel.git/blob - webcit-ng/static/js/views.js
Set up the view dispatcher for mailbox rooms
[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 // This function is the dispatcher that determines the correct view for a room,
8 // and calls the correct renderer.  Greater/Less than bounds are accepted.
9 function render_room_view(gt_msg, lt_msg) {
10
11         document.getElementById("ctdl-newmsg-button").style.display = "none";           // the view renderer will set this
12
13         // Clear the highlighting out of all the sidebar buttons
14         var items = document.getElementById("ctdl-sidebar").getElementsByTagName("*");
15         for (var i = items.length; i--;) {
16                 if (items[i].id.includes("ctdl-sidebar-button-")) {
17                         items[i].classList.remove("w3-blue");
18                 }
19         }
20
21         switch(current_view) {
22
23                 // The "forum" module displays rooms with the "VIEW_BBS" view as classic style web forums.
24                 case views.VIEW_BBS:
25                         document.getElementById("ctdl-sidebar-button-forums").classList.add("w3-blue");
26                         document.getElementById("ctdl-main").innerHTML = "<div id=\"ctdl-mrp\" class=\"ctdl-msg-reading-pane\"></div>";
27                         forum_readmessages("ctdl-mrp", gt_msg, lt_msg);
28                         break;
29
30                 // The "mail" module displays rooms with the VIEW_MAILBOX view as a webmail program.
31                 case views.VIEW_MAILBOX:
32                         document.getElementById("ctdl-sidebar-button-mail").classList.add("w3-blue");
33                         document.getElementById("ctdl-main").innerHTML = "mailbox view";
34                         break;
35
36                 default:
37                         document.getElementById("ctdl-main").innerHTML =
38                                 "<center>The view for " + current_room + " is " + current_view + " but there is no renderer.</center>";
39                         break;
40         }
41
42 }
43
44
45 // This gets called when the user clicks the "enter message" or "post message" or "add item" button etc.
46 function entmsg_dispatcher() {
47         switch(current_view) {
48                 case views.VIEW_BBS:
49                         forum_entmsg();
50                         break;
51                 default:
52                         alert("no handler");
53                         break;
54         }
55 }