aboutsummaryrefslogtreecommitdiffstats
path: root/applauncher.js
diff options
context:
space:
mode:
authoranekos2008-12-21 10:40:59 +0000
committeranekos2008-12-21 10:40:59 +0000
commitcaceac35d2bb51ee874639dc6d497d574f3227ec (patch)
tree5e8a82559500effe5ad69c84a938431511366e2c /applauncher.js
parent774083438c0c7e6b0e06b098d69e8076f6eac9e9 (diff)
downloadvimperator-plugins-caceac35d2bb51ee874639dc6d497d574f3227ec.tar.bz2
Remove whitespaces.
Add %TITLE%. git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@27155 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'applauncher.js')
-rw-r--r--applauncher.js27
1 files changed, 17 insertions, 10 deletions
diff --git a/applauncher.js b/applauncher.js
index a49d58c..18fb9fe 100644
--- a/applauncher.js
+++ b/applauncher.js
@@ -4,7 +4,7 @@ var PLUGIN_INFO =
<name lang='ja'>アプリケーションランチャー</name>
<description>Launch defined application</description>
<description lang='ja'>アプリケーションを起動します</description>
- <version>0.10</version>
+ <version>0.11</version>
<author>pekepeke</author>
<minVersion>2.0pre</minVersion>
<maxVersion>2.0pre</maxVersion>
@@ -36,7 +36,7 @@ liberator.plugins.AppLauncher = (function(){
var Class = function(){ return function(){ this.initialize.apply(this, arguments); }};
var AppLauncher = new Class();
-
+
AppLauncher.prototype = {
initialize: function(){
this.buildMenu();
@@ -44,7 +44,7 @@ liberator.plugins.AppLauncher = (function(){
},
registerCommand: function(){
var self = this;
- commands.addUserCommand(['applaunch','runapp'], 'Run Defined Application',
+ commands.addUserCommand(['applaunch', 'runapp'], 'Run Defined Application',
function(arg){
arg = (typeof arg.string == undefined ? arg : arg.string);
self.launch(arg);
@@ -67,7 +67,7 @@ liberator.plugins.AppLauncher = (function(){
menu.setAttribute('id', AppName + 'Context');
menu.setAttribute('label', AppName);
menu.setAttribute('accesskey', 'L');
-
+
var menupopup = document.createElement('menupopup');
menupopup.setAttribute('id', AppName + 'ContextMenu');
menu.appendChild(menupopup);
@@ -81,16 +81,23 @@ liberator.plugins.AppLauncher = (function(){
}
document.getElementById('contentAreaContextMenu').appendChild(menu);
},
+ variables: {
+ __noSuchMethod__: function(name) name,
+ URL: function() gContextMenu && gContextMenu.onLink ? gContextMenu.getLinkURL() : buffer.URL,
+ SEL: function(){
+ var selection = window.content.window.getSelection();
+ var sel = '';
+ for (let i=0, l=selection.rangeCount; i<l; i++) sel+=selection.getRangeAt(i).toString();
+ return sel;
+ },
+ TITLE: function() buffer.title
+ },
launch: function(appName){
- var url = gContextMenu && gContextMenu.onLink ? gContextMenu.getLinkURL() : buffer.URL ;
- var selection = window.content.window.getSelection();
- var sel = '';
- for (let i=0, l=selection.rangeCount; i<l; i++) sel+=selection.getRangeAt(i).toString();
-
+ var self = this;
appName = appName.replace(/\\/g,''); // fix commandline input ' ' -> '\ '
settings.some( function([name, app, args]){
args = args instanceof Array ? args : args ? [args] : [];
- args = args.map( function( val ) val.replace(/%URL%/g, url).replace(/%SEL%/g, sel) );
+ args = args.map( function( val ) val.replace(/%([A-Z]+)%/g, function( _, name ) self.variables[name]()) );
if (appName == name) {
io.run(app, args);
return true;