]> code.citadel.org Git - citadel.git/commitdiff
Consolidated all renderings of a user profile picture (avatar) into a single renderin...
authorArt Cancro <ajc@citadel.org>
Thu, 15 Sep 2022 22:37:50 +0000 (18:37 -0400)
committerArt Cancro <ajc@citadel.org>
Thu, 15 Sep 2022 22:37:50 +0000 (18:37 -0400)
webcit-ng/static/index.html
webcit-ng/static/js/main.js
webcit-ng/static/js/user_profile.js
webcit-ng/static/js/view_forum.js
webcit-ng/static/js/view_mail.js

index 262524895d900a851d92a420e17618ff4245be12..2a11550c655102d802db3eb632f832b54c8dc72a 100644 (file)
                        <li><button id="ctdl-ungoto-button" style="display:none" onClick="gotonext(0);">ungoto</button></li>
                        <li><button id="ctdl-skip-button" style="display:none" onClick="gotonext(1);">skip</button></li>
                        <li><button id="ctdl-goto-button" style="display:none" onClick="gotonext(2);">goto</button></li>
-                       <li><button id="lilo">Login</button><br>
-                       <span id="current_user">Not logged in.</span>
-                       <li><i class="fa fa-user-circle fa-3x"></i></li>
+                       <li>
+                               <span id="current_user">Not logged in.</span><br>
+                               <button id="lilo">Login</button>
+                       </li>
+                       <li><span id="current_user_avatar"><i class="fa fa-user-circle fa-3x"></i></span></li>
                </ul>
        </div>
 
index ec9ff04ffdf113fd37bbf20f177cce590bbb5b52..0e1f43b971e79bedc0ce3898f70edddf0047a2b3 100644 (file)
@@ -52,9 +52,11 @@ function update_banner() {
        document.getElementById("current_user").innerHTML = current_user ;
        if (logged_in) {
                document.getElementById("lilo").innerHTML = "<a href=\"/ctdl/a/logout\"><i class=\"fa fa-right-from-bracket\"></i>" + _("Log off") + "</a>" ;
+               document.getElementById("current_user_avatar").innerHTML = render_userpic(current_user);
        }
        else {
                document.getElementById("lilo").innerHTML = "<a href=\"javascript:display_login_screen('')\"><i class=\"fa fa-right-to-bracket\"></i>" + _("Log in") + "</a>" ;
+               document.getElementById("current_user_avatar").innerHTML = "<i class=\"fa fa-user-circle fa-3x\"></i>";
        }
 }
 
index fb46c525312e6d15912283fe1cccea017c947c25..0d9eca43275f5e3227d8357599fa2dc16db5dbc0 100644 (file)
@@ -4,7 +4,7 @@
 // disclosure are subject to the GNU General Public License v3.
 
 
-// Display the author of a message.  This can be called from many different views.
+// 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) {
@@ -21,7 +21,21 @@ function render_msg_author(msg) {
 }
 
 
-// Display the user profile for a user
+// 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";
 }
index 5f95ca724ba31999b254a0688fa9ed929cdd468e..9ebdd699ec5668c938d8b98bba1a7f05c14be578 100644 (file)
@@ -176,10 +176,7 @@ function forum_render_one(msg, existing_div) {
        try {
                outmsg =
                  "<div class=\"ctdl-fmsg-wrapper\">"                           // begin message wrapper
-               + "<div class=\"ctdl-avatar\" onClick=\"javascript:user_profile('" + msg.from + "');\">"
-               + "<img src=\"/ctdl/u/" + msg.from + "/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
+               + render_userpic(msg.from)                                      // user avatar
                + "<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
index 791c54d8446bea982200b4e99d53cc6f31edf714..3742fb94e01352b259a98172a20c5df6b35d1c98 100644 (file)
@@ -16,10 +16,7 @@ function mail_render_one(msg, target_div) {
        try {
                outmsg =
                  "<div class=\"ctdl-mmsg-wrapper\">"                           // begin message wrapper
-               + "<div class=\"ctdl-avatar\" onClick=\"javascript:user_profile('" + msg.from + "');\">"
-               + "<img src=\"/ctdl/u/" + msg.from + "/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
+               + render_userpic(msg.from)                                      // user avatar
                + "<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