-// Copyright (c) 2016-2022 by the citadel.org team
+// Copyright (c) 2016-2023 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() => {
-
floor_response = await fetch("/ctdl/f/");
floor_list = await(floor_response.json());
room_response = await fetch("/ctdl/r/");
// Renderer for display_room_list()
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);
});
+ // 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] += "<div class=\"w3-button ctdl-roomlist-room\" onClick=\"javascript:gotoroom('" + escapeJS(escapeHTML(room_list[i].name)) + "');\">";
- output[room_list[i].floor] += "<i class=\"ctdl-roomlist-roomicon fas fa-comments";
- output[room_list[i].floor] += (room_list[i].hasnewmsgs ? " ctdl-roomlist-roomicon-hasnewmsgs" : "");
- output[room_list[i].floor] += " fa-fw\"></i><span class=\"ctdl-roomlist-roomname\"";
- output[room_list[i].floor] += (room_list[i].hasnewmsgs ? " ctdl-roomlist-roomname-hasnewmsgs" : "");
- output[room_list[i].floor] += "\">";
- output[room_list[i].floor] += escapeHTML(room_list[i].name);
- output[room_list[i].floor] += "</span></div>";
+ output[room_list[i].floor] +=
+
+ "<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
}
}
final_output = "<div class=\"ctdl-roomlist-top\">";
for (var f in floor_list) {
- final_output += "<div class=\"ctdl-roomlist-floor\">";
- final_output += "<div class=\"ctdl-roomlist-floor-label\">" + floor_list[f].name + "</div>";
- final_output += "<div class=\"ctdl-roomlist-floor-rooms\">";
- final_output += output[floor_list[f].num];
- final_output += "</div></div>";
+ 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 ;
+ document.getElementById("ctdl-main").innerHTML = final_output;
}