diff options
author | metamuffin <metamuffin@disroot.org> | 2022-09-10 18:09:14 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2022-09-10 18:09:14 +0200 |
commit | d889e1b572952c5777fc2bb147f04ad8baf7f497 (patch) | |
tree | c61a68864314290c85532311bb1cc3f5181f72cc /client-web/source/helper.ts | |
parent | e45770adfcc46fe5f0350767801204efdb14313b (diff) | |
download | keks-meet-d889e1b572952c5777fc2bb147f04ad8baf7f497.tar keks-meet-d889e1b572952c5777fc2bb147f04ad8baf7f497.tar.bz2 keks-meet-d889e1b572952c5777fc2bb147f04ad8baf7f497.tar.zst |
images in chat
Diffstat (limited to 'client-web/source/helper.ts')
-rw-r--r-- | client-web/source/helper.ts | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/client-web/source/helper.ts b/client-web/source/helper.ts index 1d75b60..3c5d0ff 100644 --- a/client-web/source/helper.ts +++ b/client-web/source/helper.ts @@ -1,14 +1,13 @@ /// <reference lib="dom" /> - - const elem = (s: string) => document.createElement(s) -interface Opts { class?: string[] | string, id?: string } +interface Opts { class?: string[] | string, id?: string, src?: string, onclick?: () => void } function apply_opts(e: HTMLElement, o: Opts | undefined) { if (!o) return if (o.id) e.id = o.id + if (o.onclick) e.onclick = o.onclick if (typeof o?.class == "string") e.classList.add(o.class) if (typeof o?.class == "object") e.classList.add(...o.class) } @@ -40,7 +39,6 @@ export const elabel = elem_with_content("label") export const OVERLAYS = ediv({ class: "overlays" }) - export class OverlayUi { _shown = false constructor(public el: HTMLElement, initial = false) { @@ -54,3 +52,13 @@ export class OverlayUi { } } +export function image_view(url: string, opts?: Opts): HTMLElement { + const img = document.createElement("img") + apply_opts(img, opts) + img.src = url + img.alt = `Image (click to open)` + img.addEventListener("click", () => { + window.open(url, "_blank", "noreferrer=true,noopener=true,popup=true") + }) + return img +} |