-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
57 lines (52 loc) · 1.75 KB
/
index.html
File metadata and controls
57 lines (52 loc) · 1.75 KB
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
<!doctype html>
<html>
<head>
<title>Socket.IO chat</title>
<link rel = "stylesheet" href= "https://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: 30px;
}
</style>
</head>
<body>
<div class = "container">
<div class = "col-md-4">
<div class ="well">
<h3> Online User</h3>
<ul class = "list-group" id = "users"></ul>
</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(function(e) {
e.preventDefault();
socket.emit('send message', $message.val());
$message.val('');
});
socket.on('new message', function(data){
$chat.append('<div class= "well">' + data.msg+'</div>');
});
});
</script>
</body>
</html>