Skip to content

Instantly share code, notes, and snippets.

@swanson
Created November 6, 2010 04:20
Show Gist options
  • Select an option

  • Save swanson/665188 to your computer and use it in GitHub Desktop.

Select an option

Save swanson/665188 to your computer and use it in GitHub Desktop.
window.onload = function() {
var s = new io.Socket(null, {port: 3000});
s.connect();
s.on('message', function(data) {
if (data['type'] == 'add') {
$("#announcements").append(
'<div id=' + data['id'] +'>' + data['payload'] + '</div>'
);
}
else if (data['type'] == 'delete') {
var announcement = $('#' + data['id']);
alert(announcement.text());
announcement.remove();
//announcement.slideUp(300, function () {
// announcement.remove();
//});
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment