PageSourceSearch

https://dotnetpowered.com/js/twitter.js

js dotnetpowered.com collected 2026-10-03 20:04:52 UTC 3,932 bytes, 146 lines download raw bytes

1(function($) {
2JQTWEET = {
3	
4	// Set twitter username, number of tweets & id/class to append tweets
5	user: 'Orange_Idea_RU',
6	numTweets: 1,
7	appendTo: '#jstwitter',
8
9	// core function of jqtweet
10	loadTweets: function() {
11		$.ajax({
12			url: 'http://api.twitter.com/1/statuses/user_timeline.json/',
13			type: 'GET',
14			dataType: 'jsonp',
15			data: {
16				screen_name: JQTWEET.user,
17				include_rts: true,
18				count: JQTWEET.numTweets,
19				include_entities: true
20			},
21			success: function(data, textStatus, xhr) {
22
23			 var html = '<div class="tweet" style="float:left !important">TWEET_TEXT<div class="time">AGO</div>';
24
25				 // append tweets into page
26				 for (var i = 0; i < data.length; i++) {
27					$(JQTWEET.appendTo).append(
28						html.replace('TWEET_TEXT', JQTWEET.ify.clean(data[i].text))
29							.replace(/USER/g, data[i].user.screen_name)
30							.replace('AGO', JQTWEET.timeAgo(data[i].created_at))
31							.replace(/ID/g, data[i].id_str)
32					);
33
34				 }					
35			}	
36
37		});
38		
39	}, 
40	
41		
42	/**
43      * relative time calculator FROM TWITTER
44      * @param {string} twitter date string returned from Twitter API
45      * @return {string} relative time like "2 minutes ago"
46      */
47    timeAgo: function(dateString) {
48		var rightNow = new Date();
49		var then = new Date(dateString);
50		
51		if ($.browser.msie) {
52			// IE can't parse these crazy Ruby dates
53			then = Date.parse(dateString.replace(/( \+)/, ' UTC$1'));
54		}
55
56		var diff = rightNow - then;
57
58		var second = 1000,
59		minute = second * 60,
60		hour = minute * 60,
61		day = hour * 24,
62		week = day * 7;
63
64		if (isNaN(diff) || diff < 0) {
65			return ""; // return blank string if unknown
66		}
67
68		if (diff < second * 2) {
69			// within 2 seconds
70			return "right now";
71		}
72
73		if (diff < minute) {
74			return Math.floor(diff / second) + " seconds ago";
75		}
76
77		if (diff < minute * 2) {
78			return "about 1 minute ago";
79		}
80
81		if (diff < hour) {
82			return Math.floor(diff / minute) + " minutes ago";
83		}
84
85		if (diff < hour * 2) {
86			return "about 1 hour ago";
87		}
88
89		if (diff < day) {
90			return  Math.floor(diff / hour) + " hours ago";
91		}
92
93		if (diff > day && diff < day * 2) {
94			return "yesterday";
95		}
96
97		if (diff < day * 365) {
98			return Math.floor(diff / day) + " days ago";
99		}
100
101		else {
102			return "over a year ago";
103		}
104	}, // timeAgo()
105    
106	
107    /**
108      * The Twitalinkahashifyer!
109      * http://www.dustindiaz.com/basement/ify.html
110      * Eg:
111      * ify.clean('your tweet text');
112      */
113    ify:  {
114      link: function(tweet) {
115        return tweet.replace(/\b(((https*\:\/\/)|www\.)[^\"\']+?)(([!?,.\)]+)?(\s|$))/g, function(link, m1, m2, m3, m4) {
116          var http = m2.match(/w/) ? 'http://' : '';
117          return '<a class="twtr-hyperlink" target="_blank" href="' + http + m1 + '">' + ((m1.length > 25) ? m1.substr(0, 24) + '...' : m1) + '</a>' + m4;
118        });
119      },
120
121      at: function(tweet) {
122        return tweet.replace(/\B[@ï¼ ]([a-zA-Z0-9_]{1,20})/g, function(m, username) {
123          return '<a target="_blank" class="twtr-atreply" href="http://twitter.com/intent/user?screen_name=' + username + '">@' + username + '</a>';
124        });
125      },
126
127      list: function(tweet) {
128        return tweet.replace(/\B[@ï¼ ]([a-zA-Z0-9_]{1,20}\/\w+)/g, function(m, userlist) {
129          return '<a target="_blank" class="twtr-atreply" href="http://twitter.com/' + userlist + '">@' + userlist + '</a>';
130        });
131      },
132
133      hash: function(tweet) {
134        return tweet.replace(/(^|\s+)#(\w+)/gi, function(m, before, hash) {
135          return before + '<a target="_blank" class="twtr-hashtag" href="http://twitter.com/search?q=%23' + hash + '">#' + hash + '</a>';
136        });
137      },
138
139      clean: function(tweet) {
140        return this.hash(this.at(this.list(this.link(tweet))));
141      }
142    } // ify
143
144	
145};
146})(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.