Changeset 36144

Show
Ignore:
Timestamp:
12/15/09 23:12:00 (3 years ago)
Author:
anekos
Message:

初期化処理を変更

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/javascript/vimperator-plugins/trunk/every.js

    r36026 r36144  
    3939  <description>to run a specified command every time at specified interval.</description> 
    4040  <description lang="ja">指定のコマンドを指定の間隔で実行する。</description> 
    41   <version>1.3.0</version> 
     41  <version>1.3.1</version> 
    4242  <author mail="anekos@snca.net" homepage="http://d.hatena.ne.jp/nokturnalmortum/">anekos</author> 
    4343  <license>new BSD License (Please read the source code comments of this plugin)</license> 
    4444  <license lang="ja">修正BSDライセンス (ソースコードのコメントを参照してください)</license> 
    4545  <updateURL>http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/every.js</updateURL> 
    46   <minVersion>2.0pre</minVersion> 
    47   <maxVersion>2.0pre</maxVersion> 
     46  <minVersion>2.3</minVersion> 
     47  <maxVersion>2.3</maxVersion> 
    4848  <detail><![CDATA[ 
    4949    == Usage == 
     
    9191// }}} 
    9292 
     93ps = []; 
    9394 
    9495(function () { 
    9596 
    96   let every = liberator.plugins.every; 
    97   if (every) { 
    98     kill('*'); 
    99   } else { 
    100     liberator.plugins.every = every = {ps: []}; 
     97  let (every = liberator.plugins.every) { 
     98    if (every && every.ps) 
     99      kill('*'); 
    101100  } 
    102101 
     
    128127    }; 
    129128    process.handle = setInterval(fun, parseInt(interval, 10)); 
    130     every.ps.push(process); 
     129    ps.push(process); 
    131130  } 
    132131 
    133132  function kill (index) { 
    134133    if (index == '*') { 
    135       every.ps.forEach(function (process) clearInterval(process.handle)); 
    136       liberator.echo(every.ps.length + ' processes were killed!'); 
    137       every.ps = []; 
     134      ps.forEach(function (process) clearInterval(process.handle)); 
     135      liberator.echo(ps.length + ' processes were killed!'); 
     136      ps = []; 
    138137    } else { 
    139       let process = every.ps[index]; 
     138      let process = ps[index]; 
    140139      if (process) { 
    141140        clearInterval(process.handle); 
    142         every.ps.splice(index, index); 
     141        ps.splice(index, index); 
    143142        liberator.echo('process "' + process.command + '" was killed!'); 
    144143      } else { 
     
    186185        if (args.bang) { 
    187186          context.title = ['PID', 'every process']; 
    188           context.completions = [['*', 'kill em all']].concat(every.ps.map(function (p, i) ([i.toString(), p.command]))); 
     187          context.completions = [['*', 'kill em all']].concat(ps.map(function (p, i) ([i.toString(), p.command]))); 
    189188        } else { 
    190189          liberator.modules.completion.ex(context);