﻿(function($) { $.fn.getTweets = function(options) { var feed = $.extend({}, $.fn.getTweets.defaults, options); $(this).hide(); var id = $(this).attr("id"); var inner = $('<div id="' + id + '_inner" class="inner"></div>'); var hd = $('<div class="hd"></div>'); var bd = $('<div class="bd"></div>'); var lst = $('<ul id="' + id + '_list"></ul>'); $(this).append(inner); $(inner).append(hd); if (feed.showHeading) { $(hd).append('<h2>' + feed.headingText + '</h2>'); } $(inner).append(bd); $(bd).append(lst); $(lst).hide(); var preloader = $('<p class="' + feed.preloaderClass + '">' + feed.preloaderText + '</p>'); $(bd).append(preloader); var footer = $('<div class="ft"></div>'); $(inner).append(footer); if (feed.showProfileLink) { $(footer).append('<a href="http://twitter.com/' + feed.username + '" target="_blank">http://twitter.com/' + feed.username + '</a>'); } $(this).show(); $.getJSON("http://twitter.com/statuses/user_timeline/" + feed.username + ".json?callback=?&count=" + feed.numTweets, function(result) { $(result).each(function(i) { appendTweet(result[i], lst); SI_clearFooter(); }); $(preloader).remove(); if (feed.animate) { $(lst).slideDown(1000); SI_clearFooter(); } else { $(lst).show(); SI_clearFooter(); } $("#" + id + "_list li:first").addClass("first-child"); $("#" + id + "_list li:last").addClass("last-child"); }); }; $.fn.getTweets.defaults = { username: null, numTweets: 5, preloaderClass: "preloader", preloaderText: "Loading...", animate: false, showHeading: true, headingText: "Latest Tweets", showProfileLink: true }; function appendTweet(tweet, lst) { $(lst).append('<li>' + tweet.text.replace(/((https?|s?ftp|ssh)\:\/\/[^"\s\<\>]*[^.,;'">\:\s\<\>\)\]\!])/g, function(F) { return '<a href="' + F + '" target="_blank">' + F + "</a>" }).replace(/\B@([_a-z0-9]+)/ig, function(F) { return F.charAt(0) + '<a href="http://www.twitter.com/' + F.substring(1) + '" target="_blank">' + F.substring(1) + "</a>" }) + '<span class="tweet_date">' + formatTime(tweet.created_at) + '</span></li>'); }; function formatTime(C) { var B = C.split(" "); C = B[1] + " " + B[2] + ", " + B[5] + " " + B[3]; var A = Date.parse(C); var D = (arguments.length > 1) ? arguments[1] : new Date(); var E = parseInt((D.getTime() - A) / 1000); E = E + (D.getTimezoneOffset() * 60); if (E < 60) { return "less than a minute ago" } else { if (E < 120) { return "about a minute ago" } else { if (E < (60 * 60)) { return (parseInt(E / 60)).toString() + " minutes ago" } else { if (E < (120 * 60)) { return "about an hour ago" } else { if (E < (24 * 60 * 60)) { return "about " + (parseInt(E / 3600)).toString() + " hours ago" } else { if (E < (48 * 60 * 60)) { return "1 day ago" } else { return (parseInt(E / 86400)).toString() + " days ago" } } } } } } }; })(jQuery);

// Required by the Microsoft Ajax Framework:
if ((typeof Sys !== "undefined") && (typeof Sys.Application !== "undefined")) {
    Sys.Application.notifyScriptLoaded();
}