59 |
59 |
60 IriSP.secondsToString |
60 IriSP.secondsToString |
61 |
61 |
62 /* format a tweet - replaces @name by a link to the profile, #hashtag, etc. */ |
62 /* format a tweet - replaces @name by a link to the profile, #hashtag, etc. */ |
63 IriSP.formatTweet = function(tweet) { |
63 IriSP.formatTweet = function(tweet) { |
64 var rNickname = /@(\w+)/gi; // matches a @handle |
64 /* |
65 var rHashtag = /#(\w+)/gi; // matches a hashtag |
65 an array of arrays which hold a regexp and its replacement. |
66 var rUrl = /((https?:\/\/)?[\w-]+(\.[\w-]+)+\.?(:\d+)?(\/\S*)?)/gi; // copied from http://codegolf.stackexchange.com/questions/464/shortest-url-regex-match-in-javascript/480#480 |
66 */ |
|
67 var regExps = [ |
|
68 /* copied from http://codegolf.stackexchange.com/questions/464/shortest-url-regex-match-in-javascript/480#480 */ |
|
69 [/((https?:\/\/)?[\w-]+(\.[\w-]+)+\.?(:\d+)?(\/\S*)?)/gi, "<a href='$1'>$1</a>"], |
|
70 [/@(\w+)/gi, "<a href='http://twitter.com/$1'>@$1</a>"], // matches a @handle |
|
71 [/#(\w+)/gi, "<a href='http://twitter.com/search?q=%23$1'>#$1</a>"],// matches a hashtag |
|
72 [/(\+\+)/gi, "<span class='Ldt-PolemicPlusPlus'>$1</span>"], |
|
73 [/(--)/gi, "<span class='Ldt-PolemicMinusMinus'>$1</span>"], |
|
74 [/(==)/gi, "<span class='Ldt-PolemicEqualEqual'>$1</span>"], |
|
75 [/(\?\?)/gi, "<span class='Ldt-PolemicQuestion'>$1</span>"] |
|
76 ]; |
|
77 |
|
78 var i = 0; |
|
79 for(i = 0; i < regExps.length; i++) { |
|
80 tweet = tweet.replace(regExps[i][0], regExps[i][1]); |
|
81 } |
67 |
82 |
68 var i1 = tweet.replace(rUrl, "<a href='$1'>$1</a>"); |
83 return tweet; |
69 var i2 = i1.replace(rNickname, "<a href='http://twitter.com/$1'>@$1</a>"); |
|
70 var i3 = i2.replace(rHashtag, "<a href='http://twitter.com/search?q=%23$1'>#$1</a>"); |
|
71 |
|
72 return i3; |
|
73 }; |
84 }; |
74 |
85 |
75 IriSP.countProperties = function(obj) { |
86 IriSP.countProperties = function(obj) { |
76 var count = 0; |
87 var count = 0; |
77 |
88 |