From bb0c83da4ce719b363f9db6c2db0ab892e176bc4 Mon Sep 17 00:00:00 2001 From: drry Date: Sat, 4 Oct 2008 14:28:22 +0000 Subject: * 既定ポートを修正しました。 * 数字の引数を追加しました。 e.g. `:incuri 2` git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@20723 d0d07461-0603-4401-acd4-de1884942a52 --- incuri.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'incuri.js') diff --git a/incuri.js b/incuri.js index ef480aa..35f130f 100644 --- a/incuri.js +++ b/incuri.js @@ -4,7 +4,7 @@ * @description increment the number in the URI * @description-ja URIに含まれる数字をインクリメント * @author hogelog - * @version 0.02 + * @version 0.03 * ==/VimperatorPlugin== * * COMMANDS: @@ -37,11 +37,15 @@ var l = window.content.location; var part = l[p]; if(p == "port" && part == "") { - part = "80"; + part = ({ + "ftp:" : "21", "http:" : "80", "https:" : "443" + })[l.protocol] || part; } if(numreg.test(part)) { + arg = arg.arguments[0]; let num = RegExp.$2; - let nextnum = numstr(f(parseInt(num)), num.length); + let quantity = !arg || isNaN(arg) ? 1 : parseInt(arg); + let nextnum = numstr(f(parseInt(num), quantity), num.length); let newpart = RegExp.$1 + nextnum + RegExp.$3; if(p == "href") { window.content.location.href = newpart; @@ -75,7 +79,8 @@ liberator.commands .add([prefix.toLowerCase() + "c" + suffix], prefix + "crement the number in the " + name + ".", - makeinc(function(x) x + dir, prop)); + makeinc(function(x, q) x + dir * q, prop), + { argCount : "?" }); }); }); })(); -- cgit v1.2.3