-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
83 lines (72 loc) · 2.07 KB
/
index.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
<!doctype html>
<html><head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="http://cdn.jsdelivr.net/sockjs/1.0.1/sockjs.min.js"></script>
<style>
form input {
border: 1px solid;
-moz-border-radius: 4px;
border-radius: 4px;
width: 100%;
padding: 0px;
margin: 5px;
font-family: monospace;
height: 30px;
}
div#graph {
width: 98%;
height: 600px;
margin: 10px;
border: 1px solid black;
background-color: white;
}
body {
background-color: #F0F0F0;
font-family: "Arial";
}
</style>
</head><body lang="en">
<div id="graph">
</div>
<form>
<input autocomplete="off" value='{"type":"thing", "id":"x"}'>
</input>
</form>
<script>
var sockjs_url = '/echo';
var sockjs = new SockJS(sockjs_url);
$('input').focus();
var div = $('#graph');
var inp = $('input');
var form = $('form');
var print = function(p) {
p = (p === undefined) ? '' : JSON.stringify(p);
div.append($("<code>").text(p));
div.append($("<br>"));
div.scrollTop(div.scrollTop()+10000);
};
// sockjs.onopen = function() {print('[*] open', sockjs.protocol);};
sockjs.onmessage = function(e) {
var o = JSON.parse(e.data)
var p = o.request.parameters
if(p.query)
{
// console.log(o.response)
o.response[0].nodes.forEach(function(n){
console.log("NODE", n.id)
})
o.response[0].edges.forEach(function(e){
console.log("EDGE", e)
})
}
else
print(o.response)
};
// sockjs.onclose = function() {print('[*] close');};
form.submit(function() {
sockjs.send(inp.val());
inp.val('')
return false;
});
</script>
</body></html>