diff options
author | pekepeke | 2009-11-30 04:38:42 +0000 |
---|---|---|
committer | pekepeke | 2009-11-30 04:38:42 +0000 |
commit | 398eb3f1114b9b1698e3df58d25ff219eb9653c4 (patch) | |
tree | 37708b031fdde9ed8d84259a50e47f0c5e399865 | |
parent | a18022dda670e4ee39da246a458b4debc99f4113 (diff) | |
download | vimperator-plugins-398eb3f1114b9b1698e3df58d25ff219eb9653c4.tar.bz2 |
custom functionに引数渡し対応
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@36045 d0d07461-0603-4401-acd4-de1884942a52
-rw-r--r-- | exopen.js | 31 |
1 files changed, 18 insertions, 13 deletions
@@ -35,17 +35,17 @@ javascript <<EOM liberator.globalVariables.exopen_templates = [ { label: 'vimpnightly', - value: 'http://download.vimperator.org/vimperator/nightly/', + value: 'http://code.google.com/p/vimperator-labs/downloads/list?can=1&q=label:project-vimperator', description: 'open vimperator nightly xpi page', newtab: true }, { label: 'vimplab', - value: 'http://vimperator.org/trac/', + value: 'http://www.vimperator.org/vimperator', description: 'open vimperator trac page', newtab: true }, { label: 'vimpscript', - value: 'http://vimperator.org/trac/wiki/Vimperator/Scripts/', + value: 'http://code.google.com/p/vimperator-labs/issues/list?can=2&q=label%3Aproject-vimperator+label%3Atype-plugin', description: 'open vimperator trac script page', newtab: true }, { @@ -82,17 +82,17 @@ liberator.plugins.exOpen = (function() { if (!global) { global = [{ label: 'vimpnightly', - value: 'http://download.vimperator.org/vimperator/nightly/', + value: 'http://code.google.com/p/vimperator-labs/downloads/list?can=1&q=label:project-vimperator', description: 'open vimperator nightly xpi page', newtab: true }, { label: 'vimplab', - value: 'http://vimperator.org/trac/', + value: 'http://www.vimperator.org/vimperator', description: 'open vimperator trac page', newtab: true }, { label: 'vimpscript', - value: 'http://vimperator.org/trac/wiki/Vimperator/Scripts/', + value: 'http://code.google.com/p/vimperator-labs/issues/list?can=2&q=label%3Aproject-vimperator+label%3Atype-plugin', description: 'open vimperator trac script page', newtab: true }, { @@ -161,7 +161,7 @@ liberator.plugins.exOpen = (function() { registerCommand: function() { var self = this; commands.addUserCommand(['exopen'], 'Open byextension URL', - function(args) self.open(args.string, args.bang), { + function(args) self.open(args), { completer: function(context, args) { context.title = ['Template', 'Description - Value']; if (!context.filter) { @@ -178,21 +178,26 @@ liberator.plugins.exOpen = (function() { global.some(function(template) (template.label == label) && (ret = template)); return ret; }, - open: function(arg) { + open: function(args) { var url = ''; - if (!arg) return; - var template = this.find(arg) || {value: arg}; + if (!args) return; + var name = args.string; + if (args instanceof Array) { + name = args.shift(); + args.string = args.string.replace(new RegExp(name.replace(/(\W)/g,'\\$1')+'\\s+'),''); + } + var template = this.find(name) || {value: name}; if (typeof template.custom == 'function') { - url = template.custom.call(this, template.value); + url = template.custom.call(this, template.value, args); } else if (template.custom instanceof Array) { url = replacer(template.value).replace(template.custom[0], template.custom[1], template.escape); } else { url = replacer(template.value, template.escape); } if (!url) return; - if (template.newtab) openTabOrSwitch(url); + if (template.newtab || args.bang) openTabOrSwitch(url); else liberator.open(url); - } + }, }; return new ExOpen(); })(); |