-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
124 lines (107 loc) · 2.31 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>BeneChat - webSockte</title>
<link rel="icon" href="public/bene.png" type="image/x-icon">
<script src="/socket.io/socket.io.js"></script>
<script src="https://code.jquery.com/jquery-3.6.3.min.js" integrity="sha256-pvPw+upLPUjgMXY0G+8O0xUf+/Im1MZjXxxgOcBQBXU=" crossorigin="anonymous"></script>
<style>
* {
box-sizing: border-box;
}
body {
font-family: Arial, Helvetica, sans-serif;
margin: 0;
background-color: rgb(211, 211, 211);
}
ul {
list-style: none;
text-indent: -2em;
}
ul li:before {
content: "\1F63A";
margin: 0 0.5em;
}
button {
cursor: pointer;
}
button:active {
transform: scale(0.95);
}
input:focus, button:focus {
outline: none;
}
header {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 10px 0;
position: relative;
}
header * {
z-index: 1;
}
header h1 {
margin: 0 0 30px;
}
form {
position: relative;
width: 500px;
max-width: 100%;
}
form input {
border: 0;
border-radius: 50px;
font-size: 16px;
padding: 15px 30px;
width: 100%;
}
a {
color: #0d0d0e;
text-decoration: none;
}
form button {
position: absolute;
top: 2px;
right: 1px;
background-color: #0d0d0e;
border: 0;
border-radius: 50px;
color: #fff;
font-size: 16px;
padding: 13px 30px;
}
form button:hover {
background-color: #0707f5;
color: rgb(255, 255, 255);
}
</style>
</head>
<body>
<header>
<form id="form">
<input type="text" id="msg" placeholder="Enter your message" autofocus>
<button type="submit">Send</button>
</header>
<ul id="messages"></ul>
<div id="status"></div>
<script>
$(function () {
const socket = io();
$('#form').submit(function(e){
e.preventDefault();
socket.emit('chat message', $('#msg').val());
$('#msg').val('');
return false;
});
socket.on('chat message', function(msg){
$('#messages').append($('<li>').text(msg));
});
});
</script>
</body>
</html>