Skip to content

Instantly share code, notes, and snippets.

@jmather
Created May 7, 2011 01:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmather/960119 to your computer and use it in GitHub Desktop.
Save jmather/960119 to your computer and use it in GitHub Desktop.
$script = "
<script type=\"text/javascript\">
(function() {
var id = '$id';
var augment_id = id+'_messages';
var url = '$splitter_url';
var callUpdateTimeout = null;
var updateFunction = function() {
if (callUpdateTimeout != null)
clearTimeout(callUpdateTimeout);
callUpdateTimeout = setTimeout(callUpdateFunction, 500);
};
var callUpdateFunction = function(messages) {
alert(''+messages); return;
var ul = $('<ul></ul>');
for (var i in messages)
{
a.append($('<li>'+messages[i]+'</li>'));
}
$('#'+augment_id).html('');
$('#'+augment_id).append(a);
};
var onUpdateFunction = function() {
var message = $('#'+id).val();
$.post(url, {message: message}, updateFunction, 'text');
};
$('#'+id).keypress(onUpdateFunction);
})();
</script>
";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment