-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
46 lines (41 loc) · 1.61 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
37
38
39
40
41
42
43
44
45
46
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<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>
<script src="node_modules/codemirror/mode/javascript/javascript.js"></script>
<!-- socket.io -->
<script src="node_modules/socket.io-client/dist/socket.io.js"></script>
</head>
<body>
<textarea id="note"></textarea><br/>
<!--<textarea id="test"></textarea>-->
<!-- init client -->
<script>
var socket = io()
socket.on('doc', function(data) {
var cm = CodeMirror.fromTextArea(document.getElementById('note'), {lineNumbers: true, mode: "javascript"});
cm.setValue(data.str);
var serverAdapter = new ot.SocketIOAdapter(socket);
var editorAdapter = new ot.CodeMirrorAdapter(cm);
var client = new ot.EditorClient(data.docId, data.revision, data.clients, serverAdapter, editorAdapter);
})
</script>
</body>
</html>