Created
December 27, 2009 23:45
-
-
Save rubenfonseca/264454 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function(){ | |
if(!("WebSocket" in window)) { | |
alert("Sorry, the build of your browser does not support WebSockets. Please use latest Chrome or Webkit nightly"); | |
return; | |
} | |
ws = new WebSocket("ws://localhost:8080/"); | |
ws.onmessage = function(evt) { | |
data = eval("(" + evt.data + ")"); | |
var p = $("<div class='tweet' style='display:none'><div class='content'><a class='main-screenname' href='http://www.twitter.com/" + data.user.screen_name + "/status/" + data.id + "' target='_blank'>" + data.user.screen_name + "</a> " + data.text + "</div></div>"); | |
if($('#tweets div.tweet').size() > 15) { | |
$('#tweets div.tweet:last').slideDown(100, function() { | |
$(this).remove(); | |
}); | |
} | |
$('#tweets').prepend(p); | |
p.slideDown(140); | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
yes you are totally right, thank you!