From: Art Cancro Date: Sat, 14 Jan 2023 22:49:41 +0000 (-0500) Subject: Show mailboxes in a list, ordered by floor+rorder X-Git-Tag: v973~41 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=a3b023d44896710881e7b0ad72bd4f6a2eb643a4;p=citadel.git Show mailboxes in a list, ordered by floor+rorder --- diff --git a/webcit-ng/static/js/mail_folder_list.js b/webcit-ng/static/js/mail_folder_list.js index 9f408f1a7..ce11fbacd 100644 --- a/webcit-ng/static/js/mail_folder_list.js +++ b/webcit-ng/static/js/mail_folder_list.js @@ -33,11 +33,26 @@ function display_mail_folder_list(target_div) { // Given a JSON object containing the output of the `/ctdl/r` API call, return a rendered mail folder list. function render_mail_folder_list(roomlist_json) { - let rendered_list = ""; + // Sort first by floor then by room order + roomlist_json.sort(function(a, b) { + if (a.floor > b.floor) return 1; + if (a.floor < b.floor) return -1; + if (a.rorder > b.rorder) return 1; + if (a.rorder < b.rorder) return -1; + return 0; + }); + + // Turn it into displayable markup + let rendered_list = ""; + rendered_list += ""; return rendered_list; } diff --git a/webcit-ng/static/js/util.js b/webcit-ng/static/js/util.js index 9e54e0f2d..6ea6d71d5 100644 --- a/webcit-ng/static/js/util.js +++ b/webcit-ng/static/js/util.js @@ -56,7 +56,7 @@ function escapeHTML(text) { } -// string escape for html display +// string escape for html display FIXME can this be replaced with encodeURI() from the standard library? function escapeHTMLURI(text) { 'use strict'; return text.replace(/./g, function (a) { @@ -66,7 +66,6 @@ function escapeHTMLURI(text) { // string escape for JavaScript string -// function escapeJS(text) { 'use strict'; return text.replace(/[\"\']/g, function (a) {