diff options
author | WlodekM <[email protected]> | 2024-11-30 20:15:09 +0200 |
---|---|---|
committer | WlodekM <[email protected]> | 2024-11-30 20:15:09 +0200 |
commit | db84220e2bc60b637cc5736c556e2c0bc34d6ae3 (patch) | |
tree | a8d89084f320d5f84343cb9da1b1d0c93dd9e1e9 /pages | |
parent | ec81523b3933135463defba924245d78026d7ec0 (diff) |
use less, topbar (wip) also warkdown
Diffstat (limited to 'pages')
-rw-r--r-- | pages/login/page.js | 1 | ||||
-rw-r--r-- | pages/main/page.js | 23 |
2 files changed, 15 insertions, 9 deletions
diff --git a/pages/login/page.js b/pages/login/page.js index f0c5994..dcc6f20 100644 --- a/pages/login/page.js +++ b/pages/login/page.js @@ -8,6 +8,7 @@ export function onload() { ev.preventDefault(); const username = document.getElementById('username').value; const password = document.getElementById('password').value; + document.getElementById('topbar').classList.remove('hidden') try { await stores.sdlib.login(username, password) } catch (error) { diff --git a/pages/main/page.js b/pages/main/page.js index bd51d53..9edb966 100644 --- a/pages/main/page.js +++ b/pages/main/page.js @@ -1,5 +1,8 @@ import { shiftHeld } from "../../lib/key.js" import html from "../../lib/htmlbuilder.js" +import markdwonits from "https://cdn.jsdelivr.net/npm/[email protected]/+esm" + +const md = markdwonits() async function fetchJSON(url, opts) { let resp = await fetch(url, opts); @@ -10,12 +13,7 @@ function scrollToBottomOfElement(element) { element.scrollTo(0, element.scrollHeight); } -function handleNewPost() { - console.debug('posting of the poster', post) - let scrolledToBottom = msgArea.parentElement.scrollTopMax == msgArea.parentElement.scrollTop; - createMessage(post.data) - if(scrolledToBottom) scrollToBottomOfElement(msgArea.parentElement); -} +let handleNewPost; function deHTML(t) { t = t.replaceAll("<", "<") @@ -30,6 +28,13 @@ function getUsernameHTML(msg) { export function onload() { const msgArea = document.getElementById("messages"); + handleNewPost = function handleNewPost(post) { + console.debug('posting of the poster', post) + let scrolledToBottom = msgArea.parentElement.scrollTopMax == msgArea.parentElement.scrollTop; + createMessage(post.data) + if(scrolledToBottom) scrollToBottomOfElement(msgArea.parentElement); + } + let replies = [] function rednerReplyThingy() { @@ -41,7 +46,7 @@ export function onload() { html('div') .class('reply') .child('span') - .html(getUsernameHTML(r) + ": " + deHTML(r.content)) + .html(getUsernameHTML(r) + ": " + deHTML(String(r.content).slice(0, 50))) .up() .child('button') .text('x') @@ -62,7 +67,7 @@ export function onload() { .class('message') .for(msg.replies, r => html('div') .class('reply') - .html(`→ ${getUsernameHTML(r)}: ${deHTML(r.content)}`)) + .html(`→ ${getUsernameHTML(r)}: ${deHTML(String(r.content).slice(0, 50))}`)) .child('div') .class('message-header') .child('span') @@ -83,7 +88,7 @@ export function onload() { .up() .child('span') .class('post-content') - .text(msg?.content) + .html(md.render(msg?.content)) .child('div') .for(msg.attachments, a => html('img').class('attachment').attr('src', a)) .up() |