diff options
author | snaka | 2009-06-04 22:07:26 +0000 |
---|---|---|
committer | snaka | 2009-06-04 22:07:26 +0000 |
commit | 89eb1da66dd243b299356599c1b36031c9b29125 (patch) | |
tree | 6f413da11e49d53457b7e2a33b5c1bc94bc43831 /twitter.js | |
parent | 0be96ebf7f87c3518e78dedc4a32584d6b3db874 (diff) | |
download | vimperator-plugins-89eb1da66dd243b299356599c1b36031c9b29125.tar.bz2 |
- Add least PLUGIN_INFO
- Replace URLish string to anchor link element.
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@33794 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'twitter.js')
-rw-r--r-- | twitter.js | 17 |
1 files changed, 16 insertions, 1 deletions
@@ -18,6 +18,11 @@ // fav someone's last status.. // :twitter!- someone // un-fav someone's last status.. +let PLUGIN_INFO = +<VimperatorPlugin> +<name>{NAME}</name> +<updateURL>http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/twitter.js</updateURL> +</VimperatorPlugin>; (function(){ var passwordManager = Cc["@mozilla.org/login-manager;1"].getService(Ci.nsILoginManager); @@ -121,7 +126,7 @@ title={status.user.screen_name} class="twitter photo"/> <strong>{status.user.name}‬</strong> - : <span class="twitter entry-content">{status.text}</span> + : <span class="twitter entry-content">{detectLink(status.text)}</span> </>.toSource() .replace(/(?:\r\n|[\r\n])[ \t]*/g, " ")) .join("<br/>"); @@ -129,6 +134,16 @@ //liberator.log(html); liberator.echo(html, true); } + function detectLink(str) { + let m = str.match(/https?:\/\/\S+/); + if (m) { + let left = str.substr(0, m.index); + let url = m[0]; + let right = str.substring(m.index + m[0].length); + return <>{detectLink(left)}<a highlight="URL" href={url}> {url} </a>{detectLink(right)}</>; + } + return str; + } function showTwitterSearchResult(word){ var xhr = new XMLHttpRequest(); xhr.open("GET", "http://search.twitter.com/search.json?q=" + encodeURIComponent(word), false); |