-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathedit.html
More file actions
44 lines (34 loc) · 882 Bytes
/
edit.html
File metadata and controls
44 lines (34 loc) · 882 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
37
38
39
40
41
42
43
44
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
textarea {
width:800px;
height:600px;
}
</style>
</head>
<body>
<textarea id="content" autofocus> </textarea>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/socket.io/1.3.6/socket.io.min.js"></script>
<script>
document.addEventListener('DOMContentLoaded', () =>{
let content = document.querySelector('#content');
function show(html){
content.value = html;
}
let socket = io.connect('http://' + document.domain + ':' + location.port);
socket.on('connect', function() {
socket.on('update', function(html){
console.log('updated')
show(html);
})
content.onkeyup = function() {
socket.emit('edit', content.value)
}
});
})
</script>
</body>
</html>