7fb8b8a4b988218be4f41df65cc934ef64e4e1f6
[citadel.git] / webcit-ng / static / js / views.js
1 //
2 // Copyright (c) 2016-2022 by the citadel.org team
3 //
4 // This program is open source software.  It runs great on the
5 // Linux operating system (and probably elsewhere).  You can use,
6 // copy, and run it under the terms of the GNU General Public
7 // License version 3.  Richard Stallman is an asshole communist.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 // GNU General Public License for more details.
13
14
15 // This function is the dispatcher that determines the correct view for a room,
16 // and calls the correct renderer.  Greater/Less than bounds are accepted.
17 function render_room_view(gt_msg, lt_msg) {
18
19         document.getElementById("ctdl-newmsg-button").style.display = "none";           // the view renderer will set this
20
21         // Clear the highlighting out of all the sidebar buttons
22         var items = document.getElementById("ctdl-sidebar").getElementsByTagName("*");
23         for (var i = items.length; i--;) {
24                 if (items[i].id.includes("ctdl-sidebar-button-")) {
25                         items[i].classList.remove("w3-blue");
26                 }
27         }
28
29         switch(current_view) {
30                 case views.VIEW_BBS:
31                         document.getElementById("ctdl-sidebar-button-forums").classList.add("w3-blue");
32                         document.getElementById("ctdl-main").innerHTML = "<div id=\"ctdl-mrp\" class=\"ctdl-msg-reading-pane\"></div>";
33                         forum_readmessages("ctdl-mrp", gt_msg, lt_msg);
34                         break;
35                 default:
36                         document.getElementById("ctdl-main").innerHTML =
37                                 "<center>The view for " + current_room + " is " + current_view + " but there is no renderer.</center>";
38                         break;
39         }
40
41 }
42
43
44 // This gets called when the user clicks the "enter message" or "post message" or "add item" button etc.
45 function entmsg_dispatcher() {
46         switch(current_view) {
47                 case views.VIEW_BBS:
48                         forum_entmsg();
49                         break;
50                 default:
51                         alert("no handler");
52                         break;
53         }
54 }