aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoranekos2010-08-05 13:50:14 +0000
committeranekos2010-08-05 13:50:14 +0000
commit1ab47f58917693ef925023d1010c455f4b82e5b9 (patch)
treee3bbece742844fef0896e2d497a6e2095a59e36f
parent374ed37585a5c1fd4ea0ea049524e29de3e7136b (diff)
downloadvimperator-plugins-1ab47f58917693ef925023d1010c455f4b82e5b9.tar.bz2
複数URL時の補完に説明っぽいものをついか
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@38182 d0d07461-0603-4401-acd4-de1884942a52
-rwxr-xr-xtwittperator.js23
1 files changed, 15 insertions, 8 deletions
diff --git a/twittperator.js b/twittperator.js
index 5c94164..2fb7d7a 100755
--- a/twittperator.js
+++ b/twittperator.js
@@ -1326,26 +1326,33 @@
liberator.echo("[Twittperator] Your post " + '"' + t + '" (' + t.length + " characters) was sent.", true);
});
} // }}}
- function openLink(text) { // {{{
- // TODO 複数のリンクに対応
- let links = [];
- text.replace(/https?:\/\/\S+/g, function(m) links.push(m));
- if (links.length <= 0)
+ function selectAndOpenLink(links) { // {{{
+ if (!links || !links.length)
return;
- if (links.length == 1)
- return liberator.open(links[0], liberator.NEW_TAB);
+ if (links.length === 1)
+ return liberator.open(links[0][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))];
+ context.completions = links;
}
}
);
} // }}}
+ function openLink(text) { // {{{
+ let m = text.match(/.*?(https?:\/\/[\S]+)/g);
+ if (!m)
+ return;
+
+ let links =
+ m.map(function (s) s.match(/^(.*?)(https?:\/\/[\S]+)/).slice(1)) .
+ map(function (ss) (ss.reverse(), ss.map(String.trim)))
+ selectAndOpenLink(links);
+ } // }}}
function ReTweet(id) { // {{{
let url = "http://api.twitter.com/1/statuses/retweet/" + id + ".json";
tw.post(url, null, function(text) {