/*************************************************** TWIITER JAVASCRIPT CODE ***************************************************/ (function($) { $.fn.tweet = function(o){ var s = $.extend({ username: null, // [string or array] required unless using the 'query' option; one or more twitter screen names list: null, // [string] optional name of list belonging to username favorites: false, // [boolean] display the user's favorites instead of his tweets query: null, // [string] optional search query avatar_size: null, // [integer] height and width of avatar if displayed (48px max) count: 3, // [integer] how many tweets to display? fetch: null, // [integer] how many tweets to fetch via the API (set this higher than 'count' if using the 'filter' option) retweets: true, // [boolean] whether to fetch (official) retweets (not supported in all display modes) intro_text: null, // [string] do you want text BEFORE your your tweets? outro_text: null, // [string] do you want text AFTER your tweets? join_text: null, // [string] optional text in between date and tweet, try setting to "auto" auto_join_text_default: "i said,", // [string] auto text for non verb: "i said" bullocks auto_join_text_ed: "i", // [string] auto text for past tense: "i" surfed auto_join_text_ing: "i am", // [string] auto tense for present tense: "i was" surfing auto_join_text_reply: "i replied to", // [string] auto tense for replies: "i replied to" @someone "with" auto_join_text_url: "i was looking at", // [string] auto tense for urls: "i was looking at" http:... loading_text: null, // [string] optional loading text, displayed while tweets load refresh_interval: null , // [integer] optional number of seconds after which to reload tweets twitter_url: "twitter.com", // [string] custom twitter url, if any (apigee, etc.) twitter_api_url: "api.twitter.com", // [string] custom twitter api url, if any (apigee, etc.) twitter_search_url: "search.twitter.com", // [string] custom twitter search url, if any (apigee, etc.) template: "{avatar}{join}{text}{time}", // [string or function] template used to construct each tweet
'+s.intro_text+'
'; var outro = ''+s.outro_text+'
'; var loading = $(''+s.loading_text+'
'); if(s.username && typeof(s.username) == "string"){ s.username = [s.username]; } var expand_template = function(info) { if (typeof s.template === "string") { var result = s.template; for(var key in info) { var val = info[key]; result = result.replace(new RegExp('{'+key+'}','g'), val === null ? '' : val); } return result; } else return s.template(info); }; if (s.loading_text) $(widget).append(loading); $(widget).bind("load", function(){ $.getJSON(build_url(), function(data){ if (s.loading_text) loading.remove(); if (s.intro_text) list.before(intro); list.empty(); var tweets = $.map(data.results || data, function(item){ var join_text = s.join_text; // auto join text based on verb tense and content if (s.join_text == "auto") { if (item.text.match(/^(@([A-Za-z0-9-_]+)) .*/i)) { join_text = s.auto_join_text_reply; } else if (item.text.match(/(^\w+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+) .*/i)) { join_text = s.auto_join_text_url; } else if (item.text.match(/^((\w+ed)|just) .*/im)) { join_text = s.auto_join_text_ed; } else if (item.text.match(/^(\w*ing) .*/i)) { join_text = s.auto_join_text_ing; } else { join_text = s.auto_join_text_default; } } // Basic building blocks for constructing tweet