From 29908abd809de8ee7d48fe651f33cbdac2a50664 Mon Sep 17 00:00:00 2001 From: anekos Date: Tue, 15 Dec 2009 14:12:00 +0000 Subject: 初期化処理を変更 git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@36144 d0d07461-0603-4401-acd4-de1884942a52 --- every.js | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'every.js') diff --git a/every.js b/every.js index 79761f4..9329b64 100644 --- a/every.js +++ b/every.js @@ -38,13 +38,13 @@ let PLUGIN_INFO = every.js to run a specified command every time at specified interval. 指定のコマンドを指定の間隔で実行する。 - 1.3.0 + 1.3.1 anekos new BSD License (Please read the source code comments of this plugin) 修正BSDライセンス (ソースコードのコメントを参照してください) http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/every.js - 2.0pre - 2.0pre + 2.3 + 2.3 : @@ -90,14 +90,13 @@ let PLUGIN_INFO = ; // }}} +ps = []; (function () { - let every = liberator.plugins.every; - if (every) { - kill('*'); - } else { - liberator.plugins.every = every = {ps: []}; + let (every = liberator.plugins.every) { + if (every && every.ps) + kill('*'); } function defined (value) @@ -127,19 +126,19 @@ let PLUGIN_INFO = liberator.execute(cmd); }; process.handle = setInterval(fun, parseInt(interval, 10)); - every.ps.push(process); + ps.push(process); } function kill (index) { if (index == '*') { - every.ps.forEach(function (process) clearInterval(process.handle)); - liberator.echo(every.ps.length + ' processes were killed!'); - every.ps = []; + ps.forEach(function (process) clearInterval(process.handle)); + liberator.echo(ps.length + ' processes were killed!'); + ps = []; } else { - let process = every.ps[index]; + let process = ps[index]; if (process) { clearInterval(process.handle); - every.ps.splice(index, index); + ps.splice(index, index); liberator.echo('process "' + process.command + '" was killed!'); } else { liberator.echoerr('unknown process'); @@ -185,7 +184,7 @@ let PLUGIN_INFO = completer: function (context, args) { if (args.bang) { context.title = ['PID', 'every process']; - context.completions = [['*', 'kill em all']].concat(every.ps.map(function (p, i) ([i.toString(), p.command]))); + context.completions = [['*', 'kill em all']].concat(ps.map(function (p, i) ([i.toString(), p.command]))); } else { liberator.modules.completion.ex(context); } -- cgit v1.2.3