Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 46 lines (38 sloc) 0.923 kb
<html>
<head>
<title>nowjs test</title>
<script src="/nowjs/now.js"></script>
<script type="text/javascript" src="/jquery.min.js"></script>
<script>
function talk() {
now.distributeMessage($('#text-input').val());
$("#text-input").val("");
}
$(document).ready(function(){
now.name = prompt("What's your name?", "");
now.receiveMessage = function(name, message){
addMessage(name+" : "+ message);
}
now.loginNotice = function(name) {
addMessage(name+" joined the chat...");
}
var addMessage = function(message) {
$("#messages").append('<br>'+message);
}
$("#send-button").click(function(){
talk();
});
$(window).keypress(function(e) {
if(e.keyCode == 13) {
talk();
}
});
});
</script>
</head>
<body>
<div id="messages"></div>
<input type="text" id="text-input" style="width: 400px;">
<input type="button" value="Send" id="send-button">
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.