69 lines
2.0 KiB
HTML
69 lines
2.0 KiB
HTML
<html>
|
|
<body>
|
|
<a href="/console.html" target=console>console</a>
|
|
<a href="/group.html?path=/nv" target=group>group</a>
|
|
<button onclick="action.value='getblock?path=/nv&id=*';">?getblock</button>
|
|
<button onclick="action.value='updateblock?path=/nv&id=*';">?updateblock</button>
|
|
<button onclick="action.value='console?id=*';">?console</button>
|
|
<button onclick="action.value='gettime?time=-1800,0&id=*';">?gettime</button>
|
|
<button onclick="action.value='getvars?time=-1800,0&id=*';">?getvars</button>
|
|
<button onclick="action.value='graph?time=-1800,0&variables=t_mix&id=*';">?graph</button><br>
|
|
<input type=text value="console?id=*" size=120 id=action>
|
|
<button onclick='act();'>Send</button>
|
|
<div id=result>
|
|
</div><p>
|
|
<textarea rows=50 cols=132 id=t>
|
|
</textarea>
|
|
<script type="text/javascript">
|
|
|
|
var myid = 0
|
|
var result = document.getElementById("result")
|
|
var action = document.getElementById("action")
|
|
|
|
function getJSON(url, successHandler, errorHandler) {
|
|
var xhr = typeof XMLHttpRequest != 'undefined'
|
|
? new XMLHttpRequest()
|
|
: new ActiveXObject('Microsoft.XMLHTTP');
|
|
console.log("fired JSON request", url)
|
|
xhr.open('get', url, true);
|
|
xhr.onreadystatechange = function() {
|
|
var status;
|
|
var data;
|
|
// https://xhr.spec.whatwg.org/#dom-xmlhttprequest-readystate
|
|
if (xhr.readyState == 4) { // `DONE`
|
|
status = xhr.status;
|
|
if (status == 200) {
|
|
data = JSON.parse(xhr.responseText);
|
|
successHandler && successHandler(data);
|
|
} else {
|
|
errorHandler && errorHandler(status);
|
|
}
|
|
}
|
|
};
|
|
xhr.send();
|
|
};
|
|
|
|
function insert(link) {
|
|
action.value = link
|
|
}
|
|
|
|
function act() {
|
|
getJSON("/" + action.value.split("*").join(myid),
|
|
function(message) { result.innerHTML = JSON.stringify(message); },
|
|
function(status) { console.log(status); }
|
|
)
|
|
}
|
|
|
|
var evtSrc = new EventSource("/update");
|
|
|
|
evtSrc.onmessage = function(e) {
|
|
var message = JSON.parse(e.data);
|
|
if (message.type == "id") {
|
|
myid = message.id
|
|
}
|
|
t.value = t.value + e.data + "\n";
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|