1 // Copyright (c) 2016-2022 by the citadel.org team
3 // This program is open source software. Use, duplication, or
4 // disclosure are subject to the GNU General Public License v3.
7 function render_room_list() {
9 stuffbar("none"); // No stuffbar on this screen
10 document.getElementById("ctdl-newmsg-button").style.display = "none"; // There is no "enter" button on this screen
11 document.getElementById("ctdl-main").innerHTML = "<img src=\"/ctdl/s/images/throbber.gif\" />"; // show throbber while loading
13 fetch_room_list = async() => {
14 floor_response = await fetch("/ctdl/f/");
15 floor_list = await(floor_response.json());
16 room_response = await fetch("/ctdl/r/");
17 room_list = await(room_response.json());
19 display_room_list_renderer(floor_list, room_list);
22 document.getElementById("ctdl-main").innerHTML = "<i>error</i>";
29 // Renderer for display_room_list()
30 function display_room_list_renderer(floor_list, room_list) {
32 // First sort by the room order indicated by the server
33 room_list = room_list.sort(function(a,b) {
34 if (a.floor != b.floor) {
35 return(a.floor - b.floor);
37 if (a.rorder != b.rorder) {
38 return(a.rorder - b.rorder);
40 return(a.name < b.name);
43 // Then split the sorted list out into floors
45 for (var f in floor_list) {
46 output[floor_list[f].num] = "";
49 for (var i in room_list) {
50 if (room_list[i].current_view == views.VIEW_BBS) {
51 output[room_list[i].floor] +=
52 "<div class=\"w3-button ctdl-roomlist-room\" onClick=\"javascript:gotoroom('"
53 + escapeJS(escapeHTML(room_list[i].name)) + "');\">"
54 + "<i class=\"w3-badge ctdl-roomlist-roomicon w3-left "
55 + (room_list[i].hasnewmsgs ? "w3-blue" : "w3-gray")
56 + " fas fa-comments fa-fw\"></i><span class=\"ctdl-roomlist-roomname"
57 + (room_list[i].hasnewmsgs ? " ctdl-roomlist-roomname-hasnewmsgs" : "")
59 + escapeHTML(room_list[i].name)
60 + "</span><span class=\"ctdl-roomlist-mtime w3-right\">"
61 + convertTimestamp(room_list[i].mtime)
66 final_output = "<div class=\"ctdl-roomlist-top\">";
67 for (var f in floor_list) {
69 "<div class=\"ctdl-roomlist-floor\">"
70 + "<div class=\"ctdl-roomlist-floor-label\">" + floor_list[f].name + "</div>"
71 + "<div class=\"ctdl-roomlist-floor-rooms\">"
72 + output[floor_list[f].num]
75 final_output += "</div>";
76 document.getElementById("ctdl-main").innerHTML = final_output;