-
Notifications
You must be signed in to change notification settings - Fork 1
/
GetTileIndexByLayouts50.html
250 lines (227 loc) · 9.21 KB
/
GetTileIndexByLayouts50.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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
<!DOCTYPE html>
<html>
<head>
<title>Tile num by Layouts MCM9000 API 5.0</title>
</head>
<body>
<h2>MCM9000 API 5.0 Get Tile Index by Layouts</h2>
Enter MCM User Name: <input type="text" id="user" value="Admin"/>Password: <input type="password" id="password" value="Admin"/>
<br>Enter MCM IP or URL <input type="text" id="address" value="192.168.3.50"/><br>
<button type="button" id="btn_layout_types" onclick="PostMCMCommand()">First get layouts</button>
<button type="button" id="btn_device_names" onclick="PostMCMCommand2()">Collect Device Names</button>
<button type="button" id="btn_source_names" onclick="PostMCMCommand3()">Collect Source Names</button>
<select id="dLayouts">
<option> none selected </option>
</select>
<button type="button" id="btn_tile_indexes" onclick="PostMCMCommand4()"><- Get tile indexes for layout selected</button>
<div>
<span class="replace"> Displays Status </span>
</div>
<div>
<span class="replace2"></span>
</div>
<script>
var XMLReq, XMLReq2;
var holdReturn="";
var storeDevice = [];
var storeChannel = [];
const $layoutSelect = document.querySelector('#dLayouts');
var username = document.getElementById("user").value;
var password = document.getElementById("password").value;
var address = "http://" + document.getElementById("address").value;
window.onload=function(){
document.getElementById('dLayouts').style.visibility='hidden';
document.getElementById('btn_device_names').style.visibility='hidden';
document.getElementById('btn_source_names').style.visibility='hidden';
document.getElementById('btn_tile_indexes').style.visibility='hidden';
}
function PostMCMCommand() {
XMLReq = new XMLHttpRequest();
XMLReq.onreadystatechange = function()
{
holdReturn += XMLReq.status+" + ";
document.getElementsByClassName("replace")[0].innerHTML = "Returned Code: " + holdReturn;
if (XMLReq.status != 200 ) return;
callback(XMLReq);
};
XMLReq.open("Get", address + "/api/5.0/layouts/config/.json");
XMLReq.setRequestHeader("Authorization", 'Basic ' + btoa(username+":"+password));
XMLReq.setRequestHeader("Content-Type", "application/json");
XMLReq.send();
}
function callback(xhr)
{
var convert = xhr.responseText;
document.getElementsByClassName("replace2")[0].innerHTML = convert;
var jsonData = JSON.parse(convert);
var jString="<br>UUID --- label <br>";
storeChannel.length=0;
var idata=0;
for(var i in jsonData["data"]) {
var LTuuid = jsonData["data"][idata]["uuid"];
jString += LTuuid;
jString += " -- ";
var LTlabel = jsonData["data"][idata]["label"];
jString += LTlabel;
var Layout = {
uuid: LTuuid,
label: LTlabel
}
storeChannel.push(Layout);
jString += "<br>";
idata++;
}
document.getElementsByClassName("replace2")[0].innerHTML = jString;
document.getElementById("btn_layout_types").innerHTML = "Refresh Layouts";
$layoutSelect.options.length=0;
for (let i = 0; i < storeChannel.length; i++)
{
var opt = document.createElement('option');
opt.innerHTML = storeChannel[i]["label"];
opt.value = storeChannel[i]["uuid"];
$layoutSelect.appendChild(opt);
}
document.getElementById('btn_device_names').style.visibility='visible';
holdReturn="";
}
function PostMCMCommand2() {
XMLReq = new XMLHttpRequest();
XMLReq.onreadystatechange = function()
{
holdReturn += XMLReq.status+" + ";
document.getElementsByClassName("replace")[0].innerHTML = "Returned Code: " + holdReturn;
if (XMLReq.status != 200 ) return;
callback2(XMLReq);
};
XMLReq.open("Get", address + "/api/5.0/devices/config/.json");
XMLReq.setRequestHeader("Authorization", 'Basic ' + btoa(username+":"+password));
XMLReq.setRequestHeader("Content-Type", "application/json");
XMLReq.send();
}
function callback2(xhr)
{
var convert = xhr.responseText;
//document.getElementsByClassName("replace2")[0].innerHTML = convert;
var jsonData = JSON.parse(convert);
var jString="<br>UUID --- device -- label <br>";
storeDevice.length=0;
var idata=0;
for(var i in jsonData["data"]) {
var Duuid = jsonData["data"][idata]["uuid"];
jString += Duuid;
jString += " -- ";
var Dlabel = jsonData["data"][idata]["label"];
jString += Dlabel;
var Device = {
uuid: Duuid,
label: Dlabel
}
storeDevice.push(Device);
jString += "<br>";
idata++;
}
document.getElementsByClassName("replace2")[0].innerHTML = jString;
document.getElementById('btn_device_names').innerHTML = "Refresh Devices";
document.getElementById('btn_source_names').style.visibility='visible';
holdReturn="";
}
function PostMCMCommand3() {
XMLReq = new XMLHttpRequest();
XMLReq.onreadystatechange = function()
{
holdReturn += XMLReq.status+" + ";
document.getElementsByClassName("replace")[0].innerHTML = "Returned Code: " + holdReturn;
if (XMLReq.status != 200 ) return;
callback3(XMLReq);
};
XMLReq.open("Get", address + "/api/5.0/channels/config/.json");
XMLReq.setRequestHeader("Authorization", 'Basic ' + btoa(username+":"+password));
XMLReq.setRequestHeader("Content-Type", "application/json");
XMLReq.send();
}
function callback3(xhr)
{
var convert = xhr.responseText;
//document.getElementsByClassName("replace2")[0].innerHTML = convert;
var jsonData = JSON.parse(convert);
var jString="<br>UUID --- device -- label <br>";
storeChannel.length=0;
var idata=0;
for(var i in jsonData["data"]) {
var Cuuid = jsonData["data"][idata]["uuid"];
jString += Cuuid;
jString += " -- ";
var Cdevice = "UUID not in device list";
var InUuid = jsonData["data"][idata]["device"];
for (let isearch = 0; isearch < storeDevice.length; isearch++) {
if (storeDevice[isearch]['uuid'] == InUuid) {
Cdevice=storeDevice[isearch]['label'];
}
}
jString += Cdevice;
jString += " -- ";
var Clabel = jsonData["data"][idata]["label"];
jString += Clabel;
var Channel = {
uuid: Cuuid,
device: Cdevice,
label: Clabel
}
storeChannel.push(Channel);
jString += "<br>";
idata++;
}
document.getElementsByClassName("replace2")[0].innerHTML = jString;
document.getElementById('btn_source_names').innerHTML = "Refresh Sources";
document.getElementById('dLayouts').style.visibility='visible';
document.getElementById('btn_tile_indexes').style.visibility='visible';
holdReturn="";
}
function PostMCMCommand4() {
var dvalue = $layoutSelect.value;
//document.getElementsByClassName("replace2")[0].innerHTML = dvalue;
XMLReq2 = new XMLHttpRequest();
XMLReq2.onreadystatechange = function()
{
holdReturn += XMLReq2.status+" = ";
document.getElementsByClassName("replace")[0].innerHTML = "Returned Code: " + holdReturn;
if (XMLReq2.status != 200 ) return;
callback4(XMLReq2);
};
XMLReq2.open("Get", address + "/api/5.0/layouts/config/"+dvalue+"/.json");
XMLReq2.setRequestHeader("Authorization", 'Basic ' + btoa(username+":"+password));
XMLReq2.setRequestHeader("Content-Type", "application/json");
XMLReq2.send();
}
function callback4(xhr)
{
var convert = xhr.responseText;
//document.getElementsByClassName("replace2")[0].innerHTML = convert;
var jsonData = JSON.parse(convert);
var jString="<br>index -- Device -- Channel -- tally_settings<br>";
for(var i4 in jsonData["data"]["tiles"]) {
jString += jsonData["data"]["tiles"][i4]["index"];
jString += " -- ";
var Cuuid = jsonData["data"]["tiles"][i4]["channel"];
if(Cuuid){
for (let isearch = 0; isearch < storeChannel.length; isearch++) {
if (storeChannel[isearch]['uuid'] == Cuuid) {
jString += storeChannel[isearch]['device'];
jString += " -- ";
jString += storeChannel[isearch]['label'];
jString += " -- ";
}
}
} else {
jString += " no Channel assigned ";
}
jString += " -- ";
jString += jsonData["data"]["tiles"][i4]["tally_source"];
jString += "<br>";
}
document.getElementsByClassName("replace2")[0].innerHTML = jString;
holdReturn="";
}
</script>
</body>
</html>