PageSourceSearch

https://global-deployment.com/templates/corpoboost/js/jtwt.js

js global-deployment.com collected 2026-10-07 14:33:35 UTC 5,164 bytes, 154 lines download raw bytes

1//jtwt.js by Harbor (http://jtwt.hrbor.com)
2
3(function($){
4
5 	$.fn.extend({ 
6 		
7		//pass the options variable to the function
8 		jtwt: function(options) {
9
10
11			//Set the default values, use comma to separate the settings, example:
12			var defaults = {
13				username : 'harborco',
14                count : 4,
15                image_size: 48,
16                convert_links: 1,
17                loader_text: 'loading new tweets'
18			}
19				
20			var options =  $.extend(defaults, options);
21
22    		return this.each(function() {
23				var o = options;
24                var obj = $(this);  
25                
26			$(obj).append('<ul id="jtwt"></ul>');	
27			$("#jtwt", obj).append('<li id="jtwt_loader" style="display:none;">' + o.loader_text + '</li>');	
28			$("#jtwt_loader").fadeIn('slow');
29
30			// Modified version of the prettyDate() function. Thanks to http://webdesign.onyou.ch/2010/08/04/javascript-time-ago-pretty-date/
31
32			function prettyDate(date_str){
33
34				date_str = date_str.replace(/\+[0-9]{4}/, "");
35				date_str = date_str.substr(4);
36	
37				var month = new Array();
38				month["Jan"] = "1";
39				month["Feb"] = "2";
40				month["Mar"] = "3";
41				month["Apr"] = "4";
42				month["May"] = "5";
43				month["Jun"] = "6";
44				month["Jul"] = "7";
45				month["Aug"] = "8";
46				month["Sep"] = "9";
47				month["Oct"] = "10";
48				month["Nov"] = "11";
49				month["Dec"] = "12";
50	
51				var date_str_split = date_str.split(" ");
52				date_str = date_str_split[4];
53				
54				date_str = date_str_split[4] + "-" + month[date_str_split[0]] + "-" + date_str_split[1] + "T" + date_str_split[2] + "Z";
55
56				var time_formats = [
57				[120, '1 minute ago', '1 minute from now'], // 60*2
58				[3600, 'minutes', 60], // 60*60, 60
59				[7200, '1 hour ago', '1 hour from now'], // 60*60*2
60				[86400, 'hours', 3600], // 60*60*24, 60*60
61				[604800, 'days', 86400], // 60*60*24*7, 60*60*24
62				[2419200, 'weeks', 604800], // 60*60*24*7*4, 60*60*24*7
63				[29030400, 'months', 2419200], // 60*60*24*7*4*12, 60*60*24*7*4
64				[58060800, 'last year', 'next year'], // 60*60*24*7*4*12*2
65				[2903040000, 'years', 29030400], // 60*60*24*7*4*12*100, 60*60*24*7*4*12
66				[5806080000, 'last century', 'next century'], // 60*60*24*7*4*12*100*2
67				[58060800000, 'centuries', 2903040000] // 60*60*24*7*4*12*100*20, 60*60*24*7*4*12*100
68				];
69				var time = ('' + date_str).replace(/-/g,"/").replace(/[TZ]/g," ").replace(/^\s\s*/, '').replace(/\s\s*$/, '');
70				if(time.substr(time.length-4,1)==".") time =time.substr(0,time.length-4);
71				var seconds = (new Date - new Date(time)) / 1000;
72				var token = 'ago', list_choice = 1;
73				if (seconds < 0) {
74					seconds = Math.abs(seconds);
75					token = 'from now';
76					list_choice = 2;
77				}
78				var i = 0, format;
79				while (format = time_formats[i++]) 
80					if (seconds < format[0]) {
81						if (typeof format[2] == 'string')
82							return format[list_choice];
83						else
84							return Math.floor(seconds / format[2]) + ' ' + format[1] + ' ' + token;
85					}
86				return time;
87			};
88	
89			$.getJSON('http://api.twitter.com/1/statuses/user_timeline/' + o.username + '.json?count=' + o.count + '&callback=?', function(data){ 
90
91			$.each(data, function(i, item) {       
92            
93                jtweet = '<li class="jtwt_tweet row-fluid">';
94                
95                
96                
97                if (o.image_size != 0) {
98                
99                today = new Date();
100  
101                jtweet += '<div class="jtwt_picture span1">';
102                jtweet += '<a href="http://twitter.com/' + item.user['screen_name'] + '">'
103                jtweet += '<img width="' + o.image_size +'" height="' + o.image_size + '" src="' + item.user['profile_image_url'] + '" />';
104                jtweet += '</a><br />';
105                jtweet += '</div>';
106
107                } 
108                
109                
110               
111                var tweettext = item.text;
112                var tweetdate = prettyDate(item.created_at);
113                
114                if (o.convert_links != 0) {
115                
116
117  
118                tweettext = tweettext.replace(/(http\:\/\/[A-Za-z0-9\/\.\?\=\-]*)/g,'<a href="$1">$1</a>');
119                tweettext = tweettext.replace(/@([A-Za-z0-9\/_]*)/g,'<a href="http://twitter.com/$1">@$1</a>');
120                tweettext = tweettext.replace(/#([A-Za-z0-9\/\.]*)/g,'<a href="http://twitter.com/search?q=$1">#$1</a>');
121                
122                }
123
124
125                jtweet += '<p class="jtwt_tweet_text span11">';
126                jtweet += tweettext;
127				jtweet += '</p>';
128               
129                jtweet += '<a href="http://twitter.com/' + item.user['screen_name'] + '/statuses/' + item.id + '" class="jtwt_date">';
130                
131                jtweet += tweetdate;
132                jtweet += '</a>';
133 
134                jtweet += '</li>';   				
135                
136                $("#jtwt", obj).append(jtweet);
137        
138    
139
140
141          		 });   
142                 
143
144			$("#jtwt_loader").fadeOut('fast');   
145           
146		});
147    
148    
149			
150    		});
151    	}
152	});
153	
154})(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.