49 return {"hours" : hours, "minutes" : minutes, "seconds" : seconds}; |
49 return {"hours" : hours, "minutes" : minutes, "seconds" : seconds}; |
50 }; |
50 }; |
51 |
51 |
52 /* format a tweet - replaces @name by a link to the profile, #hashtag, etc. */ |
52 /* format a tweet - replaces @name by a link to the profile, #hashtag, etc. */ |
53 IriSP.formatTweet = function(tweet) { |
53 IriSP.formatTweet = function(tweet) { |
54 var rNickname = /@(\w+)/; // matches a @handle |
54 var rNickname = /@(\w+)/gi; // matches a @handle |
55 var rHashtag = /#(\w+)/; // matches a hashtag |
55 var rHashtag = /#(\w+)/gi; // matches a hashtag |
56 var i1 = tweet.replace(rNickname, "<a href='http://twitter.com/$1'>@$1</a>"); |
56 var rUrl = /((https?:\/\/)?[\w-]+(\.[\w-]+)+\.?(:\d+)?(\/\S*)?)/gi; // copied from http://codegolf.stackexchange.com/questions/464/shortest-url-regex-match-in-javascript/480#480 |
57 var i2 = i1.replace(rHashtag, "<a href='http://twitter.com/search?q=%23$1'>#$1</a>"); |
|
58 |
57 |
59 return i2; |
58 var i1 = tweet.replace(rUrl, "<a href='$1'>$1</a>"); |
|
59 var i2 = i1.replace(rNickname, "<a href='http://twitter.com/$1'>@$1</a>"); |
|
60 var i3 = i2.replace(rHashtag, "<a href='http://twitter.com/search?q=%23$1'>#$1</a>"); |
|
61 |
|
62 return i3; |
60 }; |
63 }; |
61 |
64 |
62 /* for ie compatibility |
65 /* for ie compatibility |
63 if (Object.prototype.__defineGetter__&&!Object.defineProperty) { |
66 if (Object.prototype.__defineGetter__&&!Object.defineProperty) { |
64 Object.defineProperty=function(obj,prop,desc) { |
67 Object.defineProperty=function(obj,prop,desc) { |