aboutsummaryrefslogtreecommitdiff
path: root/client-web/source/menu.ts
blob: 035f3aa181560e3e246eae3a5e10152cf010c028 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
    This file is part of keks-meet (https://codeberg.org/metamuffin/keks-meet)
    which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
    Copyright (C) 2022 metamuffin <metamuffin@disroot.org>
*/
/// <reference lib="dom" />

import { ebutton, ediv, efooter, enav, ep, OverlayUi } from "./helper.ts"
import { VERSION } from "./index.ts"
import { PrefUi } from "./preferences/ui.ts"
import { create_file_res } from "./resource/file.ts";
import { create_camera_res, create_mic_res, create_screencast_res } from "./resource/track.ts";
import { Room } from "./room.ts"

export class MenuBr extends OverlayUi {
    constructor() {
        const item = (name: string, cb: (() => void) | string) => {
            const p = document.createElement("p")
            const a = document.createElement("a")
            a.classList.add("menu-item")
            a.target = "_blank" // dont unload this meeting
            a.textContent = name
            if (typeof cb == "string") a.href = cb
            else a.addEventListener("click", cb), a.href = "#"
            p.append(a)
            return p
        }

        super(efooter({ class: "menu-br" },
            ep(`keks-meet ${VERSION}`, { class: "version" }),
            item("License", "https://codeberg.org/metamuffin/keks-meet/raw/branch/master/COPYING"),
            item("Source code", "https://codeberg.org/metamuffin/keks-meet"),
            item("Documentation", "https://codeberg.org/metamuffin/keks-meet/src/branch/master/readme.md"),
        ), true)
    }
}

export class BottomMenu extends OverlayUi {
    constructor(room: Room) {
        // TODO this should ideally be a checkbox 
        const chat_toggle = document.createElement("input")
        chat_toggle.type = "button"
        chat_toggle.value = "Chat"
        chat_toggle.ariaHasPopup = "menu"
        chat_toggle.onclick = () => {
            room.chat.shown = !room.chat.shown
            if (room.chat.shown) chat_toggle.classList.add("active")
            else chat_toggle.classList.remove("active")
        }

        const prefs_button = document.createElement("input")
        prefs_button.type = "button"
        prefs_button.value = "Settings"
        prefs_button.ariaHasPopup = "menu"

        const prefs = new PrefUi()
        prefs_button.onclick = () => {
            prefs.shown = !prefs.shown
            if (prefs.shown) prefs_button.classList.add("active")
            else prefs_button.classList.remove("active")
        }

        const local_controls = ediv({ class: "local-controls", aria_label: "local resources" },
            ebutton("Microphone", { onclick: () => room.local_user.await_add_resource(create_mic_res()) }),
            ebutton("Camera", { onclick: () => room.local_user.await_add_resource(create_camera_res()) }),
            ebutton("Screen", { onclick: () => room.local_user.await_add_resource(create_screencast_res()) }),
            ebutton("File", { onclick: () => room.local_user.await_add_resource(create_file_res()) }),
        )

        super(enav({ class: "bottom-menu" }, chat_toggle, prefs_button, local_controls))
    }
}