diff options
author | suVene | 2008-11-19 18:24:25 +0000 |
---|---|---|
committer | suVene | 2008-11-19 18:24:25 +0000 |
commit | c9cd64547f493e2982f4e67a9eea4673d44736e8 (patch) | |
tree | 2412670bd0ffd91e9c4d670a6e1f9480a9399fb5 | |
parent | a4da1bb9668c2353280e756f0541e1dc5bd2777b (diff) | |
download | vimperator-plugins-c9cd64547f493e2982f4e67a9eea4673d44736e8.tar.bz2 |
-s option廃止。選択テキストで実行
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/branches/1.2@24375 d0d07461-0603-4401-acd4-de1884942a52
-rw-r--r-- | multi_requester.js | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/multi_requester.js b/multi_requester.js index 5eb2b7e..3c7d417 100644 --- a/multi_requester.js +++ b/multi_requester.js @@ -4,21 +4,19 @@ * @description request, and the result is displayed to the buffer. * @description-ja リクエストの結果をバッファに出力する。 * @author suVene suvene@zeromemory.info - * @version 0.2.1 + * @version 0.2.2 * @minVersion 1.2 * @maxVersion 1.2 * ==/VimperatorPlugin== * * Usage: - * command[!] subcommand [ANY_TEXT | -s] + * command[!] subcommand [ANY_TEXT] * * ! create new tab. * ANY_TEXT your input text - * FLAGS: - * -s use selected text * - * :mr alc ANY_TEXT -> request by the input text, and display to the buffer. - * :mr! goo -s -> request by the selected text, and display to the new tab. + * :mr alc ANY_TEXT -> request by the input text, and display to the buffer. + * :mr! goo {window.selection} -> request by the selected text, and display to the new tab. * * * CUSTOMIZE .vimperatorrc: @@ -53,7 +51,7 @@ * liberator.globalVariables.multi_requester_mappings = [ * [',ml', 'ex'], // == :mr ex * [',mg', 'goo', '!'], // == :mr! goo - * [',ma', 'alc', , 'args'], // == :mr alc args (however, it uses a selected_text with precedence.) + * [',ma', 'alc', , 'args'], // == :mr alc args * ]; * EOM * @@ -189,11 +187,15 @@ var CommandRegister = { [key], "user defined mapping", function() { - var str = $U.getSelectedString() || args || ''; - if (str.length) { - liberator.execute(cmd + str); + if (args) { + liberator.execute(cmd + args); } else { - liberator.commandline.open(':', cmd, liberator.modes.EX); + let sel = $U.getSelectedString(); + if (sel.length) { + liberator.execute(cmd + sel); + } else { + liberator.commandline.open(':', cmd, liberator.modes.EX); + } } }, { @@ -464,9 +466,6 @@ var DataAccess = { var MultiRequester = { name: DataAccess.getCommand(), description: 'request, and display to the buffer', - cmdOptions: [ - [['-s'], liberator.OPTION_NOARG] - ], cmdAction: function(args, special, count) { var parsedArgs = this.parseArgs(args); @@ -482,7 +481,7 @@ var MultiRequester = { var ttbu = Components.classes['@mozilla.org/intl/texttosuburi;1'] .getService(Components.interfaces.nsITextToSubURI); url = url.replace(/%s/g, ttbu.ConvertAndEscape(urlEncode, parsedArgs.str)); - $U.log(url); + $U.log(url + '::' + siteinfo.xpath); if (special) { liberator.open(url, liberator.NEW_TAB); @@ -509,11 +508,13 @@ var MultiRequester = { if (!args) return null; - var isOptS = args.hasOwnProperty('-s'); - if ((isOptS && args.arguments.length < 1) || (!isOptS && args.arguments.length < 2)) return null; + var arguments = args.split(/ +/); + var sel = $U.getSelectedString(); - var siteName = args.arguments.shift(); - var str = (isOptS ? $U.getSelectedString() : args.arguments.join()).replace(/[\n\r]+/g, ''); + if ((sel && arguments.length < 1) || (!sel && arguments.length < 2)) return null; + + var siteName = arguments.shift(); + var str = (arguments.length < 1 ? sel : arguments.join()).replace(/[\n\r]+/g, ''); var siteinfo = this.getSite(siteName); return {name: siteName, siteinfo: siteinfo, str: str}; @@ -544,7 +545,7 @@ var MultiRequester = { '<a href="' + escapedUrl + '" class="hl-Title" target="_self">' + escapedUrl + '</a>' + (new XMLSerializer()).serializeToString(doc).replace(/<[^>]+>/g, function(all) all.toLowerCase()) + '</div>'; - $U.echo(new XMLList(html)); + try { $U.echo(new XMLList(html)); } catch (e) { $U.echo(html); } } catch (e) { $U.echoerr('error!!: ' + e); |