]> code.citadel.org Git - citadel.git/blob - webcit-ng/static/js/views.js
8895433b2b847818b7bfdfa5fc730bdaddd26de3
[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 // List of defined views shamelessly swiped from libcitadel headers
16 //
17 var views = {
18         VIEW_BBS                : 0,    // Bulletin board view
19         VIEW_MAILBOX            : 1,    // Mailbox summary
20         VIEW_ADDRESSBOOK        : 2,    // Address book view
21         VIEW_CALENDAR           : 3,    // Calendar view
22         VIEW_TASKS              : 4,    // Tasks view
23         VIEW_NOTES              : 5,    // Notes view
24         VIEW_WIKI               : 6,    // Wiki view
25         VIEW_CALBRIEF           : 7,    // Brief Calendar view
26         VIEW_JOURNAL            : 8,    // Journal view
27         VIEW_DRAFTS             : 9,    // Drafts view
28         VIEW_BLOG               : 10,   // Blog view
29         VIEW_QUEUE              : 11,   // SMTP queue rooms
30         VIEW_WIKIMD             : 12,   // markdown wiki (no longer implemented)
31 };
32
33
34 // This function is the dispatcher that determines the correct view for a room,
35 // and calls the correct renderer.  Greater/Less than bounds are accepted.
36 function render_room_view(gt_msg, lt_msg) {
37
38         document.getElementById("ctdl-newmsg-button").style.display = "none";           // the view renderer will set this
39
40         switch(current_view) {
41                 case views.VIEW_BBS:
42                         document.getElementById("ctdl-main").innerHTML = "<div id=\"ctdl-mrp\" class=\"ctdl-msg-reading-pane\"></div>";
43                         forum_readmessages("ctdl-mrp", gt_msg, lt_msg);
44                         break;
45                 default:
46                         document.getElementById("ctdl-main").innerHTML =
47                                 "<center>The view for " + current_room + " is " + current_view + " but there is no renderer.</center>";
48                         break;
49         }
50
51 }
52
53
54 // This gets called when the user clicks the "enter message" or "post message" or "add item" button etc.
55 function entmsg_dispatcher() {
56         switch(current_view) {
57                 case views.VIEW_BBS:
58                         forum_entmsg();
59                         break;
60                 default:
61                         alert("no handler");
62                         break;
63         }
64 }