﻿$(document).ready(function() {
    var twitter_user    = 'camarazaragoza'

    $.getJSON(
        'http://search.twitter.com/search.json?callback=?&rpp=2&q=from:' + twitter_user,
        function(data) {
            $.each(data.results, function(i, tweet) {
        
                if(tweet.text !== undefined) {
				
                var tweet_html;
                tweet_html    = '<ul>'
                //Agregamos el texto
                tweet_html    += '<li>' + tweet.text.linkify() + '</li>';
                tweet_html    += '<\/ul>';
								
                //Añadimos el texto al contenedor que tenemos
                $('.tweets').append(tweet_html);
                }
            });
        }
    );
});

String.prototype.linkify = function() {
	return this.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+/, function(m) {
		return m.link(m);
	});
}; 

