Changeset 24375

Show
Ignore:
Timestamp:
11/20/08 03:24:25 (7 weeks ago)
Author:
suVene
Message:

-s option廃止。選択テキストで実行

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/javascript/vimperator-plugins/branches/1.2/multi_requester.js

    r24359 r24375  
    55 * @description-ja   リクエストの結果をバッファに出力する。 
    66 * @author           suVene suvene@zeromemory.info 
    7  * @version          0.2.1 
     7 * @version          0.2.2 
    88 * @minVersion       1.2 
    99 * @maxVersion       1.2 
     
    1111 * 
    1212 * Usage: 
    13  *   command[!] subcommand [ANY_TEXT | -s] 
     13 *   command[!] subcommand [ANY_TEXT] 
    1414 * 
    1515 *     !                create new tab. 
    1616 *     ANY_TEXT         your input text 
    17  *     FLAGS: 
    18  *       -s             use selected text 
    19  * 
    20  *   :mr  alc ANY_TEXT  -> request by the input text, and display to the buffer. 
    21  *   :mr! goo -s        -> request by the selected text, and display to the new tab. 
     17 * 
     18 *   :mr  alc ANY_TEXT           -> request by the input text, and display to the buffer. 
     19 *   :mr! goo {window.selection} -> request by the selected text, and display to the new tab. 
    2220 * 
    2321 * 
     
    5452 *       [',ml', 'ex'],                  // == :mr  ex 
    5553 *       [',mg', 'goo', '!'],            // == :mr! goo 
    56  *       [',ma', 'alc',    , 'args'],    // == :mr  alc args (however, it uses a selected_text with precedence.) 
     54 *       [',ma', 'alc',    , 'args'],    // == :mr  alc args 
    5755 *   ]; 
    5856 *   EOM 
     
    190188                "user defined mapping", 
    191189                function() { 
    192                     var str = $U.getSelectedString() || args || ''; 
    193                     if (str.length) { 
    194                         liberator.execute(cmd + str); 
     190                    if (args) { 
     191                        liberator.execute(cmd + args); 
    195192                    } else { 
    196                         liberator.commandline.open(':', cmd, liberator.modes.EX); 
     193                        let sel = $U.getSelectedString(); 
     194                        if (sel.length) { 
     195                            liberator.execute(cmd + sel); 
     196                        } else { 
     197                            liberator.commandline.open(':', cmd, liberator.modes.EX); 
     198                        } 
    197199                    } 
    198200                }, 
     
    465467    name: DataAccess.getCommand(), 
    466468    description: 'request, and display to the buffer', 
    467     cmdOptions: [ 
    468         [['-s'], liberator.OPTION_NOARG] 
    469     ], 
    470469    cmdAction: function(args, special, count) { 
    471470 
     
    483482                             .getService(Components.interfaces.nsITextToSubURI); 
    484483        url = url.replace(/%s/g, ttbu.ConvertAndEscape(urlEncode, parsedArgs.str)); 
    485         $U.log(url); 
     484        $U.log(url + '::' + siteinfo.xpath); 
    486485 
    487486        if (special) { 
     
    510509        if (!args) return null; 
    511510 
    512         var isOptS = args.hasOwnProperty('-s'); 
    513         if ((isOptS && args.arguments.length < 1) || (!isOptS && args.arguments.length < 2)) return null; 
    514  
    515         var siteName = args.arguments.shift(); 
    516         var str = (isOptS ? $U.getSelectedString() : args.arguments.join()).replace(/[\n\r]+/g, ''); 
     511        var arguments = args.split(/ +/); 
     512        var sel = $U.getSelectedString(); 
     513 
     514        if ((sel && arguments.length < 1) || (!sel && arguments.length < 2)) return null; 
     515 
     516        var siteName = arguments.shift(); 
     517        var str = (arguments.length < 1 ? sel : arguments.join()).replace(/[\n\r]+/g, ''); 
    517518        var siteinfo = this.getSite(siteName); 
    518519 
     
    545546                   (new XMLSerializer()).serializeToString(doc).replace(/<[^>]+>/g, function(all) all.toLowerCase()) + 
    546547                   '</div>'; 
    547             $U.echo(new XMLList(html)); 
     548            try { $U.echo(new XMLList(html)); } catch (e) { $U.echo(html); } 
    548549 
    549550        } catch (e) {