Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
33 lines (26 sloc) 792 Bytes
<h2>Chat Window</h2>
<div id="messages"></div>
<div style="position: absolute; bottom: 25;">
<input type="text" id="text-input">
<input type="button" value="Send" id="send-button">
</div>
<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").focus();
});
$("#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>
Something went wrong with that request. Please try again.