From cfb7a437cee425a5d2d67fed2e95461aebfb7ed0 Mon Sep 17 00:00:00 2001 From: snaka Date: Sat, 23 May 2009 10:09:12 +0000 Subject: 複数のタブを開くときに一瞬固まったようになるので、タイムラグを入れてみた。 git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@33525 d0d07461-0603-4401-acd4-de1884942a52 --- pino.js | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) (limited to 'pino.js') diff --git a/pino.js b/pino.js index 0dbf3ec..eedfa35 100644 --- a/pino.js +++ b/pino.js @@ -36,8 +36,9 @@ var PLUGIN_INFO = Open livedoor Reader pinned items livedoor Reader でピンを立てたページを開く 2.0 - 2.1pre + 2.1 http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/pino.js + _libly.js snaka MIT style license 1.2.2 @@ -63,7 +64,7 @@ var PLUGIN_INFO = default: "http://reader.livedoor.com" == API == - plugins.pino.api.items(): + plugins.pino.items(): Return pinned items list array. Each item is following structure. >|| @@ -74,10 +75,10 @@ var PLUGIN_INFO = } ||< - plugins.pino.api.head(): - Return head item and remove pin. + plugins.pino.shift(): + Return first item and remove pin. - plugins.pino.api.remove(link): + plugins.pino.remove(link): Remove pin from item that matched by 'link'. ]]> @@ -112,7 +113,7 @@ var PLUGIN_INFO = default: "http://reader.livedoor.com" == API == - plugins.pino.api.items(): + plugins.pino.items(): ピンの一覧を配列で取得する。 ピンのデータ構造は以下のとおりとなっている。 >|| @@ -123,17 +124,16 @@ var PLUGIN_INFO = } ||< - plugins.pino.api.head(): + plugins.pino.shift(): 先頭のピンを取得して、そのピンを一覧から削除する。 - plugins.pino.api.remove(link): + plugins.pino.remove(link): linkに該当するピンを一覧から削除する。 ]]> ; // }}} -liberator.plugins.pino = {}; -liberator.plugins.pino.api = (function() { +let self = liberator.plugins.pino = (function() { // COMMAND /////////////////////////////////////////////////////// {{{ commands.addUserCommand( ["pinneditemopen", "pino"], @@ -143,9 +143,18 @@ liberator.plugins.pino.api = (function() { if (args.string == "") { let pin; let max = (args.count >= 1) ? args.count : openItemsCount(); + if (pins.items().length == 0) { + liberator.echo("Pinned item doesn't exists."); + return; + } for(let i = 0; i < max; i++) { - if (!(pin = pins.head())) break; - liberator.open(pin.link, openBehavior()); + if (!(pin = pins.shift())) + break; + setTimeout( + function(link) liberator.open(link, openBehavior()), + 200 * i, + pin.link + ); } } else { @@ -199,7 +208,7 @@ liberator.plugins.pino.api = (function() { return result.sort(this.sortOrder); }, - head : function() { + shift : function() { if (this.items().length == 0) return null; var pin = this.items().shift(); @@ -292,12 +301,14 @@ liberator.plugins.pino.api = (function() { items : function() (new Pins).items(), - head : function() - (new Pins).head(), + shift : function() + (new Pins).shift(), + + head : self.shift, // @deprecated remove : function(link) (new Pins).remove(link), - } + }; // }}} })(); // vim: ts=2 sw=2 et fdm=marker -- cgit v1.2.3