Skip to content

Instantly share code, notes, and snippets.

@brendanfalkowski
Created May 4, 2011 03:59
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 brendanfalkowski/954731 to your computer and use it in GitHub Desktop.
Save brendanfalkowski/954731 to your computer and use it in GitHub Desktop.
Gets the most recent tweet and adds links
/* for Twitter JSON request */
function linkify (text) {
var exp = /(\b(https?|mailto):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
return text.replace(exp,"<a href='$1'>$1</a>");
}
/* jQuery start */
$(document).ready(function(){
$.getJSON('http://twitter.com/status/user_timeline/falkowski.json?count=1&callback=?', function(data) {
$('#twitter').html(linkify(data[0].text));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment