-
Notifications
You must be signed in to change notification settings - Fork 1
/
Delete Tiles.html
101 lines (95 loc) · 4.4 KB
/
Delete Tiles.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
<!DOCTYPE html>
<html>
<head>
<title>Delete Tile API 5.0 for MCM9000</title>
</head>
<body>
<h2>Delete Tile API 5.0 for MCM9000</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="layouts" onclick="PostMCMCommand()">Get Tiles</button><br>
<div>
<span class="delete">
UUID if you want to delete: <input type="text" id="uuid" size="45" />
<button type-"button" id="btnDelete" onclick="PostDelete()">send delete</button>
</span>
</div>
<div>
<span class="replace"> Displays Status </span>
</div>
<div>
<span class="replace2"></span>
</div>
<script>
var XMLReq;
var holdReturn="";
function PostDelete(){
XMLRq = new XMLHttpRequest();
XMLRq.onreadystatechange = function()
{
holdReturn += XMLReq.status+" = ";
document.getElementsByClassName("replace")[0].innerHTML = "Returned Code: " + holdReturn;
if (XMLReq.status != 200 ) return;
callback(XMLReq);
};
var username = document.getElementById("user").value;
var password = document.getElementById("password").value;
var address = "http://" + document.getElementById("address").value;
var deluuid = document.getElementById("uuid").value;
XMLRq.open("Delete", address + "/api/5.0/tiles/config/"+deluuid+".json");
XMLRq.setRequestHeader("Authorization", 'Basic ' + btoa(username+":"+password));
XMLRq.setRequestHeader("Content-Type", "application/json");
XMLRq.send();
}
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);
};
var username = document.getElementById("user").value;
var password = document.getElementById("password").value;
var address = "http://" + document.getElementById("address").value;
XMLReq.open("Get", address + "/api/5.0/tiles/config/.json");
XMLReq.setRequestHeader("Authorization", 'Basic ' + btoa(username+":"+password));
XMLReq.setRequestHeader("Content-Type", "application/json");
XMLReq.send();
}
function callback(xhr)
{
var convert = xhr.responseText;
//convert=convert.substring(1,convert.length-1);
var jsonData = JSON.parse(convert);
//if(convert.length<5)return;
// stripping off starting '{"data":[' and ending '],"metadata":{"config_version":0}}' phrases
convert=convert.substring(10,convert.length-36);
// since the Encoders all have same key word I'm splitting them in to groups
const encodeArray = convert.split("]},{");
// since I took of 2 curly braces at the end and 1 at the beginning I will have to add them back
var jsonStr = '{'+encodeArray[66]+']}';
var jString="<br>UUID --- label -- minwidth -- minheight <br>";
//jString+=jsonStr;
for (let i = 0; i < encodeArray.length; i++) {
// adding back in the 1 start and 2 end curly braces lost in split
jsonStr = '{'+encodeArray[i]+']}';
jsonData = JSON.parse(jsonStr);
//el.textContent = jsonData["Encoder"]["title"];
jString += jsonData["uuid"];
jString += " ----- ";
jString += jsonData["label"]
jString += " ----- ";
jString += jsonData["min_width"];
jString += " --- ";
jString += jsonData["min_height"];
jString+= '<br>';
}
document.getElementsByClassName("replace2")[0].innerHTML = jString;
//document.getElementsByClassName("replace2")[0].innerHTML = convert;
//document.getElementsByClassName("replace2")[0].innerHTML = encodeArray.length;
}
</script>
</body>
</html>