-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclicks.js
74 lines (62 loc) · 2.19 KB
/
clicks.js
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
74
function joinRoom(button) {
changeButton(button);
movecanvas(button);
initXAudio();
// initVisualizer();
}
function changeButton(button) {
var skip = true;
if (button.id == window.room) {
send(null, "leave");
leaver(button.id);
button.isListening = false;
window.room = undefined;
window.desc = undefined;
skip = false;
} else {
button.isListening = true;
button.classList.add("bg-red-500")
button.classList.add("hover:bg-red-700")
button.classList.remove("bg-green-500")
button.classList.remove("hover:bg-green-700")
button.textContent = "Leave"
window.room = window.room == button.id ? undefined : button.id;
window.desc = window.desc == button.name ? undefined : button.name;
joiner(button.id);
send(null, "join");
}
document.querySelectorAll('button').forEach(element => {
if ((skip && element.id == button.id) || element.parentElement.id !== "room_parent") {
return;
}
element.isListening = false;
element.classList.remove("bg-red-500")
element.classList.remove("hover:bg-red-700")
element.classList.add("bg-green-500")
element.classList.add("hover:bg-green-700")
element.textContent = "Join"
leaver(button.id);
});
}
function movecanvas(button) {
document.getElementById(`room_card_${button.id}`).appendChild(document.getElementById("visualizer"))
}
function createRoom() {
var title = document.getElementById("create_title").value;
var description = document.getElementById("create_description").value;
if (title == "") {
var titleInput = document.getElementById("create_title")
titleInput.setCustomValidity("Missing room title");
titleInput.reportValidity()
return;
}
if (description == "") {
var descriptionInput = document.getElementById("create_description")
descriptionInput.setCustomValidity("Missing room description");
descriptionInput.reportValidity()
return;
}
addRoom(title, description);
send(null, "create")
joinRoom(document.getElementById(title));
}