forked from Flotype/now
-
Notifications
You must be signed in to change notification settings - Fork 0
/
multiroomchat.html
41 lines (34 loc) · 949 Bytes
/
multiroomchat.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
<!DOCTYPE html>
<html lang="en">
<head>
<title>nowjs test</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script src="/nowjs/now.js"></script>
<script>
$(document).ready(function(){
now.receiveMessage = function(name, message){
$("#messages").append("<br>" + name + ": " + message);
}
$("#send-button").click(function(){
now.distributeMessage($("#text-input").val());
$("#text-input").val("");
});
$(".change").click(function(){
now.changeRoom($(this).text());
});
now.name = prompt("What's your name?", "");
});
</script>
</head>
<body>
<div>
<a href="#" class="change selected">room 1</a> -
<a href="#" class="change">room 2</a> -
<a href="#" class="change">room 3</a>
</div>
<br>
<div id="messages"><br>You're in room 1</div>
<input type="text" id="text-input">
<input type="button" value="Send" id="send-button">
</body>
</html>