/* ========================================================= * jquery.latestTweet.js v0.1 * Description: Return the latest tweet from a user * Project: https://github.com/manuelvanrijn/jquery-latestTweet * Author: Manuel van Rijn * Released under the MIT License. * ========================================================== */ (function(a,b,c,d){var e=function(b,c){this.elem=b,this.$elem=a(b),this.config=a.extend({},a.fn.latestTweet.defaults,c)};e.prototype={init:function(b){var c=this,d=c.getUrl(b);return a.getJSON(d,function(a){var b=c.formatTweet(a[0].text);c.$elem.html(b),c.config.callback.call(this)}),this},getUrl:function(a){var b="https:"==c.location.protocol?"https:":"http:";return b+"//api.twitter.com/1/statuses/user_timeline.json?screen_name="+a+"&count=1&callback=?"},formatTweet:function(a){var b=/((ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)/gi,c=/[\@]+([A-Za-z0-9-_]+)/gi,d=/[\#]+([A-Za-z0-9-_]+)/gi;return this.config.formatLinks&&(a=a.replace(b,'$1')),this.config.formatMentions&&(a=a.replace(c,'@$1')),this.config.formatHashes&&(a=a.replace(d,'#$1')),a}},a.fn.latestTweet=function(a,b){if(typeof a!="string")return;return this.each(function(){(new e(this,b)).init(a)})},a.fn.latestTweet.defaults={formatLinks:!0,formatMentions:!0,formatHashes:!0,callback:function(){}}})(jQuery,window,document)