Show mailboxes in a list, ordered by floor+rorder
authorArt Cancro <ajc@citadel.org>
Sat, 14 Jan 2023 22:49:41 +0000 (17:49 -0500)
committerArt Cancro <ajc@citadel.org>
Sat, 14 Jan 2023 22:49:41 +0000 (17:49 -0500)
webcit-ng/static/js/mail_folder_list.js
webcit-ng/static/js/util.js

index 9f408f1a74feeda974ec48c6866e4860ae908f12..ce11fbacd64aa7ee48dc42437c8ac3a78dc81289 100644 (file)
@@ -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 += "<ul>";
        for (let i=0; i<roomlist_json.length; ++i) {
-               rendered_list += roomlist_json[i].name + "<br>";
+               if (roomlist_json[i].current_view == views.VIEW_MAILBOX) {
+                       rendered_list += "<li>";
+                       rendered_list += ( (roomlist_json[i].name == "Mail") ? _("INBOX") : escapeHTML(roomlist_json[i].name));
+               }
        }
+       rendered_list += "</ul>";
 
        return rendered_list;
 }
index 9e54e0f2d3ea3725c99259262d2e5777aa8da2c0..6ea6d71d53bbe0b916ef1cdd2a5567bb7568a730 100644 (file)
@@ -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) {