Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

43 lines (38 sloc) 1.63 kb
<html>
<head>
<title>Chat using Beaconpush</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>
</head>
<body>
<style type="text/css">
* { font-family: Arial, Helvetica, sans-serif; }
input[type="text"] { font-size: 14px; border: 1px solid #777; padding: 5px; margin: 4px 0 8px 0; }
#messages { display: block; width: 500px; height: 300px; border: 1px solid #777; margin: 0; }
#message { width: 450px; }
#send { font-size: 24px; }
ul { margin-left: 0; padding: 4px; list-style-type: none; }
</style>
<h1>Chat using Beaconpush</h1>
Name <input id="name" type="text" value="Julia">
<ul id="messages">
<li>Welcome to this simple chat.<br>Enter your name above and send a chat message below.</li>
</ul>
<input id="message" type="text" placeholder="Enter a chat message">
<input id="send" type="button" value="Send">
<script type="text/javascript" src="http://beaconpush.com/1/client.js"></script>
<script type="text/javascript">
$(document).ready(function () {
Beacon.connect('<%= apiKey %>', ['chat'], {log: true});
Beacon.listen(function (message) {
$('#messages').append('<li>' + message.name + ': ' + message.text + '</li>');
});
var sendMessage = function () {
$.post('/messages', {name: $('#name').val(), text: $('#message').val()}, function (data) {}, 'json');
$('#message').val('');
};
$('#message').keyup(function (e) { if (e.keyCode == 13) sendMessage(); })
$('#send').click(sendMessage);
});
</script>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.