]> code.citadel.org Git - citadel.git/blobdiff - webcit-ng/static/js/view_mail.js
Rendering a single row in a mailbox now has its own function
[citadel.git] / webcit-ng / static / js / view_mail.js
index f3ee2acfab91bf6b4b2546cd1b3ab41106c119a2..ec40e6718f38191268bb71482f74683138e8c4c5 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>";