-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmultiroomchat.html
77 lines (63 loc) · 1.81 KB
/
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
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
<!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(message){
$("#messages").append("<br>" + message);
};
now.receiveEquation = function(equationInfo) {
$('#messages').append("<br> NEW equation info!!" + JSON.stringify(equationInfo));
};
now.receiveTotal = function(totalCount) {
$('#messages').append("<br> NEW total is " + String(totalCount));
now.totalCount = totalCount;
};
$("#send-button").click(function(){
now.distributeMessage($("#text-input").val());
$("#text-input").val("");
});
$("#text-input").keypress(function (e) {
if (e.which && e.which === 13) {
$("#send-button").click();
return false;
}
});
$('#make-button').click(function() {
var roomName = $('#room-name').val();
if(!roomName || roomName.length == 0)
{
alert("Specify a room name!");
return;
}
now.makeRoom(roomName,{
equation:'x + y + z',
fixAllBut2:true
});
});
$('#change-button').click(function() {
var roomName = $('#room-name').val();
if(!roomName || roomName.length == 0)
{
alert("specify a room name!");
return;
}
now.changeRoom(roomName);
});
$("#text-input").focus();
});
</script>
</head>
<body>
<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">
<input type="button" value="Change room" id="change-button">
<input type="button" value="Make Room" id="make-button">
<input type="text" id="room-name">
</body>
</html>