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