-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
87 lines (84 loc) · 2.95 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Ably Chat</title>
<script src="https://cdn.ably.io/lib/ably.min-1.js"></script>
<script src="index.js" defer></script>
<style>
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
#chat-container {
position: relative;
width: 100%;
height: 450px;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
#form {
background: rgba(0, 0, 0, 0.15);
padding: 0.25rem;
position: absolute;
bottom: 0;
left: 0;
right: 0;
display: flex;
height: 3rem;
box-sizing: border-box;
backdrop-filter: blur(10px);
}
#input { border: none; padding: 0 1rem; flex-grow: 1; border-radius: 2rem; margin: 0.25rem; }
#input:focus { outline: none; }
#form > button { background: #333; border: none; padding: 0 1rem; margin: 0.25rem; border-radius: 3px; outline: none; color: #fff; }
#messages {
list-style-type: none;
margin: 0;
padding: 0;
position: absolute;
top: 40px;
bottom: 3rem;
left: 0;
right: 0;
overflow-y: auto;
}
.message { padding: 10px; border-radius: 10px; margin-bottom: 5px; max-width: 70%; word-wrap: break-word;}
.my-message { background-color: #cce5ff; align-self: flex-end;}
.other-message { background-color: #e2e3e5; align-self: flex-start;}
.pinged { background-color: yellow !important;}
.online-users { margin-bottom: 1rem; position: absolute; top: 0; left: 0; right: 0; padding: 10px; background: #f8f9fa; }
.private-message { color: blue; }
@media (max-width: 600px) {
#chat-container { font-size: smaller; }
#form { flex-direction: column; height: auto; }
#input { width: calc(100% - 20px); margin-bottom: 5px; }
#form > button { width: calc(100% - 20px); }
}
#scroll-down-button {
display: none;
position: absolute;
bottom: 3.5em;
right: .5em;
background-color: #007bff;
color: white;
border: none;
padding: .5em;
border-radius: .25em;
cursor: pointer;
}
</style>
</head>
<body>
<div id="chat-container">
<div class="online-users">Online Users Count: <span id="user-count">0</span></div>
<ul id="messages"></ul>
<form id="form" action="">
<input id="input" autocomplete="off" placeholder="Type your message..." />
<button>Send</button>
<input id="nickname" placeholder="Enter your nickname (no spaces, max 20 characters)" />
<button type="button" id="set-nickname">Set Name</button>
</form>
<audio id="ping-sound" src="ping.mp3" preload="auto"></audio>
<button id="scroll-down-button">Scroll Down</button>
</div>
</body>
</html>