Initial commit
This commit is contained in:
68
client/main.html
Normal file
68
client/main.html
Normal file
@ -0,0 +1,68 @@
|
||||
<html>
|
||||
<body>
|
||||
<a href="http://localhost:5000/console.html" target=console>console</a>
|
||||
<a href="http://localhost:5000/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=tt.tm,lev&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("http://localhost:5000/" + action.value.split("*").join(myid),
|
||||
function(message) { result.innerHTML = JSON.stringify(message); },
|
||||
function(status) { console.log(status); }
|
||||
)
|
||||
}
|
||||
|
||||
var evtSrc = new EventSource("http://localhost:5000/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>
|
Reference in New Issue
Block a user