-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
56 lines (53 loc) · 1.76 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Chat box!!</title>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script src="/socket.io/socket.io.js"></script>
<style>
body{
margin-top: 300px;
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-4">
<div class="well">
<h3>Online Users</h3>
<ul class="list-group" id="users"></ul>
</div>
</div>
<div class="col-md-8">
<div class="chat" id="chat"></div>
<form id="messageForm">
<div class="form-group">
<label>enter message</label>
<textarea class="form-control" id="message"></textarea>
<br>
<input type="submit" class="btn btn-primary" value="Send Message"/>
</div>
</form>
</div>
</div>
</div>
<script>
$(function(){
var socket=io.connect();
var $messageForm=$('#messageForm');
var $message=$('#message');
var $chat=$('#chat');
$messageForm.submit((e)=>{
e.preventDefault();
console.log('Submitted');
socket.emit('send message',$message.val());
$message.val('');
});
});
</script>
</body>
</html>