From 076f6c6b34b13f3fbbd2393917871e8fff4165ee Mon Sep 17 00:00:00 2001
From: anekos
Date: Tue, 4 May 2010 15:17:24 +0000
Subject: strel 補完時に、description でも絞り込みできるように
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@37365 d0d07461-0603-4401-acd4-de1884942a52
---
stella.js | 79 +++++++++++++++++++++++++++++++++++----------------------------
1 file changed, 44 insertions(+), 35 deletions(-)
diff --git a/stella.js b/stella.js
index 3511cd0..001d150 100644
--- a/stella.js
+++ b/stella.js
@@ -39,7 +39,7 @@ let PLUGIN_INFO =
すてら
For Niconico/YouTube/Vimeo, Add control commands and information display(on status line).
ニコニコ動画/YouTube/Vimeo 用。操作コマンドと情報表示(ステータスライン上に)追加します。
- 0.26.8
+ 0.27.0
anekos
new BSD License (Please read the source code comments of this plugin)
修正BSDライセンス (ソースコードのコメントを参照してください)
@@ -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 ? <>
{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 ? <>
{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 () {
--
cgit v1.2.3