Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

49 lines (41 sloc) 1.131 kB
<!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());
});
$("#text-input").keypress(function (e) {
if (e.which && e.which === 13) {
$("#send-button").click();
return false;
}
});
now.name = prompt("What's your name?", "");
$("#text-input").focus();
});
</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>
Jump to Line
Something went wrong with that request. Please try again.