diff options
author | metamuffin <metamuffin@disroot.org> | 2022-09-09 10:39:13 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2022-09-09 10:39:13 +0200 |
commit | afed94bb4609bd796102c9184f13fa29c5f92a48 (patch) | |
tree | 6d40b78dcc6174e148cf5b9531366e3712c223f7 /client-web/source/helper.ts | |
parent | 7c039b507695d0dbb8d00e583f7ce29b6925dcdc (diff) | |
download | keks-meet-afed94bb4609bd796102c9184f13fa29c5f92a48.tar keks-meet-afed94bb4609bd796102c9184f13fa29c5f92a48.tar.bz2 keks-meet-afed94bb4609bd796102c9184f13fa29c5f92a48.tar.zst |
server is only a relay now.
Diffstat (limited to 'client-web/source/helper.ts')
-rw-r--r-- | client-web/source/helper.ts | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/client-web/source/helper.ts b/client-web/source/helper.ts index ef95e3a..c277c0d 100644 --- a/client-web/source/helper.ts +++ b/client-web/source/helper.ts @@ -4,3 +4,28 @@ export function hex_id(len = 8): string { if (len > 8) return hex_id() + hex_id(len - 8) return Math.floor(Math.random() * 16 ** len).toString(16).padStart(len, "0") } + +const elem = (s: string) => document.createElement(s) +const elem_with_content = (s: string) => (c: string) => { + const e = elem(s) + e.textContent = c + return e +} +const elem_with_children = (s: string) => (opts: { classes?: string[] }, ...cs: (HTMLElement | string)[]) => { + const e = elem(s) + if (opts.classes) e.classList.add(...opts.classes) + for (const c of cs) { + e.append(c) + } + return e +} + +export const ep = elem_with_content("p") +export const eh1 = elem_with_content("h1") +export const eh2 = elem_with_content("h2") +export const eh3 = elem_with_content("h3") +export const eh4 = elem_with_content("h4") +export const eh5 = elem_with_content("h5") +export const eh6 = elem_with_content("h6") +export const ediv = elem_with_children("div") + |