forked from remy/jsconsole
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremote.html
More file actions
36 lines (31 loc) · 816 Bytes
/
remote.html
File metadata and controls
36 lines (31 loc) · 816 Bytes
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="/EventSource.js"></script>
<script>
var id = window.location.search.replace(/.*\?/, ''),
origin = null;
window.addEventListener('message', function (event) {
origin = event.origin;
if (event.data == '__init__') {
return;
}
var xhr = new XMLHttpRequest(),
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>