]> code.citadel.org Git - citadel.git/blob - webcit-ng/static/js/views.js
Display "brief" datestamps in mailbox: date if not today, time if today.
[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                         stuffbar("none");
26                         document.getElementById("ctdl-sidebar-button-forums").classList.add("w3-blue");
27                         document.getElementById("ctdl-main").innerHTML = "<div id=\"ctdl-mrp\" class=\"ctdl-msg-reading-pane\"></div>";
28                         forum_readmessages("ctdl-mrp", gt_msg, lt_msg);
29                         break;
30
31                 // The "mail" module displays rooms with the VIEW_MAILBOX view as a webmail program.
32                 case views.VIEW_MAILBOX:
33                         stuffbar("block");
34                         document.getElementById("ctdl-sidebar-button-mail").classList.add("w3-blue");
35                         document.getElementById("ctdl-main").innerHTML = "";
36                         mail_display();
37                         break;
38
39                 default:
40                         stuffbar("none");
41                         document.getElementById("ctdl-main").innerHTML =
42                                 "<center>The view for " + current_room + " is " + current_view + " but there is no renderer.</center>";
43                         break;
44         }
45
46 }
47
48
49 // This gets called when the user clicks the "enter message" or "post message" or "add item" button etc.
50 function entmsg_dispatcher() {
51         switch(current_view) {
52                 case views.VIEW_BBS:
53                         forum_entmsg();
54                         break;
55                 default:
56                         mail_compose(false, "", "");
57                         break;
58         }
59 }
60
61
62 // The "stuffbar" is an extension of the top navigation bar that can be used for elements such as
63 // a mailbox view, etc.  Many of our operations require activating or deactivating the stuffbar. 
64 // This is a convenience function to make the stuffbar appear or disappear.
65 function stuffbar(state) {
66         document.getElementById("ctdl-stuffbar").style.display = state;
67 }