( function($) { var Twitter = function() { var defaults = { user :0, hashtag: false, id :0, total :10, hideSurround : false, rand:0, height: 0, textColor :"#000000", linkColor :"#000000", scrollbar :"#000000", target: "_blank" }, niceTime = function (time_value) { var values = time_value.split(" "); time_value = values[1] + " " + values[2] + ", " + values[5] + " " + values[3]; 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); if (delta < 60) { return 'less than a minute ago'; } else if(delta < 120) { return 'about a minute ago'; } else if(delta < (60*60)) { return (parseInt(delta / 60)).toString() + ' minutes ago'; } else if(delta < (120*60)) { return 'about an hour ago'; } else if(delta < (24*60*60)) { return 'about ' + (parseInt(delta / 3600)).toString() + ' hours ago'; } else if(delta < (48*60*60)) { return '1 day ago'; } else { return (parseInt(delta / 86400)).toString() + ' days ago'; } }, getRSS = function(ev) { var url = "/externalfeeds/json/type/twitter/total/"+defaults.total+"/username/"+defaults.user; //+"/callback/twitterCallback"+defaults.rand+"/"; var usr = defaults.user; if (defaults.hashtag) { url = "/externalfeeds/json/type/twitterhashtag/total/"+defaults.total+"/tag/"+escape(defaults.user); //+"/callback/twitterCallback"+defaults.rand+"/"; } var id = defaults.id; var color = defaults.textColor; var user = defaults.user; var link = defaults.linkColor; var height = defaults.height; var scrollbar = defaults.scrollbar; $.ajax({ url: url, success: function (twitters) { twitters = $.evalJSON(twitters); // alert (twitters.length); var target=""; if (defaults.target) { target="target=\""+defaults.target+"\""; } if (defaults.hashtag) { twitters = twitters.results; } if (!twitters[0]) return; if (defaults.hashtag) { var statusHTML = []; statusHTML.push('
'); var max = twitters.length; if (twitters.length>defaults.total) { max = defaults.total; } 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)+''; }); statusHTML.push(''); } } else { var avatar = twitters[0].user.profile_image_url; var twitterName = twitters[0].user.name; var statusHTML = []; if (!defaults.hideSurround) statusHTML.push('

'+twitterName+'

'+user+'

'); statusHTML.push('
'); 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)+''; }); statusHTML.push(''); } } if (!defaults.hideSurround) statusHTML.push('
'); $("#"+id).html(statusHTML.join('')); }, dataType: "string" }); }; return { init : function(opt) { defaults = $.extend( {}, defaults, opt || {}); getRSS(); } }; }(); $.fn.extend( { Twitter: Twitter.init, TwitterCallback: Twitter.callback }); document.write(""); })(jQuery)