+// Copyright (c) 2016-2023 by the citadel.org team
//
-// 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.
+// This program is open source software. Use, duplication, or
+// disclosure is subject to the GNU General Public License v3.
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
+ document.getElementById("ctdl-main").innerHTML = "<div class=\"ctdl-middle\"><img src=\"/ctdl/s/images/throbber.gif\" /></div>"; // show throbber while loading
+ clear_sidebar_selection();
+ document.getElementById("ctdl-sidebar-button-forums").classList.add("ctdl-sidebar-button-selected");
fetch_room_list = async() => {
- response = await fetch("/ctdl/r/");
- room_list = await(response.json());
+ floor_response = await fetch("/ctdl/f/");
+ floor_list = await(floor_response.json());
+ room_response = await fetch("/ctdl/r/");
+ room_list = await(room_response.json());
if (response.ok) {
- display_room_list_renderer(room_list);
+ display_room_list_renderer(floor_list, room_list);
}
else {
document.getElementById("ctdl-main").innerHTML = "<i>error</i>";
// Renderer for display_room_list()
-function display_room_list_renderer(data) {
- data = data.sort(function(a,b) {
+function display_room_list_renderer(floor_list, room_list) {
+
+ // First sort by the room order indicated by the server
+ room_list = room_list.sort(function(a,b) {
if (a.floor != b.floor) {
return(a.floor - b.floor);
}
return(a.name < b.name);
});
- new_roomlist_text = "<ul>" ;
+ // Then split the sorted list out into floors
+ output = [];
+ for (var f in floor_list) {
+ output[floor_list[f].num] = "";
+ }
+
+ for (var i in room_list) {
+ if (room_list[i].current_view == views.VIEW_BBS) {
+ output[room_list[i].floor] +=
- 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>" ;
- }
+ "<div class=\"ctdl-roomlist-room\" onClick=\"javascript:gotoroom('" // container
+ + escapeJS(escapeHTML(room_list[i].name)) + "');\">"
+
+ + "<div><i class=\"ctdl-roomlist-roomicon " // room icon
+ + (room_list[i].hasnewmsgs ? "w3-blue" : "w3-gray")
+ + " fas fa-comments fa-fw\"></i></div>"
+
+ + "<div class=\"ctdl-roomlist-roomname" // room name
+ + (room_list[i].hasnewmsgs ? " ctdl-roomlist-roomname-hasnewmsgs" : "")
+ + "\">"
+ + escapeHTML(room_list[i].name)
+ + "</div>"
+
+ + "<div class=\"ctdl-roomlist-mtime\">" // date/time of last post
+ + string_timestamp(room_list[i].mtime)
+ + "</div>"
+
+ + "</div>" // end container
}
- 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 ;
+
+ final_output = "<div class=\"ctdl-roomlist-top\">";
+ for (var f in floor_list) {
+ final_output +=
+ "<div class=\"ctdl-roomlist-floor\">"
+ + "<div class=\"ctdl-roomlist-floor-label\">" + floor_list[f].name + "</div>"
+ + "<div class=\"ctdl-roomlist-floor-rooms\">"
+ + output[floor_list[f].num]
+ + "</div></div>";
+ }
+ final_output += "</div>";
+ document.getElementById("ctdl-main").innerHTML = final_output;
}