From 990182ebbbb832e08f9c324817238a64ad71fd8f Mon Sep 17 00:00:00 2001 From: anekos Date: Tue, 3 Aug 2010 10:51:06 +0000 Subject: 複数のリンクに対応 git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@38153 d0d07461-0603-4401-acd4-de1884942a52 --- twittperator.js | 22 +++++++++++++++++++--- 1 file 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"; -- cgit v1.2.3