summary refs log tree commit diff
path: root/pages/main/page.js
diff options
context:
space:
mode:
Diffstat (limited to 'pages/main/page.js')
-rw-r--r--pages/main/page.js20
1 files changed, 17 insertions, 3 deletions
diff --git a/pages/main/page.js b/pages/main/page.js
index d3357cb..1c20850 100644
--- a/pages/main/page.js
+++ b/pages/main/page.js
@@ -1,6 +1,9 @@
 import { shiftHeld } from "../../lib/key.js"
 import html from "../../lib/htmlbuilder.js"
 import markdwonits from "https://cdn.jsdelivr.net/npm/[email protected]/+esm"
+import { openPopup } from "../../lib/popups.js";
+
+window.html = html // debug
 
 const md = markdwonits()
 
@@ -9,6 +12,13 @@ async function fetchJSON(url, opts) {
     return await resp.json()
 }
 
+function buildUserPopup(userData) {
+    return html('div')
+        .child('pre')
+            .text(JSON.stringify(userData))
+            .up()
+}
+
 function scrollToBottomOfElement(element) {
     element.scrollTo(0, element.scrollHeight);
 }
@@ -25,7 +35,7 @@ function getUsernameHTML(msg) {
     return msg.author.display_name ? `${deHTML(msg.author.display_name)} (<code>${deHTML(msg.author.username)}</code>)`: deHTML(r.author.username)
 }
 
-export function onload() {
+export async function onload() {
     const msgArea = document.getElementById("messages");
 
     handleNewPost = function handleNewPost(post) {
@@ -75,6 +85,8 @@ export function onload() {
                 .class('message-container')
                 .child('img')
                     .attr('src', msg.author.avatar)
+                    .class('avatar')
+                    .ev('click', e => openPopup(buildUserPopup(msg.author)))
                     .up()
                 .child('div')
                     .class('message-content-container')
@@ -115,7 +127,9 @@ export function onload() {
                                         .attr('type', types[i])
                                         .up()
                             } else {
-                                return html('a').attr('href', a).text(`Attachment ${i + 1} (${a})`)
+                                return html('a')
+                                    .txt(`Attachment ${i + 1} (${a})`)
+                                    .attr('href', a)
                             }
                         })
                         .up()
@@ -129,7 +143,7 @@ export function onload() {
     // :+1:
 
     for (const msg of window.stores.sdlib.messages.reverse()) {
-        createMessage(msg)
+        await createMessage(msg)
     }
     scrollToBottomOfElement(msgArea.parentElement);