diff options
author | WlodekM <[email protected]> | 2024-12-01 12:32:53 +0200 |
---|---|---|
committer | WlodekM <[email protected]> | 2024-12-01 12:32:53 +0200 |
commit | 84ebada2cc3a7f6f094d249ceae0df49f66e55bc (patch) | |
tree | 470b9623677e0144d023ae99e6bb564fa89043ba /pages | |
parent | 18b3dc1aeaeac7114f68ea0eab9ad59c7991b0ae (diff) |
wip user popup
Diffstat (limited to 'pages')
-rw-r--r-- | pages/main/page.js | 20 |
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); |