-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProRemote.html
More file actions
114 lines (97 loc) · 2.32 KB
/
ProRemote.html
File metadata and controls
114 lines (97 loc) · 2.32 KB
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
<html>
<head>
<title>ProRemote</title>
<script>
var socket;
var host = '10.10.5.102';
var port = '12345';
var password = 'admin';
var stageDisplayLayoutIndex;
var messageLayoutIndex;
var kidsMessage;
function err(s) {
document.getElementById('errbox').innerHTML = s;
return false;
}
function check_socket() {
if (!socket) return err('SOCKET NOT CONNECTED');
if (socket.readyState != 1) return err('SOCKET NOT READY');
return true;
}
function setup() {
connect();
listen();
}
function connect() {
socket = new WebSocket(`ws://${host}:${port}/remote`);
socket.onopen = function (event) {
console.log('Connected');
authenticate();
}
listen();
}
function listen() {
socket.onmessage = function (event) {
var msg = JSON.parse(event.data);
console.log(msg);
switch (msg.action) {
case "authenticate":
controlling = (msg.controller == 1);
text = "(" + msg.timeStr + ") <b>" + msg.name + "</b>: " + msg.text + "<br>";
break;
case "psl":
stageDisplayLayoutIndex = msg.uid;
if (stageDisplayLayoutIndex == 0) {
messageLayoutIndex = 0;
} else { messageLayoutIndex = 1 }
break;
}
}
}
function emit(obj) {
var json = JSON.stringify(obj);
if (check_socket()) socket.send(json);
else return err('SOCKET EMIT FAILED');
}
function authenticate() {
emit({
action: 'authenticate',
protocol: '600',
password: password
});
}
function myMessageSend(message) {
emit({ acn: "psl" });
setTimeout(function () {
getKidsMessage();
nowSend(messageLayoutIndex, kidsMessage)
}, 1500);
}
function nowSend(messageLayoutIndex, messageValue) {
emit({
"action": "messageSend",
"messageIndex": messageLayoutIndex,
"messageKeys": ['Message'],
"messageValues": [messageValue]
});
}
function getKidsMessage() {
kidsMessage = document.getElementById("kidsId").value;
alert(kidsMessage);
}
setup();
console.log('hi');
</script>
</head>
<body>
<div id="errbox"></div>
<div id="infobox"></div>
<div id="library"></div>
<div id="playlists"></div>
<div id="presentation"></div>
<form>
Kids Nummer: <input type="text" id="kidsId"><br>
<input type="submit" value= "Send" onsubmit="myMessageSend(); return false"></input>
</form>
</body>
</html>