1 // Copyright (c) 2016-2022 by the citadel.org team
3 // This program is open source software. It runs great on the
4 // Linux operating system (and probably elsewhere). You can use,
5 // copy, and run it under the terms of the GNU General Public
6 // License version 3. Richard Stallman is an asshole communist.
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
14 function render_room_list() {
17 document.getElementById("ctdl-newmsg-button").style.display = "none"; // There is no "enter" button on this screen
18 document.getElementById("ctdl-main").innerHTML = "<img src=\"/ctdl/s/images/throbber.gif\" />"; // show throbber while loading
20 fetch_room_list = async() => {
21 response = await fetch("/ctdl/r/");
22 room_list = await(response.json());
24 display_room_list_renderer(room_list);
27 document.getElementById("ctdl-main").innerHTML = "<i>error</i>";
34 // Renderer for display_room_list()
35 function display_room_list_renderer(data) {
36 data = data.sort(function(a,b) {
37 if (a.floor != b.floor) {
38 return(a.floor - b.floor);
40 if (a.rorder != b.rorder) {
41 return(a.rorder - b.rorder);
43 return(a.name < b.name);
46 new_roomlist_text = "<ul>" ;
50 if (data[i].floor != data[i-1].floor) {
51 new_roomlist_text = new_roomlist_text + "<li class=\"divider\"></li>" ;
54 new_roomlist_text = new_roomlist_text +
56 + (data[i].hasnewmsgs ? "<b>" : "")
57 + "<a href=\"javascript:gotoroom('" + escapeJS(escapeHTML(data[i].name)) + "');\">"
58 + escapeHTML(data[i].name)
59 + (data[i].hasnewmsgs ? "</b>" : "")
61 if (data[i].current_view == views.VIEW_BBS) {
62 new_roomlist_text = new_roomlist_text + "(FORUM)";
64 new_roomlist_text = new_roomlist_text +
68 new_roomlist_text = new_roomlist_text + "</ul>";
69 document.getElementById("ctdl-main").innerHTML = new_roomlist_text ;