aboutsummaryrefslogtreecommitdiffstats
path: root/bitly.js
diff options
context:
space:
mode:
authoranekos2010-05-25 19:26:19 +0000
committeranekos2010-05-25 19:26:19 +0000
commitf46f04b6807f6cbaeac6c70b0ad2e8fbddd78ffe (patch)
treecc6797575e7c0098d7f05b597d8c4ebee4a6dc80 /bitly.js
parentfa402e02902722748a66f4be0fa1f6740d763ba1 (diff)
downloadvimperator-plugins-f46f04b6807f6cbaeac6c70b0ad2e8fbddd78ffe.tar.bz2
expand 対応
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@37706 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'bitly.js')
-rw-r--r--bitly.js18
1 files changed, 11 insertions, 7 deletions
diff --git a/bitly.js b/bitly.js
index cf7b633..9390e20 100644
--- a/bitly.js
+++ b/bitly.js
@@ -38,7 +38,7 @@ let PLUGIN_INFO =
<name>bit.ly</name>
<description>Get short alias by bit.ly and j.mp</description>
<description lang="ja">bit.ly や j.mp で短縮URLを得る</description>
- <version>2.0.3</version>
+ <version>2.1.0</version>
<author mail="anekos@snca.net" homepage="http://d.hatena.ne.jp/nokturnalmortum/">anekos</author>
<license>new BSD License (Please read the source code comments of this plugin)</license>
<license lang="ja">修正BSDライセンス (ソースコードのコメントを参照してください)</license>
@@ -95,7 +95,7 @@ let PLUGIN_INFO =
);
}
- function shorten (url, domain, callback) {
+ function shorten (url, domain, command, callback) {
function get () {
let req = new XMLHttpRequest();
req.onreadystatechange = function () {
@@ -104,13 +104,13 @@ let PLUGIN_INFO =
if (req.status == 200)
return callback && callback(req.responseText, req);
else
- throw new Error(req.statusText);
+ return liberator.echoerr(req.statusText);
};
let requestUri =
- ApiUrl + '/shorten?' +
+ ApiUrl + '/' + (command || 'shorten') + '?' +
'apiKey=' + auth.password + '&' +
'login=' + auth.username + '&' +
- 'uri=' + encodeURIComponent(url) + '&' +
+ (command !== 'expand' ? 'uri=' : 'shortUrl=') + encodeURIComponent(url) + '&' +
'domain=' + (domain || 'bit.ly') + '&' +
'format=txt';
req.open('GET', requestUri, callback);
@@ -142,14 +142,18 @@ let PLUGIN_INFO =
'Copy ' + domain + ' url',
function (args) {
let url = args.literalArg ? util.stringToURLArray(args.literalArg)[0] : buffer.URL;
+ let cmd = args['-expand'] ? 'expand' : 'shorten';
- shorten(url, domain, function (short) {
+ shorten(url, domain, cmd, function (short) {
util.copyToClipboard(short);
liberator.echo(short + ' <= ' + url);
});
},
{
literal: 0,
+ options: [
+ [['-expand', '-e'], commands.OPTION_NOARG]
+ ],
completer: function (context) {
context.completions = [
[buffer.URL, 'Current URL']
@@ -159,7 +163,7 @@ let PLUGIN_INFO =
},
true
);
- __context__[name] = function (url, callback) shorten(url, domain, callback);
+ __context__[name] = function (url, cmd, callback) shorten(url, domain, cmd, callback);
});
__context__.get = shorten;