diff options
author | anekos | 2008-11-08 16:35:49 +0000 |
---|---|---|
committer | anekos | 2008-11-08 16:35:49 +0000 |
commit | 05494c71f1a1e8b06cb4b7e7815c61524725ff4c (patch) | |
tree | 300430684a24fc26facdcae09fd05b4423328bf6 | |
parent | 5b829e24b4aae22f34799e7ce359952aac60b93a (diff) | |
download | vimperator-plugins-05494c71f1a1e8b06cb4b7e7815c61524725ff4c.tar.bz2 |
added
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/branches/1.2@23016 d0d07461-0603-4401-acd4-de1884942a52
-rw-r--r-- | asdfghjkl.js | 58 | ||||
-rw-r--r-- | bitly.js | 40 |
2 files changed, 98 insertions, 0 deletions
diff --git a/asdfghjkl.js b/asdfghjkl.js new file mode 100644 index 0000000..87f960d --- /dev/null +++ b/asdfghjkl.js @@ -0,0 +1,58 @@ +// ==VimperatorPlugin== +// @name asdfghjkl; +// @description Inputting numbers by asdfghjkl; keys in hint mode. +// @description-ja Hintモードで、asdfghjkl;キーを使って数字入力をする。 +// @license Creative Commons 2.1 (Attribution + Share Alike) +// @version 1.1 +// @minVersion 1.2 +// @maxVersion 1.2 +// @author anekos (anekos@snca.net) +// ==/VimperatorPlugin== +// +// Usage: +// In hint-mode, When press <Space>, enter into asdfghjkl; mode. +// (If you want to leave this mode, re-press <Space>) +// +// Usage-ja: +// ヒントモードで、<Space> を押すと asdfghjkl; モード(?)に入ります。 +// 出たい場合は、もう一度押します。 +// +// 切り替えキーを変更したい場合は、以下のように設定できます。 +// let g:asdfghjkl_mode_change_key = "<C-c>" +// +// +// Links: +// http://d.hatena.ne.jp/nokturnalmortum/20081021#1224543467 +// + +{ + let asdfghjkl_default = window.eval(liberator.globalVariables.asdfghjkl_default || "false"); + let active = false; + + let original = { + show: hints.show, + onEvent: hints.onEvent, + }; + + hints.show = function () { + active = asdfghjkl_default; + return original.show.apply(this, arguments); + }; + + hints.onEvent = function (event) { + let key = events.toString(event); + if (key == "<Space>") { + active = !active; + return; + } + if (active && key.length == 1) { + let n = ";asdfghjkl".indexOf(key); + if (n >= 0) { + events.feedkeys(n.toString(), true); + return; + } + } + return original.onEvent.call(this, event); + }; + +} diff --git a/bitly.js b/bitly.js new file mode 100644 index 0000000..f4e5bcc --- /dev/null +++ b/bitly.js @@ -0,0 +1,40 @@ +// ==VimperatorPlugin== +// @name Bit.ly +// @description-ja Bit.ly で短縮URLを得る +// @license Creative Commons 2.1 (Attribution + Share Alike) +// @version 1.0 +// ==/VimperatorPlugin== +// + +(function () { + + function bitly (uri) { + var req = new XMLHttpRequest(); + req.onreadystatechange = function(){ + if (req.readyState == 4) + return; + if(req.status == 200) { + var short = req.responseText; + util.copyToClipboard(short); + liberator.echo('`' + short + "' was copied to clipboard."); + return; + } + throw new Error(req.statusText) + }; + uri = 'http://bit.ly/api?url=' + uri; + req.open("GET", uri, true); + req.send(null); + } + + //commands.removeUserCommand('bitly'); + commands.addUserCommand( + ['bitly'], + 'Copy bitly url', + function () { + bitly(buffer.URL); + } + ); + +})(); + + |