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
73
|
/*
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, einput, elabel, enav, ep } from "./helper.ts"
import { VERSION } from "./index.ts"
import { ui_preferences } 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 function info_br() {
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
}
return efooter({ class: "info-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"),
)
}
export function control_bar(room: Room, side_ui_container: HTMLElement): HTMLElement {
const leave = ebutton("Leave", { class: "leave", onclick() { window.location.href = "/" } })
const chat = side_ui(side_ui_container, room.chat.element, "Chat")
const prefs = side_ui(side_ui_container, ui_preferences(), "Settings")
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()) }),
]
return enav({ class: "control-bar" }, leave, chat.el, prefs.el, ...local_controls)
}
export interface SideUI { el: HTMLElement, set_state: (s: boolean) => void }
export function side_ui(container: HTMLElement, content: HTMLElement, label: string): SideUI {
// TODO: close other side uis
const tray = ediv({ class: "side-tray" }, content)
const checkbox = einput("checkbox", {
onchange: () => {
if (checkbox.checked) {
tray.classList.add("animate-in")
container.appendChild(tray)
} else {
tray.classList.remove("animate-in")
tray.classList.add("animate-out")
setTimeout(() => { // TODO breaks if ui is being enabled while timeout is active
tray.classList.remove("animate-out")
container.removeChild(tray)
}, 400)
}
}
})
return {
el: elabel(label, { class: "side-ui-control" }, checkbox),
set_state(s) { checkbox.checked = s }
}
}
|