-
Notifications
You must be signed in to change notification settings - Fork 12
/
index.html
executable file
·36 lines (34 loc) · 1.22 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
<html>
<head>
<meta charset="UTF-8">
<title>ot.js Demo</title>
<!-- ot.js -->
<script src="ot.js/text-operation.js"></script>
<script src="ot.js/selection.js"></script>
<script src="ot.js/wrapped-operation.js"></script>
<script src="ot.js/undo-manager.js"></script>
<script src="ot.js/client.js"></script>
<script src="ot.js/codemirror-adapter.js"></script>
<script src="ot.js/socketio-adapter.js"></script>
<script src="ot.js/editor-client.js"></script>
<!-- CodeMirror -->
<link rel="stylesheet" href="node_modules/codemirror/lib/codemirror.css">
<script src="node_modules/codemirror/lib/codemirror.js"></script>
<!-- socket.io -->
<script src="node_modules/socket.io-client/dist/socket.io.js"></script>
</head>
<body>
<textarea id="note"></textarea>
<!-- init client -->
<script>
var socket = io()
socket.on('doc', function(data) {
var cm = CodeMirror.fromTextArea(document.getElementById('note'), {lineNumbers: true})
cm.setValue(data.str)
var serverAdapter = new ot.SocketIOAdapter(socket)
var editorAdapter = new ot.CodeMirrorAdapter(cm)
var client = new ot.EditorClient(data.revision, data.clients, serverAdapter, editorAdapter)
})
</script>
</body>
</html>