Last Updated: February 25, 2016
· idered

Load tweet from user and make links, hashtags, usernames active links

Here's the JS function to load specified number of tweets and parse first one:

 * Get latest tweets
 * @param  {string} username
 * @param  {int}    num      Number of tweets to get
function getTweets(username, num) {

    $.getJSON(""+username+".json?count="+num+"&include_rts=1&callback=?", function(tweets) {

} // getTweets

 * Change user names, hashtags and links to active links
 * @param  {string} text Just a tweet
 * @return {string}      Parsed tweet
function parseTweet(text) {

    var patterns = {
        link: /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig,
        user: /(^|\s)@(\w+)/g,
        hash: /(^|\s)#(\w+)/g
    return text
        .replace(,'<a href="$1" target="_blank">$1</a>')
        .replace(patterns.user, '$1@<a href="$2" target="_blank">$2</a>')
        .replace(patterns.hash, '$1#<a href="$2" target="_blank">$2</a>');

} // parseTweet

How to use it?

Create an html tag with js-get-tweet class and run this code:

getTweets('Idered', 1);

More useful code snippets here