3b218f4e86538d9a30d87cafba0f44c1d3df2fc0
[citadel.git] / webcit-ng / static / js / user_profile.js
1 // Copyright (c) 2016-2023 by the citadel.org team
2 //
3 // This program is open source software.  Use, duplication, or
4 // disclosure are subject to the GNU General Public License v3.
5
6
7 // Inline display the author of a message.  This can be called from many different views.
8 // For messages originating locally, it renders the display name linked to their profile.
9 // For messages originating locally, it renders the display name and their email address.
10 function render_msg_author(msg, view) {
11         if ((msg.locl) && (view == views.VIEW_BBS)) {
12                 return(
13                         "<span class=\"ctdl-username\" onClick=\"javascript:user_profile('" + msg.from + "');\">"
14                         + msg.from
15                         + "</span>"
16                 );
17         }
18         else {
19                 return("<span class=\"ctdl-username\">" + msg.from + " &lt;" + msg.rfca + "&gt;</span>");
20         }
21 }
22
23
24 // Inline display the profile picture for a user.  This can be called from anywhere.
25 function render_userpic(username) {
26         return(
27                 "<div class=\"ctdl-avatar\" onClick=\"javascript:user_profile('" + username + "');\">"
28                 + "<img src=\"/ctdl/u/" + username + "/userpic\" width=\"32\""
29                 + "onerror=\"this.parentNode.innerHTML='&lt;i class=&quot;fa fa-user-circle fa-2x&quot;&gt;&lt;/i&gt;'\">"
30                 + "</div>"                                                      // end avatar
31         );
32 }
33
34
35 // Display the user profile page for a user
36 function user_profile(who) {
37         document.getElementById("ctdl-main").innerHTML =
38                 render_userpic(who)
39                 + "This is the user profile page for " + who + ".<br>"
40                 + "FIXME finish this";
41 }