Rendering a single row in a mailbox now has its own function master
authorArt Cancro <ajc@citadel.org>
Sun, 3 Jul 2022 21:04:46 +0000 (17:04 -0400)
committerArt Cancro <ajc@citadel.org>
Sun, 3 Jul 2022 21:04:46 +0000 (17:04 -0400)
webcit-ng/static/js/defs.js
webcit-ng/static/js/util.js
webcit-ng/static/js/view_mail.js

index 571afc0..5a7397e 100644 (file)
@@ -1,4 +1,3 @@
-//
 // Copyright (c) 2016-2022 by the citadel.org team
 //
 // This program is open source software.  Use, duplication, or
@@ -26,7 +25,6 @@ var march_list = [] ;
 
 
 // List of defined views shamelessly swiped from libcitadel headers
-//
 var views = {
        VIEW_BBS                : 0,    // Bulletin board view
        VIEW_MAILBOX            : 1,    // Mailbox summary
index e25921e..629f071 100644 (file)
@@ -1,4 +1,3 @@
-//
 // Copyright (c) 2016-2022 by the citadel.org team
 //
 // This program is open source software.  Use, duplication, or
index f3ee2ac..ec40e67 100644 (file)
@@ -10,6 +10,21 @@ function select_message(msgnum) {
 }
 
 
+// render one row in the mailbox table (this could be called from one of several places)
+function mail_render_row(msg) {
+       row     = "<tr "
+               + "id=\"ctdl-msgsum-" + msg["msgnum"] + "\""
+               + "onClick=\"select_message(" + msg["msgnum"] + ")\""
+               + ">"
+               + "<td>" + msg["subject"] + "</td>"
+               + "<td>" + msg["author"] + " &lt;" + msg["addr"] + "&gt;</td>"
+               + "<td>" + convertTimestamp(msg["time"]) + "</td>"
+               + "<td>" + msg["msgnum"] + "</td>"
+               + "</tr>";
+       return(row);
+}
+
+
 // Set up the mailbox view
 function mail_display() {
        target_div = document.getElementById("ctdl-main");
@@ -33,15 +48,7 @@ function mail_display() {
                                + "</tr>";
 
                        for (var i=0; i<msgs.length; ++i) {
-                               box +=  "<tr "
-                                       + "id=\"ctdl-msgsum-" + msgs[i]["msgnum"] + "\""
-                                       + "onClick=\"select_message(" + msgs[i]["msgnum"] + ")\""
-                                       + ">"
-                                       + "<td>" + msgs[i]["subject"] + "</td>"
-                                       + "<td>" + msgs[i]["author"] + " &lt;" + msgs[i]["addr"] + "&gt;</td>"
-                                       + "<td>" + convertTimestamp(msgs[i]["time"]) + "</td>"
-                                       + "<td>" + msgs[i]["msgnum"] + "</td>"
-                                       + "</tr>";
+                               box += mail_render_row(msgs[i]);
                        }
 
                        box +=  "</table>";