From c136485e4e0b2052719fe24cda688891e01130dd Mon Sep 17 00:00:00 2001 From: drry Date: Mon, 7 Apr 2008 15:33:17 +0000 Subject: lang/javascript/vimperator-plugins/trunk/lookupDictionary.js lang/javascript/vimperator-plugins/trunk/gmperator.js: * 空白を修整しました。 * ほか。 git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@9102 d0d07461-0603-4401-acd4-de1884942a52 --- gmperator.js | 316 ++++++++++++++++++++++++++++++----------------------------- 1 file changed, 162 insertions(+), 154 deletions(-) (limited to 'gmperator.js') diff --git a/gmperator.js b/gmperator.js index 945513f..9b4af67 100644 --- a/gmperator.js +++ b/gmperator.js @@ -1,6 +1,6 @@ /** - * gmperator - vimperator plugin for Greasemonkey - * For vimperator 0.6pre + * gmperator - Vimperator plugin for Greasemonkey + * For Vimperator 0.6pre * @author teramako teramako@gmail.com * @version 0.3a * @@ -18,7 +18,7 @@ * so maybe you should edit the scripts before load * :gmlo[ad]! {name|filename} -> force load the user script * - * :gmset! -> toggle enable/disable greasemonkey + * :gmset! -> toggle enable/disable Greasemonkey * :gmset! {filename} -> toogle enable/disable the script * :gmset {filename} {options} * {options}: @@ -64,10 +64,10 @@ * enabled : {Boolean} * includes : {String[]} * encludes : {String[]} - * ) + * ) * addAutoCommand : function( uri, script, cmd ) * If both of uri and script is match - * + * * ) * }}} */ @@ -85,7 +85,7 @@ if(!liberator.plugins) liberator.plugins = {}; liberator.plugins.gmperator = (function(){ //{{{ // ----------------------- - // PUBLIC section + // PUBLIC section // ----------------------- // {{{ var manager = { @@ -96,7 +96,7 @@ liberator.plugins.gmperator = (function(){ //{{{ gmCon = containers[panelID]; } else { gmCon = new GmContainer(uri,sandbox); - containers[panelID] = gmCon; + containers[panelID] = gmCon; this.__defineGetter__(panelID,function(){return gmCon;}); log('gmpeartor: redisted: '+ panelID + ' - ' + uri); } @@ -188,143 +188,151 @@ liberator.plugins.gmperator = (function(){ //{{{ // User Command // --------------------------- commands.addUserCommand(['gmli[st]','lsgm'], 'list Greasemonkey scripts', //{{{ - function(arg,special){ - var str = ''; - var scripts = getScripts(); - var reg; - if (special || arg == 'full'){ - reg = new RegExp('.*'); - } else if( arg ){ - reg = new RegExp(arg,'i'); - } - if (reg){ - for each(var s in scripts){ - if ( reg.test(s.name) || reg.test(s.filename) ) { - str += scriptToString(s) + '\n\n'; - } - } - } else { - str = ''; - for each(var s in scripts){ - if (s.enabled){ - str += '' - } else { - str += ''; - } - str += '' - } - str += '
'+ s.name + '
' + s.name + '(' + s.filename + ')
'; - } - echo(str,true); - function scriptToString(script){ - var thTag = ''; - var rs = '' + thTag; - var re = ''; - var sep = ''; - return [ - '', - '', - rs, 'FileName', sep, script.filename, re, - rs, 'NameSpace', sep, script.namespace, re, - rs, 'Description', sep, script.description, re, - rs, 'Includes', sep, script.includes.join('
'), re, - rs, 'Excludes', sep, script.excludes.join('
'), re, - rs, 'Enabled', sep, script.enabled, re, - '
', script.name, '
' - ].join(''); - } - } + function(arg,special){ + var str = ''; + var scripts = getScripts(); + var reg; + var table, tr; + if (special || arg == 'full'){ + reg = new RegExp('.*'); + } else if( arg ){ + reg = new RegExp(arg,'i'); + } + if (reg){ + for each(var s in scripts){ + if ( reg.test(s.name) || reg.test(s.filename) ) { + str += scriptToString(s) + '\n\n'; + } + } + } else { + table = ; + for each(var script in scripts){ + tr = ; + if (script.enabled){ + tr.* += ; + } else { + tr.* += ; + } + tr.* += ; + table.* += tr; + } + str += table.toSource(); + } + echo(str,true); + function scriptToString(script){ + var table =
{script.name}{script.name}({script.filename})
+ +
{script.name}
; + ['FileName', 'NameSpace', 'Description', + 'Includes', 'Excludes', 'Enabled'].forEach(function(prop){ + var tr = + {prop} + ; + var contents = script[prop.toLowerCase()]; + if (typeof contents == "string"){ + tr.* += <>{contents}; + } else { + contents.forEach(function(c,i,a){ + tr.* += <>{c}; + if (a[i+1]) tr.* +=
; + }); + } + table.* += tr; + }); + return table.toSource(); + } + } ); //}}} -commands.addUserCommand(['gmlo[ad]'], 'load Greasemonkey script', //{{{ - function(arg, special){ - if (!arg) { +commands.addUserCommand(['gmlo[ad]'], 'load Greasemonkey scripts', //{{{ + function(arg, special){ + if (!arg) { echoerr('Usage: :gmlo[ad][!] {name|filename}'); return; } - var scripts = getScripts(); - var script; - for (var i=0; i 0){ script.name = commands.getOption(res.opts, '-name', script.name); script.includes = commands.getOption(res.opts, '-include', script.includes); script.excludes = commands.getOption(res.opts, '-exclude', script.excludes); } - config.save(); - },{ - args: [ - [['-name','-n'], commands.OPTION_STRING], - [['-include','-i'], commands.OPTION_LIST], - [['-exclude','-e'], commands.OPTION_LIST] - ], - shortHelp: 'change setting a greasemonkey script', - help: [ - 'toggle enable/disable with "!", if {filename} is exist, if not toggle greasemonkey', - '
-n
-name
change the name
', - '
-i
-include
change the inclue list ("," demiliter)
', - '
-e
-exclude
change the exclude list ("," demiliter)
', - 'Caution: the change is permanent, not the only session.
And cannot get back.' - ].join(''), - completer: function(filter){ + config.save(); + },{ + args: [ + [['-name','-n'], commands.OPTION_STRING], + [['-include','-i'], commands.OPTION_LIST], + [['-exclude','-e'], commands.OPTION_LIST] + ], + shortHelp: 'change settings for Greasemonkey scripts', + help: [ + 'toggle enable/disable with "!", if {filename} is exist, if not toggle Greasemonkey', + '
-n
-name
change the name
', + '
-i
-include
change the includes list ("," delimiter)
', + '
-e
-exclude
change the excludes list ("," delimiter)
', + 'Caution: the change is permanent, not the only session.
And cannot get back.' + ].join(''), + completer: function(filter){ return scriptsCompleter(filter, false); - } - } + } + } ); //}}} // --------------------------- @@ -357,35 +365,35 @@ GmContainer.prototype = { } } // }}} function getScripts(){ //{{{ - var config = new Config(); - config.load(); - return config.scripts; + var config = new Config(); + config.load(); + return config.scripts; } //}}} function scriptsCompleter(filter,flag){ //{{{ - var candidates = []; - var scripts = getScripts(); - var isAll = false; - if (!filter) isAll=true; - if (flag){ - for each(var s in scripts){ - if (isAll || s.name.toLowerCase().indexOf(filter) == 0 || - s.filename.indexOf(filter) == 0) - { - candidates.push([s.name, s.description]); - candidates.push([s.filename, s.description]); - } - } - } else { - for each(var s in scripts){ - if (isAll || s.filename.indexOf(filter) == 0) - { - candidates.push([s.filename, s.description]); - } - } - } - return [0,candidates]; + var candidates = []; + var scripts = getScripts(); + var isAll = false; + if (!filter) isAll=true; + if (flag){ + for each(var s in scripts){ + if (isAll || s.name.toLowerCase().indexOf(filter) == 0 || + s.filename.indexOf(filter) == 0) + { + candidates.push([s.name, s.description]); + candidates.push([s.filename, s.description]); + } + } + } else { + for each(var s in scripts){ + if (isAll || s.filename.indexOf(filter) == 0) + { + candidates.push([s.filename, s.description]); + } + } + } + return [0,candidates]; } //}}} })(); -// vim: set fdm=marker sw=4 ts=4 et: +// vim: fdm=marker sw=4 ts=4 et: -- cgit v1.2.3