Skip to content
This repository
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 38 lines (32 sloc) 0.881 kb
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
<!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("");
  });
  
  $("#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 id="messages"></div>
<input type="text" id="text-input">
<input type="button" value="Send" id="send-button">
</body>
</html>
Something went wrong with that request. Please try again.