Moved render_msg_author() into a different file
authorArt Cancro <ajc@citadel.org>
Fri, 9 Sep 2022 22:08:57 +0000 (18:08 -0400)
committerArt Cancro <ajc@citadel.org>
Fri, 9 Sep 2022 22:08:57 +0000 (18:08 -0400)
webcit-ng/static/js/user_profile.js
webcit-ng/static/js/view_forum.js
webcit-ng/static/js/view_mail.js

index 70c853bf941f34b58f86892bfb48dfbbfac992e0..fb46c525312e6d15912283fe1cccea017c947c25 100644 (file)
@@ -4,6 +4,24 @@
 // disclosure are subject to the GNU General Public License v3.
 
 
+// Display the author of a message.  This can be called from many different views.
+// For messages originating locally, it renders the display name linked to their profile.
+// For messages originating locally, it renders the display name and their email address.
+function render_msg_author(msg) {
+       if (msg.locl) {
+               return(
+                       "<span class=\"ctdl-username\" onClick=\"javascript:user_profile('" + msg.from + "');\">"
+                       + msg.from
+                       + "</span>"
+               );
+       }
+       else {
+               return("<span class=\"ctdl-username\">" + msg.from + " &lt;" + msg.rfca + "&gt;</span>");
+       }
+}
+
+
+// Display the user profile for a user
 function user_profile(who) {
        document.getElementById("ctdl-main").innerHTML = `user_profile(${who})`;
 }
index c5f0d61797fbe8be7414953389a3892e2dc89415..5f95ca724ba31999b254a0688fa9ed929cdd468e 100644 (file)
@@ -183,9 +183,7 @@ function forum_render_one(msg, existing_div) {
                + "<div class=\"ctdl-fmsg-content\">"                           // begin content
                + "<div class=\"ctdl-msg-header\">"                             // begin header
                + "<span class=\"ctdl-msg-header-info\">"                       // begin header info on left side
-               + "<span class=\"ctdl-username\" onClick=\"javascript:user_profile('" + msg.from + "');\">"
-               + msg.from
-               + "</a></span>"                                                 // end username
+               + render_msg_author(msg)                                        // author
                + "<span class=\"ctdl-msgdate\">"
                + string_timestamp(msg.time,0)
                + "</span>"                                                     // end msgdate
index 5effc0b461bcc9180d5750c464a14c7789803f84..3499f49b96a59ee56a88f31b631836b6df5dd3ff 100644 (file)
@@ -13,7 +13,7 @@ var RefreshMailboxInterval;                                                   // We store our refresh timer here
 // Render a message into the mailbox view
 function mail_render_one(msg, target_div) {
        let div = "FIXME";
-       console.log(msg);
+       console.log(render_msg_author(msg));
        try {
                outmsg =
                  "<div class=\"ctdl-mmsg-wrapper\">"                           // begin message wrapper
@@ -24,9 +24,7 @@ function mail_render_one(msg, target_div) {
                + "<div class=\"ctdl-mmsg-content\">"                           // begin content
                + "<div class=\"ctdl-msg-header\">"                             // begin header
                + "<span class=\"ctdl-msg-header-info\">"                       // begin header info on left side
-               + "<span class=\"ctdl-username\" onClick=\"javascript:user_profile('" + msg.from + "');\">"
-               + msg.from
-               + "</a></span>"                                                 // end username
+               + render_msg_author(msg)
                + "<span class=\"ctdl-msgdate\">"
                + string_timestamp(msg.time,0)
                + "</span>"                                                     // end msgdate