From 61ffc41c7713df2364fe653bde03d910d130b2e4 Mon Sep 17 00:00:00 2001 From: pekepeke Date: Sun, 21 Dec 2008 05:35:17 +0000 Subject: applauncher.js 新規追加 git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@27141 d0d07461-0603-4401-acd4-de1884942a52 --- applauncher.js | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 applauncher.js (limited to 'applauncher.js') diff --git a/applauncher.js b/applauncher.js new file mode 100644 index 0000000..a49d58c --- /dev/null +++ b/applauncher.js @@ -0,0 +1,103 @@ +var PLUGIN_INFO = + + AppLauncher + アプリケーションランチャー + Launch defined application + アプリケーションを起動します + 0.10 + pekepeke + 2.0pre + 2.0pre + + + +liberator.plugins.AppLauncher = (function(){ + const AppName = 'AppLauncher'; + var global = liberator.globalVariables; + var settings = global.applauncher_list ? global.applauncher_list : []; + if (!settings || settings.length <= 0) return; + var completer = settings.map( function([name, app, args]) [name, args ? app + ' ' + args.toString(): app] ); + + var Class = function(){ return function(){ this.initialize.apply(this, arguments); }}; + var AppLauncher = new Class(); + + AppLauncher.prototype = { + initialize: function(){ + this.buildMenu(); + this.registerCommand(); + }, + registerCommand: function(){ + var self = this; + commands.addUserCommand(['applaunch','runapp'], 'Run Defined Application', + function(arg){ + arg = (typeof arg.string == undefined ? arg : arg.string); + self.launch(arg); + }, { + completer: function( context, arg, special){ + let filter = context.filter; + context.title = [ 'Name', 'Description']; + if (!filter) { + context.completions = completer; + return; + } + filter = filter.toLowerCase(); + context.completions = completer.filter( function(el) el[0].toLowerCase().indexOf(filter) == 0); + } + }); + }, + buildMenu: function(){ + var self = this; + var menu = document.createElement('menu'); + 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); + for (let i=0, l=settings.length; i '\ ' + 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) ); + if (appName == name) { + io.run(app, args); + return true; + } + return false; + }); + } + } + return new AppLauncher(); +})(); -- cgit v1.2.3