1/* 2 * TweetScroll jQuery Plugin 3 * Author: Pixel Industry 4 * Author URL : http://pixel-industry.com 5 * Version: 1.2 6 * 7 * jQuery plugin to load latest Twitter tweets. 8 * 9 */ 10 11(function ($) { 12 //define the tweetable plugin 13 $.fn.tweetscroll = function (options) { 14 //specify the plugins defauls 15 var defaults = { 16 visible_tweets: 10, //number of tweets to be visible 17 username: 'thinkupthemes', //@username tweets to display. can be multiple usernames e.g. [philipbeel, vmrkela] 18 time: false, //display date 19 replies: false, //filter out @replys 20 date_format: 'style1', 21 color: 'blue', 22 }; 23 //overwrite the defaults 24 var tweetscrollOptions = $.extend({}, defaults, options); 25 26 // Wordpress widget change 27 tweetscrollOptions['instance_id'] = $(this).attr('data-instance-id'); 28 if(!tweetscrollOptions['instance_id']) 29 tweetscrollOptions['instance_id'] = ""; 30 tweetscrollOptions['action'] = 'thinkup_widget_tweetscroll_ajax'; 31 32 //loop through each instance 33 return this.each(function (options) { 34 //assign our initial vars 35 var act = $(this); 36 var $allTweets; 37 38 // Wordpress widget change 39 var requestURL = PiTweetScroll.ajaxrequests; 40 41 //do a JSON request to twitters API 42 if(jQuery.isArray(tweetscrollOptions.username)){ 43 var numOfUsers = tweetscrollOptions.username.length; 44 var tweetsCount, $tweetList; 45 var restTweets = (tweetscrollOptions.visible_tweets
45- (Math.floor(tweetscrollOptions.visible_tweets / numOfUsers) * numOfUsers)); 46 var tweetsPerUser = Math.floor(tweetscrollOptions.visible_tweets / numOfUsers); 47 $allTweets = $('<ul class="tweet-feed">'); 48 49 jQuery.each(tweetscrollOptions.username, function(index, val){ 50 51 if(restTweets > 0){ 52 tweetsCount = tweetsPerUser + 1; 53 restTweets--; 54 } 55 else{ 56 tweetsCount = tweetsPerUser; 57 } 58 59 $.getJSON(requestURL, tweetscrollOptions, function (data) { 60 $tweetList = createHtml(data, tweetscrollOptions); 61 62 $tweetList.find('li').appendTo($allTweets); 63 if(index == numOfUsers - 1 ){ 64 $($allTweets).appendTo(act); 65 setInitialListHeight($allTweets); 66 /*setInterval(function(){ 67 animateTweets($allTweets); 68 }, 3000);*/ 69 } 70 }); 71 72 }); 73 74 }else{ 75 76 $.getJSON(requestURL, tweetscrollOptions, function (data) { 77 $allTweets = createHtml(data, tweetscrollOptions); 78 $($allTweets).appendTo(act); 79 setInitialListHeight($allTweets); 80 /*setInterval(function(){ 81 animateTweets($allTweets); 82 }, 3000);*/ 83 }); 84 } 85 86 87 88 function setInitialListHeight($allTweets){ 89 var containerSize = 0; 90 91 } 92 93 }); 94 95 function createHtml(data, tweetscrollOptions){ 96 var $tweetList; 97 var tweetMonth = ''; 98 var shortMonths = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]; 99 var allMonths = ["January","February","March","April","May","June","July","August","Septemper","October","November","December"]; 100 101 $.each(data, function (i, item) { 102 103 //check for the first loop 104 if(i == 0){ 105 $tweetList = $('<ul class="tweet-feed ' + tweetscrollOptions.color + '">'); 106 } 107 108 109 110 //handle @reply and #tag filtering if required 111 if (tweetscrollOptions.replies === false) { 112 if (item.in_reply_to_status_id === null) { 113 $tweetList.append('<li class="tweet-content"><p class="twitter-tweet-' + i + '">' + item.text.replace(/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig, '<a href="$&" target="_blank" >$&</a> ').replace(/#(.*?)(\s|$)/g, '<a href="http://twitter.com/search?q=%23$1&src=hash" target="_blank" >#$1 </a>').replace(/@(.*?)(\s|\(|\)|$)/g, '<a href="http://twitter.com/$1" target="_blank" >@$1 </a>$2')+'</p></li>'); 114 } 115 } else { 116 $tweetList.append('<li class="tweet-content"><p class="twitter-tweet-' + i + '">' + item.text.replace(/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig, '<a href="$&" target="_blank" >$&</a> ').replace(/#(.*?)(\s|$)/g, '<a href="http://twitter.com/search?q=%23$1&src=hash" target="_blank" >#$1 </a>').replace(/@(.*?)(\s|\(|\)|$)/g, '<a href="http://twitter.com/$1" target="_blank" >@$1 </a>$2') + '</p></li>'); 117 } 118 119 //display the tiem of tweet if required 120 if (tweetscrollOptions.time == true) { 121 var monthIndex = jQuery.inArray(item.created_at.substr(4, 3), shortMonths); 122 123 if(tweetscrollOptions.date_format == 'style1'){ 124 tweetMonth = monthIndex + 1; 125 if(tweetMonth < 10) { 126 tweetMonth = '0' + tweetMonth; 127 } 128 $tweetList.find('.twitter-tweet-' + i).append('<small> ' + item.created_at.substr(8, 2) + '/' + tweetMonth + '/' + item.created_at.substr(26,4) + '</small>'); 129 }else{ 130 131 tweetMonth = allMonths[monthIndex]; 132 $tweetList.find('.twitter-tweet-' + i).append('<small> ' + tweetMonth + ' ' + item.created_at.substr(8, 2) + ' ' + item.created_at.substr(26,4) + '</small>'); 133 } 134 135 } 136 137 }); 138 return $tweetList; 139 } 140 } 141})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.