PageSourceSearch

https://fueradecontexto.mx/wp-content/themes/More/widgets/js/jquery.tweet_ver-4.7.13.js

js fueradecontexto.mx collected 2026-10-05 02:10:13 UTC 12,016 bytes, 233 lines download raw bytes

1(function($) {
2
3	/* Modified version to trigger a caallback function when done loading
4	https://github.com/ahmednuaman/tweet/commit/af9a64f1e0bda03e2847ddac8a4bb38f859d395c
5	 */
6
7  $.fn.tweet = function(o){
8    var s = $.extend({
9      username: ["seaofclouds"],                // [string]   required, unless you want to display our tweets. :) it can be an array, just do ["username1","username2","etc"]
10      list: null,                               // [string]   optional name of list belonging to username
11      favorites: false,                         // [boolean]  display the user's favorites instead of his tweets
12      avatar_size: null,                        // [integer]  height and width of avatar if displayed (48px max)
13      count: 3,                                 // [integer]  how many tweets to display?
14      fetch: null,                              // [integer]  how many tweets to fetch via the API (set this higher than 'count' if using the 'filter' option)
15      intro_text: null,                         // [string]   do you want text BEFORE your your tweets?
16      outro_text: null,                         // [string]   do you want text AFTER your tweets?
17      join_text:  null,                         // [string]   optional text in between date and tweet, try setting to "auto"
18      auto_join_text_default: "i said,",        // [string]   auto text for non verb: "i said" bullocks
19      auto_join_text_ed: "i",                   // [string]   auto text for past tense: "i" surfed
20      auto_join_text_ing: "i am",               // [string]   auto tense for present tense: "i was" surfing
21      auto_join_text_reply: "i replied to",     // [string]   auto tense for replies: "i replied to" @someone "with"
22      auto_join_text_url: "i was looking at",   // [string]   auto tense for urls: "i was looking at" http:...
23      loading_text: null,                       // [string]   optional loading text, displayed while tweets load
24      query: null,                              // [string]   optional search query
25      callback: null,                 // [function] optional callback fired when the data has loaded
26      refresh_interval: null ,                  // [integer]  optional number of seconds after which to reload tweets
27      twitter_url: "twitter.com",               // [string]   custom twitter url, if any (apigee, etc.)
28      twitter_api_url: "api.twitter.com",       // [string]   custom twitter api url, if any (apigee, etc.)
29      twitter_search_url: "search.twitter.com", // [string]   custom twitter search url, if any (apigee, etc.)
30      template: function(info) {                // [function] template used to construct each tweet <li>
31        return info["avatar"] + info["time"] + info["join"] + info["text"];
32      },
33      comparator: function(tweet1, tweet2) {    // [function] comparator used to sort tweets (see Array.sort)
34        return tweet2["tweet_time"] - tweet1["tweet_time"];
35      },
36      filter: function(tweet) {                 // [function] whether or not to include a particular tweet (be sure to also set 'fetch')
37        return true;
38      }
39    }, o);
40
41    $.fn.extend({
42      linkUrl: function() {
43        var returning = [];
44        // See http://daringfireball.net/2010/07/improved_regex_for_matching_urls
45        var regexp = /\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/gi;
46        this.each(function() {
47          returning.push(this.replace(regexp,
48                                      function(match) {
49                                        var url = (/^[a-z]+:/i).test(match) ? match : "http://"+match;
50                                        return "<a href=\""+url+"\">"+match+"</a>";
51                                      }));
52        });
53        return $(returning);
54      },
55      linkUser: function() {
56        var returning = [];
57        var regexp = /[\@]+([A-Za-z0-9-_]+)/gi;
58        this.each(function() {
59          returning.push(this.replace(regexp,"<a href=\"http://"+s.twitter_url+"/$1\">@$1</a>"));        });
60        return $(returning);
61      },
62      linkHash: function() {
63        var returning = [];
64        var regexp = /(?:^| )[\#]+([A-Za-z0-9-_]+)/gi;
65        this.each(function() {
66          returning.push(this.replace(regexp, ' <a href="http://'+s.twitter_search_url+'/search?q=&tag=$1&lang=all&from='+s.username.join("%2BOR%2B")+'">#$1</a>'));
67        });
68        return $(returning);
69      },
70      capAwesome: function() {
71        var returning = [];
72        this.each(function() {
73          returning.push(this.replace(/\b(awesome)\b/gi, '<span class="awesome">$1</span>'));
74        });
75        return $(returning);
76      },
77      capEpic: function() {
78        var returning = [];
79        this.each(function() {
80          returning.push(this.replace(/\b(epic)\b/gi, '<span class="epic">$1</span>'));
81        });
82        return $(returning);
83      },
84      makeHeart: function() {
85        var returning = [];
86        this.each(function() {
87          returning.push(this.replace(/(&lt;)+[3]/gi, "<tt class='heart'>&#x2665;</tt>"));
88        });
89        return $(returning);
90      }
91    });
92
93    function parse_date(date_str) {
94      // The non-search twitter APIs return inconsistently-formatted dates, which Date.parse
95      // cannot handle in IE. We therefore perform the following transformation:
96      // "Wed Apr 29 08:53:31 +0000 2009" => "Wed, Apr 29 2009 08:53:31 +0000"
97      return Date.parse(date_str.replace(/^([a-z]{3})( [a-z]{3} \d\d?)(.*)( \d{4})$/i, '$1,$2$4$3'));
98    }
99
100    function relative_time(date) {
101      var relative_to = (arguments.length > 1) ? arguments[1] : new Date();
102      var delta = parseInt((relative_to.getTime() - date) / 1000, 10);
103      var r = '';
104      if (delta < 60) {
105        r = delta + ' seconds ago';
106      } else if(delta < 120) {
107        r = 'a minute ago';
108      } else if(delta < (45*60)) {
109        r = (parseInt(delta / 60, 10)).toString() + ' minutes ago';
110      } else if(delta < (2*60*60)) {
111        r = 'an hour ago';
112      } else if(delta < (24*60*60)) {
113        r = '' + (parseInt(delta / 3600, 10)).toString() + ' hours ago';
114      } else if(delta < (48*60*60)) {
115        r = 'a day ago';
116      } else {
117        r = (parseInt(delta / 86400, 10)).toString() + ' days ago';
118      }
119      return 'about ' + r;
120    }
121
122    function build_url() {
123      var proto = ('https:' == document.location.protocol ? 'https:' : 'http:');
124      var count = (s.fetch === null) ? s.count : s.fetch;
125      if (s.list) {
126        return proto+"//"+s.twitter_api_url+"/1/"+s.username[0]+"/lists/"+s.list+"/statuses.json?per_page="+count+"&callback=?";
127      } else if (s.favorites) {
128        return proto+"//"+s.twitter_api_url+"/favorites/"+s.username[0]+".json?count="+s.count+"&callback=?";
129      } else if (s.query === null && s.username.length == 1) {
130        return proto+'//'+s.twitter_api_url+'/1/statuses/user_timeline.json?screen_name='+s.username[0]+'&count='+count+'&include_rts=1&callback=?';
131      } else {
132        var query = (s.query || 'from:'+s.username.join(' OR from:'));
133        return proto+'//'+s.twitter_search_url+'/search.json?&q='+encodeURIComponent(query)+'&rpp='+count+'&c
133allback=?';
134      }
135    }
136
137    return this.each(function(i, widget){
138      var list = $('<ul class="tweet_list">').appendTo(widget);
139      var intro = '<p class="tweet_intro">'+s.intro_text+'</p>';
140      var outro = '<p class="tweet_outro">'+s.outro_text+'</p>';
141      var loading = $('<p class="loading">'+s.loading_text+'</p>');
142
143      if(typeof(s.username) == "string"){
144        s.username = [s.username];
145      }
146
147      if (s.loading_text) $(widget).append(loading);
148      $(widget).bind("load", function(){
149        $.getJSON(build_url(), function(data){
150          if (s.loading_text) loading.remove();
151          if (s.intro_text) list.before(intro);
152          list.empty();
153
154          var tweets = $.map(data.results || data, function(item){
155            var join_text = s.join_text;
156
157            // auto join text based on verb tense and content
158            if (s.join_text == "auto") {
159              if (item.text.match(/^(@([A-Za-z0-9-_]+)) .*/i)) {
160                join_text = s.auto_join_text_reply;
161              } else if (item.text.match(/(^\w+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+) .*/i)) {
162                join_text = s.auto_join_text_url;
163              } else if (item.text.match(/^((\w+ed)|just) .*/im)) {
164                join_text = s.auto_join_text_ed;
165              } else if (item.text.match(/^(\w*ing) .*/i)) {
166                join_text = s.auto_join_text_ing;
167              } else {
168                join_text = s.auto_join_text_default;
169              }
170            }
171
172            // Basic building blocks for constructing tweet <li> using a template
173            var screen_name = item.from_user || item.user.screen_name;
174            var source = item.source;
175            var user_url = "http://"+s.twitter_url+"/"+screen_name;
176            var avatar_size = s.avatar_size;
177            var avatar_url = item.profile_image_url || item.user.profile_image_url;
178            var tweet_url = "http://"+s.twitter_url+"/"+screen_name+"/statuses/"+item.id_str;
179            var tweet_time = parse_date(item.created_at);
180            var tweet_relative_time = relative_time(tweet_time);
181            var tweet_raw_text = item.text;
182            var tweet_text = $([tweet_raw_text]).linkUrl().linkUser().linkHash()[0];
183
184            // Default spans, and pre-formatted blocks for common layouts
185            var user = '<a class="tweet_user" href="'+user_url+'">'+screen_name+'</a>';
186            var join = ((s.join_text) ? ('<span class="tweet_join"> '+join_text+' </span>') : ' ');
187            var avatar = (avatar_size ?
188                          ('<a class="tweet_avatar" href="'+user_url+'"><img src="'+avatar_url+
189                           '" height="'+avatar_size+'" width="'+avatar_size+
190                           '" alt="'+screen_name+'\'s avatar" title="'+screen_name+'\'s avatar" border="0"/></a>') : '');
191            var time = '<span class="tweet_time"><a href="'+tweet_url+'" title="view tweet on twitter">'+tweet_relative_time+'</a></span>';
192            var text = '<span class="tweet_text">'+$([tweet_text]).makeHeart().capAwesome().capEpic()[0]+ '</span>';
193
194            return { item: item, // For advanced users who want to dig out other info
195                     screen_name: screen_name,
196                     user_url: user_url,
197                     avatar_size: avatar_size,
198                     avatar_url: avatar_url,
199                     source: source,
200                     tweet_url: tweet_url,
201                     tweet_time: tweet_time,
202                     tweet_relative_time: tweet_relative_time,
203                     tweet_raw_text: tweet_raw_text,
204                     tweet_text: tweet_text,
205                     user: user,
206                     join: join,
207                     avatar: avatar,
208                     time: time,
209                     text: text
210                   };
211          });
212
213          tweets = $.grep(tweets, s.filter).slice(0, s.count);
214          list.append($.map(tweets.sort(s.comparator),
215                            function(t) { return "<li>" + s.template(t) + "</li>"; }).join('')).
216              children('li:first').addClass('tweet_first').end().
217              children('li:odd').addClass('tweet_even').end().
218              children('li:even').addClass('tweet_odd');
219
220          if (s.outro_text) list.after(outro);
221          $(widget).trigger("loaded").trigger((tweets.length === 0 ? "empty" : "full"));
222          if (s.refresh_interval) {
223            window.setTimeout(function() { $(widget).trigger("load"); }, 1000 * s.refresh_interval);
224          }
225          
226          // callback    
227          if ( s.callback ){ s.callback(); }
228          
229        });
230      }).trigger("load");
231    });
232  };
233})(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.