-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
39 lines (31 loc) · 1.06 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Liveblocks Auth</title>
</head>
<body>
<div>
<p id="status">Not connected</p>
<form onsubmit="return false;">
<input id="name" value="Max" required="" placeholder="Name">
<input id="room" value="asrez:devs:general" required="" placeholder="Room">
<button id="connect">Connect to Room</button>
</form>
</div>
<script type="module">
import { client } from "./room.js";
const elm_button = document.querySelector("#connect");
const elm_name = document.querySelector("#name");
const elm_room = document.querySelector("#room");
elm_button.addEventListener("click", () => {
localStorage.setItem("name", elm_name.value);
const { room, leave } = client.enterRoom(elm_room.value);
room.subscribe("others", (others) => {
document.getElementById("status").innerText = `There are ${others.length} other user(s) online`;
});
});
</script>
</body>
</html>