diff options
author | anekos | 2010-08-03 10:51:06 +0000 |
---|---|---|
committer | anekos | 2010-08-03 10:51:06 +0000 |
commit | 990182ebbbb832e08f9c324817238a64ad71fd8f (patch) | |
tree | 750fd88aef674cf902ae9ca7c3bf43dca9ca1576 | |
parent | abdfbdc96faf0f31e0ff20d9e6924ebba46faf02 (diff) | |
download | vimperator-plugins-990182ebbbb832e08f9c324817238a64ad71fd8f.tar.bz2 |
複数のリンクに対応
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@38153 d0d07461-0603-4401-acd4-de1884942a52
-rwxr-xr-x | twittperator.js | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/twittperator.js b/twittperator.js index 28b8583..da64c68 100755 --- a/twittperator.js +++ b/twittperator.js @@ -1337,9 +1337,25 @@ } // }}} function openLink(text) { // {{{ // TODO 複数のリンクに対応 - let m = text.match(/https?:\/\/\S+/); - if (m) - liberator.open(m[0], liberator.NEW_TAB); + let links = []; + text.replace(/https?:\/\/\S+/g, function(m) links.push(m)); + if (links.length <= 0) + return; + + if (links.length == 1) + return liberator.open(links[0], liberator.NEW_TAB); + + commandline.input( + 'Select URL: ', + function (arg) { + liberator.open(arg, liberator.NEW_TAB); + }, + { + completer: function(context) { + context.completions = [[link, link] for ([, link] in Iterator(links))]; + } + } + ); } // }}} function ReTweet(id) { // {{{ let url = "http://api.twitter.com/1/statuses/retweet/" + id + ".json"; |