Moved the room list from the sidebar to the main viewing pane.
authorArt Cancro <ajc@citadel.org>
Sun, 23 Jan 2022 21:01:16 +0000 (16:01 -0500)
committerArt Cancro <ajc@citadel.org>
Sun, 23 Jan 2022 21:01:16 +0000 (16:01 -0500)
This is going to turn into a "forum list" and we'll do something
else for mailboxes.

webcit-ng/static/index.html
webcit-ng/static/js/main.js
webcit-ng/static/js/roomlist.js [new file with mode: 0644]

index ebf7653e14eb5d82ed92c61638339103791799d1..42ca0d4e059e0b70a1f61e81a49b8ac449fc1671 100644 (file)
@@ -56,8 +56,8 @@ LOADING
        <div class="w3-bar-block">
                <a href="#" class="w3-bar-item w3-button w3-padding-16 w3-hide-large w3-dark-grey w3-hover-black" onclick="w3_close()" title="close menu"><i class="fa fa-remove fa-fw"></i>  Close Menu</a>
                <a href="#" class="w3-bar-item w3-button w3-padding w3-blue"><i class="fas fa-inbox fa-fw"></i>  Mail</a>
-               <div id="roomlist">rooms go here</div>
-               <a href="#" class="w3-bar-item w3-button w3-padding"><i class="fas fa-comments fa-fw"></i>  Forums</a>
+               <div id="ctdl_mail_folder_list" style="display:none"></div>
+               <a href="#" class="w3-bar-item w3-button w3-padding" onClick="render_room_list();"><i class="fas fa-comments fa-fw"></i>  Forums</a>
                <a href="#" class="w3-bar-item w3-button w3-padding"><i class="far fa-calendar-alt fa-fw"></i>  Calendar</a>
                <a href="#" class="w3-bar-item w3-button w3-padding"><i class="fa fa-bullseye fa-fw"></i>  Contacts</a>
                <a href="#" class="w3-bar-item w3-button w3-padding"><i class="fa fa-blog fa-fw"></i>  Blogs</a>
@@ -80,6 +80,7 @@ Loading...
 <script type="text/javascript" src="js/main.js"></script>
 <script type="text/javascript" src="js/views.js"></script>
 <script type="text/javascript" src="js/view_forum.js"></script>
+<script type="text/javascript" src="js/roomlist.js"></script>
 <script>
 
 // Get the Sidebar
index d8e01401c465ede9e7c0992514944e94cb165343..04e38243867631414f4997197bdb725ef9de3b2d 100644 (file)
@@ -47,7 +47,6 @@ ctdl_startup = async() => {
 
                if ( (serv_info.serv_supports_guest) || (logged_in) ) {                 // If the Lobby is visible,
                        gotoroom("_BASEROOM_");                                         // go there.
-                       display_room_list();
                }
                else {                                                                  // Otherwise,
                        display_login_screen("");                                       // display the login modal.
@@ -63,59 +62,8 @@ ctdl_startup = async() => {
 
 
 // Display a room list in the main div.
-function display_room_list() {
-       document.getElementById("roomlist").innerHTML = "<img src=\"/ctdl/s/images/throbber.gif\" />";  // show throbber while loading
-
-       fetch_room_list = async() => {
-               response = await fetch("/ctdl/r/");
-               room_list = await(response.json());
-               if (response.ok) {
-                       display_room_list_renderer(room_list);
-               }
-               else {
-                       document.getElementById("roomlist").innerHTML = "<i>error</i>";
-               }
-       }
-       fetch_room_list();
-}
-
-
-// Renderer for display_room_list()
-function display_room_list_renderer(data) {
-       data = data.sort(function(a,b) {
-               if (a.floor != b.floor) {
-                       return(a.floor - b.floor);
-               }
-               if (a.rorder != b.rorder) {
-                       return(a.rorder - b.rorder);
-               }
-               return(a.name < b.name);
-       });
-
-       new_roomlist_text = "<ul>" ;
-
-       for (var i in data) {
-               if (i > 0) {
-                       if (data[i].floor != data[i-1].floor) {
-                               new_roomlist_text = new_roomlist_text + "<li class=\"divider\"></li>" ;
-                       }
-               }
-               new_roomlist_text = new_roomlist_text +
-                       "<li>"
-                       + (data[i].hasnewmsgs ? "<b>" : "")
-                       + "<a href=\"javascript:gotoroom('" + escapeJS(escapeHTML(data[i].name)) + "');\">"
-                       + escapeHTML(data[i].name)
-                       + (data[i].hasnewmsgs ? "</b>" : "")
-                       + "</a></li>"
-               ;
-       }
-       new_roomlist_text = new_roomlist_text + "</ul>";
-       document.getElementById("roomlist").innerHTML = new_roomlist_text ;
-}
-
 
 // Update the "banner" div with all relevant info.
-//
 function update_banner() {
        detect_logged_in();
        if (current_room) {
diff --git a/webcit-ng/static/js/roomlist.js b/webcit-ng/static/js/roomlist.js
new file mode 100644 (file)
index 0000000..e2f44ec
--- /dev/null
@@ -0,0 +1,67 @@
+//
+// 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.
+
+
+function render_room_list() {
+
+
+       document.getElementById("ctdl-newmsg-button").style.display = "none";           // There is no "enter" button on this screen
+       document.getElementById("ctdl-main").innerHTML = "<img src=\"/ctdl/s/images/throbber.gif\" />"; // show throbber while loading
+
+       fetch_room_list = async() => {
+               response = await fetch("/ctdl/r/");
+               room_list = await(response.json());
+               if (response.ok) {
+                       display_room_list_renderer(room_list);
+               }
+               else {
+                       document.getElementById("ctdl-main").innerHTML = "<i>error</i>";
+               }
+       }
+       fetch_room_list();
+}
+
+
+// Renderer for display_room_list()
+function display_room_list_renderer(data) {
+       data = data.sort(function(a,b) {
+               if (a.floor != b.floor) {
+                       return(a.floor - b.floor);
+               }
+               if (a.rorder != b.rorder) {
+                       return(a.rorder - b.rorder);
+               }
+               return(a.name < b.name);
+       });
+
+       new_roomlist_text = "<ul>" ;
+
+       for (var i in data) {
+               if (i > 0) {
+                       if (data[i].floor != data[i-1].floor) {
+                               new_roomlist_text = new_roomlist_text + "<li class=\"divider\"></li>" ;
+                       }
+               }
+               new_roomlist_text = new_roomlist_text +
+                       "<li>"
+                       + (data[i].hasnewmsgs ? "<b>" : "")
+                       + "<a href=\"javascript:gotoroom('" + escapeJS(escapeHTML(data[i].name)) + "');\">"
+                       + escapeHTML(data[i].name)
+                       + (data[i].hasnewmsgs ? "</b>" : "")
+                       + "</a></li>"
+               ;
+       }
+       new_roomlist_text = new_roomlist_text + "</ul>";
+       document.getElementById("ctdl-main").innerHTML = new_roomlist_text ;
+}
+