-
Notifications
You must be signed in to change notification settings - Fork 2
/
chat.html
47 lines (42 loc) · 1.07 KB
/
chat.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
<html>
<head>
<title>nowjs test</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<script type="text/javascript" src="nowjs/now.js"></script>
<script>
$(function(){
now.name = prompt("What's your name?", "");
var name = now.name;
$("body").one("mouseover",function(){
now.distributeAlert();
});
now.peopleOnline = function(name){
addPeople(name);
};
now.receiveMessage = function(name, msg){
$("<div></div>").text(name + ": " + msg).appendTo("#msg");
};
$("#send-button").click(function(){
now.distributeMessage($("#text-input").val());
$("#text-input").val("");
});
});
</script>
</head>
<body>
First Name<input type="text" id="textName">
<br /><br /><br />
<input type="button" value="Enter Chat Room" id="enter">
<div id="msg"></div>
<input type="text" id="text-input">
<input type="button" value="Send" id="send-button">
<br /><br /><br />
<div id="online">People Online</div>
<script type="text/javascript">
function addPeople(person)
{
$("body").append("<br />"+person);
}
</script>
</body>
</html>