From d2a23f60e98966335ba1939c570a7e020084607d Mon Sep 17 00:00:00 2001 From: B Mathis Date: Fri, 6 Nov 2009 11:04:12 -0600 Subject: now twitter handles linking better, and replaces endlines with
tags --- source/javascripts/twitter.js | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'source/javascripts/twitter.js') diff --git a/source/javascripts/twitter.js b/source/javascripts/twitter.js index b78b8de1..d698cf90 100644 --- a/source/javascripts/twitter.js +++ b/source/javascripts/twitter.js @@ -10,6 +10,7 @@ var filter_mentions = true; var tweet_count = 5; var tweet_tag = 'p'; var twitter_div = 'twitter_status'; +var tweet_cookie = 'the_tweets_' + username; window.addEvent('domready',function() { getTwitterStatus(); @@ -29,7 +30,7 @@ function showTweets(the_tweets, from_cookie){ function getTwitterStatus(){ $(twitter_div).set('html', 'Fetching tweets...'); - if(!Cookie.read('the_tweets')) { + if(!Cookie.read(tweet_cookie)) { var myTwitterGitter = new TwitterGitter(username,{ count: ((!filter_mentions) ? tweet_count : 15 + tweet_count), onComplete: function(tweets,user) { @@ -37,21 +38,15 @@ function getTwitterStatus(){ tweets.each(function(tweet,i) { if((tweet.in_reply_to_status_id && !filter_mentions) || !tweet.in_reply_to_status_id){ if(the_tweets.length == tweet_count) return; + tweet.text = tweet.text.replace(/\n/gi, '
'); the_tweets.push(tweet.text); } }); - Cookie.write('the_tweets',the_tweets.join('^!^!^!^!^'), { duration: 1 }); + Cookie.write(tweet_cookie,the_tweets.join('^!^!^!^!^'), { duration: 1 }); showTweets(the_tweets); } }).retrieve(); } else { - showTweets(Cookie.read('the_tweets'),true); + showTweets(Cookie.read(tweet_cookie),true); } -} - -//implement string.tweetify(); -String.implement({ - tweetify: function() { - return this.replace(/(https?:\/\/\S+)/gi,'$1').replace(/(^|\s)@(\w+)/g,'$1@$2').replace(/(^|\s)#(\w+)/g,'$1#$2'); - } -}); \ No newline at end of file +} \ No newline at end of file -- cgit v1.2.1