Skip to content

Instantly share code, notes, and snippets.

@mdarby
Created August 17, 2010 23:23
Show Gist options
  • Save mdarby/532587 to your computer and use it in GitHub Desktop.
Save mdarby/532587 to your computer and use it in GitHub Desktop.
function showTweets(){
var target = $("#twitter");
var url = "http://twitter.com/statuses/user_timeline/USERNAME.json?callback=?&count=5"
var tweets = new Array();
target.html("Loading Tweets...");
$.getJSON(url, function(data) {
target.html("");
for(var i = 0; i < data.length; i++) {
var str = "<li style=\"display:none;\">" + autoLink(data[i].text) + "</li>";
target.append(str);
}
$("#twitter li").each(function(){
$(this).show("blind");
});
});
}
function autoLink(text){
return text.replace(/(http:\/\/[\w\.\/]+)/, "<a href=\"$1\" target=\"blank\">$1</a>");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment