This repository has been archived by the owner on Mar 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index_pi.html
71 lines (59 loc) · 2.29 KB
/
index_pi.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
<head>
<meta charset="utf-8" />
<title>My Property Inspector</title>
<link rel="stylesheet" href="sdpi.css">
</head>
<body>
<div class="sdpi-wrapper">
<div class="sdpi-item">
<div class="sdpi-item-label">IP Address</div>
<input id="ipField" class="sdpi-item-value" value="" placeholder="MusicCast devide IP" required pattern="\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"
onchange="sendValueToPlugin(event.target.value)">
</div>
</div>
<script>
var websocket = null;
var context = null;
// called by streamdecj at startup
function connectSocket(inPort, inPropertyInspectorUUID, inRegisterEvent, inInfo, inActionInfo) {
websocket = new WebSocket('ws://localhost:' + inPort);
context = inPropertyInspectorUUID;
websocket.onopen = function () {
var json = {
"event": inRegisterEvent,
"uuid": inPropertyInspectorUUID
};
websocket.send(JSON.stringify(json));
sendStartup();
};
websocket.onmessage = function(event) {
var json = JSON.parse(event.data)
textField = document.getElementById("ipField")
textField.value = json.payload.IP
};
}
// Send ip address to plugin
function sendValueToPlugin(value) {
if (websocket) {
const json = {
"action": "de.louischrist.musiccast.power",
"event": "sendToPlugin",
"context": context, // as received from the 'connectSocket' event
"payload": { "IP": value, "type": "get" }
};
websocket.send(JSON.stringify(json));
}
}
function sendStartup() {
if (websocket) {
const json = {
"action": "de.louischrist.musiccast.power",
"event": "sendToPlugin",
"context": context, // as received from the 'connectSocket' event
"payload": {"type": "startup"}
};
websocket.send(JSON.stringify(json));
}
}
</script>
</body>