-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtext.html
More file actions
58 lines (47 loc) · 1.3 KB
/
text.html
File metadata and controls
58 lines (47 loc) · 1.3 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Emerging tech</title>
<style type="text/css">body{font-family: sans-serif;} label{display:block;}</style>
</head>
<body>
<h1>→ network_def</h1>
<pre id="network_def"></pre>
<h1>→ outbound</h1>
<pre id="outbound"></pre>
<h1>← inbound</h1>
<pre id="inbound" contenteditable>{
"node": "dc42",
"payload": [1]
}</pre>
<input type="submit">
<script src="bower_components/pubnub/web/pubnub.min.js"></script>
<script type="text/javascript">
var qs = document.querySelector.bind(document);
var pubnub = PUBNUB.init({
subscribe_key: 'sub-c-9c92c072-698f-11e4-97dd-02ee2ddab7fe',
publish_key: 'pub-c-10a63f9f-359c-472b-a6ba-d55766a60e69'
});
pubnub.subscribe({
channel: 'outbound,network_def',
backfill: true,
callback: function(message, _stuff, channel){
qs('#' + channel).innerText = JSON.stringify(message, null, 2);
}
});
document.querySelector('input').onclick = function(){
try{
var obj = JSON.parse(qs('#inbound').innerText);
pubnub.publish({
channel:'inbound',
message:obj
})
} catch (e){
alert("JSON, yo? - " + e.message)
console.error(e)
}
}
</script>
</body>
</html>