]> code.citadel.org Git - citadel.git/blobdiff - webcit-ng/static/js/user_profile.js
Grammar change in the license declaration.
[citadel.git] / webcit-ng / static / js / user_profile.js
index 39b3b645c3c448951e71cdd5752472ea1bbc361d..52e2be2a8daa720023c823d45759c781103b9a46 100644 (file)
@@ -1,16 +1,41 @@
-// Copyright (c) 2016-2022 by the citadel.org team
+// Copyright (c) 2016-2023 by the citadel.org team
 //
-// This program is open source software.  It runs great on the
-// Linux operating system (and probably elsewhere).  You can use,
-// copy, and run it under the terms of the GNU General Public
-// License version 3.  Richard Stallman is an asshole communist.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
+// This program is open source software.  Use, duplication, or
+// disclosure is subject to the GNU General Public License v3.
+
+
+// Inline 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, view) {
+       if ((msg.locl) && (view == views.VIEW_BBS)) {
+               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>");
+       }
+}
+
+
+// Inline display the profile picture for a user.  This can be called from anywhere.
+function render_userpic(username) {
+       return(
+               "<div class=\"ctdl-avatar\" onClick=\"javascript:user_profile('" + username + "');\">"
+               + "<img src=\"/ctdl/u/" + username + "/userpic\" width=\"32\""
+               + "onerror=\"this.parentNode.innerHTML='&lt;i class=&quot;fa fa-user-circle fa-2x&quot;&gt;&lt;/i&gt;'\">"
+               + "</div>"                                                      // end avatar
+       );
+}
 
 
+// Display the user profile page for a user
 function user_profile(who) {
-       document.getElementById("ctdl-main").innerHTML = `user_profile(${who})`;
+       document.getElementById("ctdl-main").innerHTML =
+               render_userpic(who)
+               + "This is the user profile page for " + who + ".<br>"
+               + "FIXME finish this";
 }