-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGetReceiverData.html
More file actions
59 lines (56 loc) · 2.53 KB
/
GetReceiverData.html
File metadata and controls
59 lines (56 loc) · 2.53 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
<!DOCTYPE html>
<html>
<head>
<title>MCM9000 API 4.0 Get Receiver Data</title>
</head>
<body>
<h2>MCM9000 API 4.0 Get Receiver Data with Label</h2>
<label>Enter MCM User Name: <input type="text" id="user" value="Admin"/></label>
<label>Password: <input type="password" id="password" value="Admin"/></label>
<br>
<label>Enter MCM IP or URL: <input type="text" id="address" value="192.168.3.49"/></label>
<br>
<button type="button" id="btn_layout_types" onclick="postMCMCommand()">Get Receiver Data</button>
<div>
<span class="replace">Displays Status</span>
</div>
<div>
<span class="replace2"></span>
</div>
<div>
<br><br>
<span class="RAWreplace"></span>
</div>
<script>
function postMCMCommand() {
const xhr = new XMLHttpRequest();
const user = document.getElementById("user").value;
const password = document.getElementById("password").value;
const address = "http://" + document.getElementById("address").value;
const replaceElement = document.getElementsByClassName("replace")[0];
const replaceElement2 = document.getElementsByClassName("replace2")[0];
const replaceElement3 = document.getElementsByClassName("RAWreplace")[0];
replaceElement2.innerHTML = ""; //Clearing for refreshes by user
xhr.onreadystatechange = function() {
if (xhr.readyState === XMLHttpRequest.DONE) {
replaceElement.innerHTML = "HTML API Returned Code: " + xhr.status;
if (xhr.status === 200) {
const responseText = xhr.responseText;
var jsonData = JSON.parse(responseText);
for (var i in jsonData) {
replaceElement2.innerHTML += "<br>" + jsonData[i]["Receiver"]["receiver_uuid"] + " --- with label --- " + jsonData[i]["Receiver"]["receiver_label"] ;
}
replaceElement3.innerHTML = "--End--";
//replaceElement3.innerHTML = responseText; // You can modify this to parse and display JSON as needed
document.getElementById("btn_layout_types").innerHTML = "Refresh Receiver Data";
}
}
};
xhr.open("GET", address + "/api/4.0/receivers/.json");
xhr.setRequestHeader("Authorization", 'Basic ' + btoa(user + ":" + password));
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send();
}
</script>
</body>
</html>