room list renderer is now aware of which rooms are forum view:
authorArt Cancro <ajc@citadel.org>
Sun, 23 Jan 2022 21:14:05 +0000 (16:14 -0500)
committerArt Cancro <ajc@citadel.org>
Sun, 23 Jan 2022 21:14:05 +0000 (16:14 -0500)
webcit-ng/room_functions.c
webcit-ng/static/index.html
webcit-ng/static/js/defs.js [new file with mode: 0644]
webcit-ng/static/js/roomlist.js
webcit-ng/static/js/views.js

index 006bd287bec95a491ddf87a1da62a4ad02e67e1f..26f35ef5eafabe56c33d973a597f3dcec1aeae53 100644 (file)
@@ -458,21 +458,22 @@ void room_list(struct http_transaction *h, struct ctdlsession *c) {
        JsonValue *j = NewJsonArray(HKEY("lkra"));
        while (ctdl_readline(c, buf, sizeof(buf)), strcmp(buf, "000")) {
 
+               // 0   |1      |2      |3      |4       |5 |6           |7           |8
                // name|QRflags|QRfloor|QRorder|QRflags2|ra|current_view|default_view|mtime
                JsonValue *jr = NewJsonObject(HKEY("room"));
 
                extract_token(roomname, buf, 0, '|', sizeof roomname);
                JsonObjectAppend(jr, NewJsonPlainString(HKEY("name"), roomname, -1));
 
+               JsonObjectAppend(jr, NewJsonNumber(HKEY("floor"), extract_int(buf, 2)));
+               JsonObjectAppend(jr, NewJsonNumber(HKEY("rorder"), extract_int(buf, 3)));
+
                int ra = extract_int(buf, 5);
                JsonObjectAppend(jr, NewJsonBool(HKEY("known"), (ra & UA_KNOWN)));
                JsonObjectAppend(jr, NewJsonBool(HKEY("hasnewmsgs"), (ra & UA_HASNEWMSGS)));
 
-               int floor = extract_int(buf, 2);
-               JsonObjectAppend(jr, NewJsonNumber(HKEY("floor"), floor));
-
-               int rorder = extract_int(buf, 3);
-               JsonObjectAppend(jr, NewJsonNumber(HKEY("rorder"), rorder));
+               JsonObjectAppend(jr, NewJsonNumber(HKEY("current_view"), extract_int(buf, 6)));
+               JsonObjectAppend(jr, NewJsonNumber(HKEY("default_view"), extract_int(buf, 7)));
 
                JsonArrayAppend(j, jr); // add the room to the array
        }
index 42ca0d4e059e0b70a1f61e81a49b8ac449fc1671..4ad83b00831dfd38ee235602559f995172e34cde 100644 (file)
@@ -75,6 +75,7 @@ Loading...
 <!-- End page content -->
 </div>
 
+<script type="text/javascript" src="js/defs.js"></script>
 <script type="text/javascript" src="js/util.js"></script>
 <script type="text/javascript" src="js/login.js"></script>
 <script type="text/javascript" src="js/main.js"></script>
diff --git a/webcit-ng/static/js/defs.js b/webcit-ng/static/js/defs.js
new file mode 100644 (file)
index 0000000..8eaa7b6
--- /dev/null
@@ -0,0 +1,31 @@
+//
+// Copyright (c) 2016-2022 by the citadel.org team
+//
+// This program is open source software.  It runs great on the
+// Linux operating system (and probably elsewhere).  You can use,
+// copy, and run it under the terms of the GNU General Public
+// License version 3.  Richard Stallman is an asshole communist.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+
+// List of defined views shamelessly swiped from libcitadel headers
+//
+var views = {
+       VIEW_BBS                : 0,    // Bulletin board view
+       VIEW_MAILBOX            : 1,    // Mailbox summary
+       VIEW_ADDRESSBOOK        : 2,    // Address book view
+       VIEW_CALENDAR           : 3,    // Calendar view
+       VIEW_TASKS              : 4,    // Tasks view
+       VIEW_NOTES              : 5,    // Notes view
+       VIEW_WIKI               : 6,    // Wiki view
+       VIEW_CALBRIEF           : 7,    // Brief Calendar view
+       VIEW_JOURNAL            : 8,    // Journal view
+       VIEW_DRAFTS             : 9,    // Drafts view
+       VIEW_BLOG               : 10,   // Blog view
+       VIEW_QUEUE              : 11,   // SMTP queue rooms
+       VIEW_WIKIMD             : 12,   // markdown wiki (no longer implemented)
+};
index e2f44ec136b847dba8e37d801bfa0438d2f417b8..7c611f97a7f489d87c65488a4e2178f95fbccb30 100644 (file)
@@ -1,4 +1,3 @@
-//
 // Copyright (c) 2016-2022 by the citadel.org team
 //
 // This program is open source software.  It runs great on the
@@ -53,12 +52,17 @@ function display_room_list_renderer(data) {
                        }
                }
                new_roomlist_text = new_roomlist_text +
-                       "<li>"
+                         "<li>"
                        + (data[i].hasnewmsgs ? "<b>" : "")
                        + "<a href=\"javascript:gotoroom('" + escapeJS(escapeHTML(data[i].name)) + "');\">"
                        + escapeHTML(data[i].name)
                        + (data[i].hasnewmsgs ? "</b>" : "")
-                       + "</a></li>"
+                       + "</a>"
+               if (data[i].current_view == views.VIEW_BBS) {
+                       new_roomlist_text = new_roomlist_text + "(FORUM)";
+               }
+               new_roomlist_text = new_roomlist_text +
+                         "</li>"
                ;
        }
        new_roomlist_text = new_roomlist_text + "</ul>";
index 8895433b2b847818b7bfdfa5fc730bdaddd26de3..cfdca07ba3cf3f2563ba18051cfa5aafbb0fee2a 100644 (file)
 // GNU General Public License for more details.
 
 
-// List of defined views shamelessly swiped from libcitadel headers
-//
-var views = {
-       VIEW_BBS                : 0,    // Bulletin board view
-       VIEW_MAILBOX            : 1,    // Mailbox summary
-       VIEW_ADDRESSBOOK        : 2,    // Address book view
-       VIEW_CALENDAR           : 3,    // Calendar view
-       VIEW_TASKS              : 4,    // Tasks view
-       VIEW_NOTES              : 5,    // Notes view
-       VIEW_WIKI               : 6,    // Wiki view
-       VIEW_CALBRIEF           : 7,    // Brief Calendar view
-       VIEW_JOURNAL            : 8,    // Journal view
-       VIEW_DRAFTS             : 9,    // Drafts view
-       VIEW_BLOG               : 10,   // Blog view
-       VIEW_QUEUE              : 11,   // SMTP queue rooms
-       VIEW_WIKIMD             : 12,   // markdown wiki (no longer implemented)
-};
-
-
 // This function is the dispatcher that determines the correct view for a room,
 // and calls the correct renderer.  Greater/Less than bounds are accepted.
 function render_room_view(gt_msg, lt_msg) {