2 // Copyright (c) 2016-2017 by the citadel.org team
4 // This program is open source software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License version 3.
7 // This program is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 // GNU General Public License for more details.
13 // List of defined views shamelessly swiped from libcitadel headers
16 VIEW_BBS : 0, /* Bulletin board view */
17 VIEW_MAILBOX : 1, /* Mailbox summary */
18 VIEW_ADDRESSBOOK : 2, /* Address book view */
19 VIEW_CALENDAR : 3, /* Calendar view */
20 VIEW_TASKS : 4, /* Tasks view */
21 VIEW_NOTES : 5, /* Notes view */
22 VIEW_WIKI : 6, /* Wiki view */
23 VIEW_CALBRIEF : 7, /* Brief Calendar view */
24 VIEW_JOURNAL : 8, /* Journal view */
25 VIEW_DRAFTS : 9, /* Drafts view */
26 VIEW_BLOG : 10, /* Blog view */
27 VIEW_QUEUE : 11, /* SMTP QUEUE rooms */
28 VIEW_WIKIMD : 12, /* Markdown Wiki view */
32 // This function is the dispatcher that determines the correct view for a room,
33 // and calls the correct renderer.
35 function render_room_view() {
37 switch(current_view) {
38 case views.VIEW_MAILBOX: // FIXME view mail rooms as forums for now
40 threads_readmessages();
43 document.getElementById("main").innerHTML = "The view for " + current_room + " is " + current_view + " but there is no renderer." ;
51 // The inner div exists so that if the user clicks away early, the main div doesn't get clobbered when the load completes.
53 function threads_readmessages() {
54 var innerdivname = randomString(5);
55 document.getElementById("main").innerHTML = "<div id=\"" + innerdivname + "\"><img src=\"/ctdl/s/throbber.gif\" />" + _("Loading messages from server, please wait") + "</div>" ;
57 var request = new XMLHttpRequest();
58 request.open("GET", "/ctdl/r/" + escapeHTMLURI(current_room) + "/" + "threads", true);
59 request.onreadystatechange = function() {
60 if (this.readyState === 4) {
61 if ((this.status / 100) == 2) {
62 document.getElementById(innerdivname).outerHTML = this.responseText;
65 document.getElementById(innerdivname).outerHTML = "ERROR " + this.status ;