diff options
author | anekos | 2010-05-04 15:17:24 +0000 |
---|---|---|
committer | anekos | 2010-05-04 15:17:24 +0000 |
commit | 076f6c6b34b13f3fbbd2393917871e8fff4165ee (patch) | |
tree | 455c8f4b3545b2b99624b2b18ae1548171ee8c1c | |
parent | 6c6cca768f59e2b3da393f425e6f26020f6cf808 (diff) | |
download | vimperator-plugins-076f6c6b34b13f3fbbd2393917871e8fff4165ee.tar.bz2 |
strel 補完時に、description でも絞り込みできるように
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@37365 d0d07461-0603-4401-acd4-de1884942a52
-rw-r--r-- | stella.js | 79 |
1 files changed, 44 insertions, 35 deletions
@@ -39,7 +39,7 @@ let PLUGIN_INFO = <name lang="ja">すてら</name> <description>For Niconico/YouTube/Vimeo, Add control commands and information display(on status line).</description> <description lang="ja">ニコニコ動画/YouTube/Vimeo 用。操作コマンドと情報表示(ステータスライン上に)追加します。</description> - <version>0.26.8</version> + <version>0.27.0</version> <author mail="anekos@snca.net" homepage="http://d.hatena.ne.jp/nokturnalmortum/">anekos</author> <license>new BSD License (Please read the source code comments of this plugin)</license> <license lang="ja">修正BSDライセンス (ソースコードのコメントを参照してください)</license> @@ -744,8 +744,9 @@ Thanks: get command () this._command, get description () this._description, get thumbnail () this._thumbnail, - get completionItem () ({ - text: this.command, + get completionText () this.command, + completionItem: function (index) ({ + text: [this.completionText, index + ': ' + this.description], description: this.description, thumbnail: this.thumbnail }) @@ -1679,40 +1680,48 @@ Thanks: true ); - commands.addUserCommand( - ['strel[ations]'], - 'relations - Stella', - function (args) { - if (!self.isValid) - return U.raiseNotSupportedPage(); - - let arg = args.string; - let url = self.player.has('makeURL', 'x') ? makeRelationURL(self.player, arg) : arg; - liberator.open(url, args.bang ? liberator.NEW_TAB : liberator.CURRENT_TAB); - }, - { - argCount: '*', - bang: true, - completer: function (context, args) { + let (lastCompletions = []) { + commands.addUserCommand( + ['strel[ations]'], + 'relations - Stella', + function (args) { if (!self.isValid) - U.raiseNotSupportedPage(); - if (!self.player.has('relations', 'r')) - U.raiseNotSupportedFunction(); - - context.title = ['Tag/ID', 'Description']; - context.keys = {text: 'text', description: 'description', thumbnail: 'thumbnail'}; - let process = Array.slice(context.process); - context.process = [ - process[0], - function (item, text) - (item.thumbnail ? <><img src={item.thumbnail} style="margin-right: 0.5em; height: 3em;"/>{text}</> - : process[1].apply(this, arguments)) - ]; - context.completions = self.player.relations.map(function (rel) rel.completionItem); + return U.raiseNotSupportedPage(); + + let arg = args.literalArg; + let index = (/^\d+:/)(arg) && parseInt(arg, 10); + if (index > 0) + arg = lastCompletions[index - 1].command; + let url = self.player.has('makeURL', 'x') ? makeRelationURL(self.player, arg) : arg; + liberator.open(url, args.bang ? liberator.NEW_TAB : liberator.CURRENT_TAB); }, - }, - true - ); + { + literal: 0, + argCount: '*', + bang: true, + completer: function (context, args) { + if (!self.isValid) + U.raiseNotSupportedPage(); + if (!self.player.has('relations', 'r')) + U.raiseNotSupportedFunction(); + + context.title = ['Tag/ID', 'Description']; + context.keys = {text: 'text', description: 'description', thumbnail: 'thumbnail'}; + let process = Array.slice(context.process); + context.process = [ + process[0], + function (item, text) + (item.thumbnail ? <><img src={item.thumbnail} style="margin-right: 0.5em; height: 3em;"/>{text}</> + : process[1].apply(this, arguments)) + ]; + lastCompletions = self.player.relations; + context.completions = + self.player.relations.map(function (rel, index) rel.completionItem(index + 1)); + }, + }, + true + ); + } }, addPageInfo: function () { |