Skip to content

Instantly share code, notes, and snippets.

@jedmund
Created February 27, 2013 10:10
Show Gist options
  • Save jedmund/5046849 to your computer and use it in GitHub Desktop.
Save jedmund/5046849 to your computer and use it in GitHub Desktop.
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<script src="http://codeclasschat.herokuapp.com/helpers.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
$('#message').keyup(function(e) {
if (e.keyCode === 13) {
e.preventDefault();
e.stopPropagation();
helpers.sendMessage($.trim($(this).val()));
$(this).val("");
}
});
var message = "Hello Agatha!";
helpers.sendMessage(message);
setInterval(function() {
helpers.fetchNewMessages(function (messages) {
$.each(messages, function(i, m) {
helpers.renderMessage(m);
});
});
}, 1500);
});
</script>
</head>
<body>
<input type="text" id="message" placeholder="type your msg" />
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment