-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
44 lines (36 loc) · 1.17 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>CoEditor Demo</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="src/co-editor.js" type="module"></script>
<!-- Use the script below to test the webpack build instead: -->
<!-- <script src="dist/co-editor.min.js"></script> -->
<style>
co-editor {
width: 400px;
height: 120px;
}
</style>
</head>
<body onload="init()">
<co-editor username="Pekka" id="one"></co-editor>
<co-editor username="Paavo" id="two"></co-editor>
<button id="join">Join session</button>
<script>
function init() {
const first = document.querySelector('#one');
const second = document.querySelector('#two');
first.initSession();
const delay = 5000;
first.addEventListener('update', e => setTimeout(() => second.receive(e.detail), delay));
second.addEventListener('update', e => setTimeout(() => first.receive(e.detail), delay));
document.querySelector("#join").addEventListener('click', e => {
second.joinSession();
});
}
</script>
</body>
</html>