forked from remy/jsconsole
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathremote.html
36 lines (32 loc) · 963 Bytes
/
remote.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset=utf-8 />
<title>remote</title>
</head>
<body>
<script src="/js/EventSource.js"></script>
<script>
/* jshint browser:true */
var id = window.location.search.replace(/.*\?/, '');
var origin = null;
window.addEventListener('message', function (event) {
origin = event.origin;
if (event.data === '__init__' || typeof event.data !== 'string') {
return;
}
var xhr = new XMLHttpRequest();
var params = 'data=' + encodeURIComponent(event.data);
xhr.open('POST', '/remote/' + id + '/log', true);
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.send(params);
}, false);
setTimeout(function () {
var sse = new EventSource('/remote/' + id + '/run');
sse.onmessage = function (event) {
window.top.postMessage(event.data, origin);
};
}, 13);
</script>
</body>
</html>