-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.html
94 lines (70 loc) · 3.14 KB
/
client.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
<!DOCTYPE html>
<html>
<head>
<title>Chat Room</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<link rel = "stylesheet" type = "text/css" href="styleSheet.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="/socket.io/socket.io.js"></script>
<script type ="text/javascript">
$(window).load(function(){
$('#loginModal').modal('show');
});
var socketio = io.connect();
socketio.on("message_to_client",function(data) {
//Append an HR thematic break and the escaped HTML of the new message
document.getElementById("chatlog").appendChild(document.createElement("hr"));
document.getElementById("chatlog").appendChild(document.createTextNode(data['message']));
});
function sendMessage(){
var msg = document.getElementById("message_input").value;
socketio.emit("message_to_server", {message:msg});
}
function login() {
var user = $('#user').val();
}
</script>
</head>
<body>
<div id="loginModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- modal content-->
<div class="modal-content">
<div class="modal-body">
<form id = "loginForm" class="form-horizontal" role="form">
<div class="form-group">
<label class="control-label col-sm-2" for="user">Username:</label>
<div class="col-sm-10">
<input id="user" type="text" class="form-control" placeholder="Enter username" required>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button id="loginSubmit" type="submit" class="btn btn-default" data-dismiss="modal" onclick="login()">Start Chat!</button>
</div>
</div>
</div>
</div>
<div id="container" class="container-fluid">
<div id="main" class="row">
<div id="nav" class="full col-xs-3">
</div>
<div id="chatroom" class="full col-xs-9">
<div id="header" class="row">
Chat Room Name (temp)
</div>
<div id="chatlog" class="row">
</div>
<div id="message" class="row">
<input type=text" id="message_input"/>
<button onclick="sendMessage()">send</button>
</div>
</div>
</div>
</div>
</body>
</html>