Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

40 lines (34 sloc) 0.964 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.name = prompt("What's your name?", "");
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());
});
});
</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.