PageSourceSearch

https://coloradospartans.com/scripts/twitter.js

js coloradospartans.com collected 2026-10-04 19:08:57 UTC 5,112 bytes, 174 lines download raw bytes

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

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.