-
Notifications
You must be signed in to change notification settings - Fork 0
/
controller.html
148 lines (138 loc) · 4.72 KB
/
controller.html
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
/>
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Presentation-Tool: Controller</title>
<link rel="stylesheet" href="css/controller.css" />
<script src="./socket.io/socket.io.js"></script>
<script src="./js/jquery-3.6.1.slim.min.js"></script>
<script>
$(function () {
var socket = io();
socket.on("slideStatus", (msg) => {
if (!msg.side || !(msg.side === "left" || msg.side === "right")) {
return false;
}
let msgArea;
if (msg.side === "left") {
msgArea = $("#messages_left");
} else if (msg.side === "right") {
msgArea = $("#messages_right");
}
if (msgArea.children().length > 5) {
msgArea.children().first().next("li").remove();
}
msgArea.append($("<li>").text(msg.code));
});
$("form").submit((e) => {
e.preventDefault();
const msgSelector = $("#m");
socket.emit("slideCommand", msgSelector.val());
msgSelector.val("");
return false;
});
$("ul#list").click((e) => {
let targetEle = $(e.target);
if (targetEle.is("small")) {
targetEle = targetEle.parent();
}
if (targetEle.attr("id")) {
$("li").removeClass("ac-active ac-next");
targetEle.addClass("ac-active ac-visited");
let nextEle = targetEle.next("li");
if (!nextEle.attr("id")) {
if (nextEle.children().length > 0) {
// Subordinate element
nextEle = targetEle.next("li").children().children().first();
} else if (
targetEle.parent().parent().next("li") &&
targetEle.parent().parent().next("li").attr("id")
) {
// Last subordinate element
nextEle = targetEle.parent().parent().next("li");
}
}
nextEle.addClass("ac-next");
console.log("Emit: ", targetEle.attr("id"));
socket.emit("slideCommand", targetEle.attr("id"));
}
});
$("ul#fast-list").click((e) => {
let targetEle = $(e.target);
if (targetEle.attr("id")) {
socket.emit("slideCommand", targetEle.attr("id"));
}
});
$("#gr").click((e) => {
let targetEle = $(e.target);
if (targetEle.attr("id")) {
socket.emit("slideCommand", targetEle.attr("id"));
}
});
$("body").keydown((e) => {
if(e.key === "PageDown") {
socket.emit("slideCommand", "next");
} else if(e.key === "PageUp") {
socket.emit("slideCommand", "prev");
}
})
});
</script>
</head>
<body>
<div class="grid" id="gr">
<div class="control special">
<div id="play">
<ion-icon name="videocam-sharp" aria-hidden="true"></ion-icon>
</div>
</div>
<div class="control prev" id="prev">
<ion-icon name="arrow-back-sharp" aria-label="Previous"></ion-icon>
</div>
<div class="control next" id="next">
<ion-icon name="arrow-forward-sharp" aria-label="Next"></ion-icon>
</div>
<div class="control start" id="start">
<ion-icon name="home-sharp" aria-label="Back to Start"></ion-icon>
</div>
<div class="control black" id="black">
<ion-icon name="contrast-sharp" aria-label="Toggle black"></ion-icon>
</div>
<section id="log">
<ul id="messages_left">
<small>Left</small>
</ul>
<ul id="messages_right">
<small>Right</small>
</ul>
</section>
<section class="actions">
<form><input id="m" /></form>
<ul id="list">
<li id="start">## START ##</li>
<li id="1">01 ABC</li>
<li id="2">02 DEF</li>
<li id="3">03 GEH</li>
<li id="pause">## PAUSE ##</li>
<li id="5">05 XYZ</li>
<li>
<ul>
<li id="5b">> XYZ 2</li>
<li id="5c">> XYZ 3</li>
</ul>
</li>
<li id="6">06 123</li>
<li id="encore">## ENCORE ##</li>
<li id="end">## END ##</li>
</ul>
</section>
</div>
<script type="module" src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.esm.js"></script>
<script nomodule src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.js"></script>
</body>
</html>