///
/// Uses the parameters provided to retrieve the latest tweets, including retweets that were
/// created either with the original or new twitter process and outputs a number of items
/// to the control with the id provided
///
/// (string) Your twitter username
/// (int) The maximum number of tweets to return
/// (string) The id given to the
element that will contain the tweets.
///
function GetTwitterFeedIncRT(username, maxTweets, outputElementId, WidgetSidebar)
{
if (maxTweets == null) maxTweets = 10;
var url = 'http://twitter.com/statuses/user_timeline/'+username+'.atom?count='+maxTweets+'&include_rts=true&callback=?'
var gurl = "http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&callback=?&num="+maxTweets+"&q="+url;
var fnk = function(feeds)
{
var statusHTML = [];
for(var i=0; i]*[^.,;'">\:\s\<\>\)\]\!])/g,
function(url) { return ''+url+'';})
.replace(/\B@([_a-z0-9]+)/ig,
function(reply) { return reply.charAt(0)+''+reply.substring(1)+'';})
.replace(username + ': ',
function(clean) { return clean.substring(username.length + 3); });
var timeValues = entry.publishedDate.split(" ");
var time_value = timeValues[1] + " " + timeValues[2] + " " + timeValues[3] + ", " + timeValues[4];
var parsed_date = Date.parse(time_value);
var relative_to = (arguments.length > 1) ? arguments[1] : new Date();
var delta = parseInt((relative_to.getTime() - parsed_date) / 1000);
delta = delta + (relative_to.getTimezoneOffset() * 60);
var relativeTime = '';
if (delta < 60) {
relativeTime = 'less than a minute ago';
} else if(delta < 120) {
relativeTime = 'about a minute ago';
} else if(delta < (60*60)) {
relativeTime = (parseInt(delta / 60)).toString() + ' minutes ago';
} else if(delta < (120*60)) {
relativeTime = 'about an hour ago';
} else if(delta < (24*60*60)) {
relativeTime = 'about ' + (parseInt(delta / 3600)).toString() + ' hours ago';
} else if(delta < (48*60*60)) {
relativeTime = '1 day ago';
} else {
relativeTime = (parseInt(delta / 86400)).toString() + ' days ago';
}
if (WidgetSidebar == 1)
statusHTML.push('- '+status+'
');
else {
statusHTML.push('- ' +
'' + status + '' +
' ' +
relativeTime +
'' +
'
');
}
}
document.getElementById(outputElementId).innerHTML = statusHTML.join('');
};
$.getJSON(gurl,
function(data)
{
if(typeof fnk == 'function')
fnk.call(this, data.responseData.feed);
else
return false;
});
}