-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchatroom.html
69 lines (57 loc) · 1.96 KB
/
chatroom.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
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="ja" />
<meta http-equiv="X-UA-Compatible" content="chrome=1; IE=8; IE=edge" />
<title>Chat Room,Connecting</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="/socketiojs"></script>
<script type="text/javascript">
var User_Info={name:'Unknow'};
$(document).ready(function () {
var Message_Windows = $("#msg_wrap");
var socket = io.connect('https://home.thestargazer.net');
socket.on('connect', function () {
$(document).attr("title", "Chat Room,Connected");
socket.emit("Chat_New")
});
socket.on('Chat_Private', function (message) {
Message_Windows.prepend(new Date().toString() + '<span>' + message + '</span><br>');
});
socket.on('Chat_Public', function (message) {
Message_Windows.prepend(new Date().toString() + '<span>' + message + '</span><br>');
});
socket.on('Your Name',function(Name){
User_Info.name=Name;
$('#User_Name').text(Name);
});
socket.on('Chat_User_List',function(list){
$('#User_List_Wrap').text(list);
});
$("#sent").click(function () {
socket.emit("Chat_Public",User_Info.name, $("#msgbox").val());
})
})
</script>
<style type="text/css">
#User_List_Wrap{
float:right;
width: 300px;
}
#msg_wrap{
float:left;
width: 600px;
}
</style>
</head>
<body>
<div id="Info_Wrap">
<span id="User_Name">Unknow</span>
</div>
<input type="test" id="msgbox" style="width:200dx;"/><input type="button" id="sent" value="Send"/>
<div id="msg_wrap"></div>
<div id="User_List_Wrap"></div>
</body>
</html>