aboutsummaryrefslogtreecommitdiffstats
path: root/twittperator.js
diff options
context:
space:
mode:
authoranekos2010-07-31 05:12:49 +0000
committeranekos2010-07-31 05:12:49 +0000
commit210ff71279ab6be279883e806c7fabb2a716a075 (patch)
tree81eb249e9580d48ff2ff32dec03f1fffdeab2148 /twittperator.js
parent1e6106aeef9b49db9889e55b7a29c38dbd6e76da (diff)
downloadvimperator-plugins-210ff71279ab6be279883e806c7fabb2a716a075.tar.bz2
補完関数を移動
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@38067 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'twittperator.js')
-rwxr-xr-xtwittperator.js100
1 files changed, 48 insertions, 52 deletions
diff --git a/twittperator.js b/twittperator.js
index b7e7ecc..f0a7f8e 100755
--- a/twittperator.js
+++ b/twittperator.js
@@ -1374,8 +1374,52 @@ function ReTweet(id) { // {{{
});
} // }}}
function setup() { // {{{
- let SubCommands = [
- ];
+ function commandCompelter(context, args) {
+ function statusObjectFilter(item)
+ let (desc = item.description)
+ (this.match(desc.user.screen_name) || this.match(desc.text));
+
+ context.createRow = function(item, highlightGroup) {
+ let desc = item[1] || this.process[1].call(this, item, item.description);
+
+ if (desc && desc.user) {
+ return <div highlight={highlightGroup || "CompItem"} style="white-space: nowrap">
+ <li highlight="CompDesc">
+ <img src={desc.user.profile_image_url} style="max-width: 24px; max-height: 24px"/>
+ &#160;{desc.user.screen_name}: {desc.text}
+ </li>
+ </div>;
+ }
+
+ return <div highlight={highlightGroup || "CompItem"} style="white-space: nowrap">
+ <li highlight="CompDesc">{desc}&#160;</li>
+ </div>;
+ };
+
+ if (args.bang && !/^[-+]/.test(args[0])) {
+ context.title = ["Name","Entry"];
+ list = history.map(function(s) ("retweeted_status" in s) ?
+ ["@" + s.retweeted_status.user.screen_name, s] :
+ ["@" + s.user.screen_name, s]);
+ } else if (/(?:^|\b)RT\s+@[A-Za-z0-9_]{1,15}$/.test(args[0])) {
+ context.title = ["Name + Text"];
+ list = history.map(function(s) ("retweeted_status" in s) ?
+ ["@" + s.retweeted_status.user.screen_name + "#" + s.retweeted_status.id +
+ ": " + s.retweeted_status.text, s] :
+ ["@" + s.user.screen_name + "#" + s.id + ": " + s.text, s]);
+ } else {
+ context.title = ["Name#ID","Entry"];
+ list = history.map(function(s) ("retweeted_status" in s) ?
+ ["@" + s.retweeted_status.user.screen_name + "#" + s.retweeted_status.id + " ", s] :
+ ["@" + s.user.screen_name+"#" + s.id + " ", s]);
+ }
+
+ context.completions = list;
+ context.filters = [statusObjectFilter];
+ context.incomplete = false;
+ context = getting = null;
+ }
+
commands.addUserCommand(["tw[ittperator]"], "Twittperator command",
function(args) {
@@ -1403,57 +1447,9 @@ function setup() { // {{{
bang: true,
literal: 0,
completer: let (getting, targetContext) function(context, args) {
- function filter (item)
- let (desc = item.description)
- (this.match(desc.user.screen_name) || this.match(desc.text));
-
- function compl() {
- targetContext.createRow = function(item, highlightGroup) {
- let desc = item[1] || this.process[1].call(this, item, item.description);
-
- if (desc && desc.user) {
- return <div highlight={highlightGroup || "CompItem"} style="white-space: nowrap">
- <li highlight="CompDesc">
- <img src={desc.user.profile_image_url} style="max-width: 24px; max-height: 24px"/>
- &#160;{desc.user.screen_name}: {desc.text}
- </li>
- </div>;
- }
-
- return <div highlight={highlightGroup || "CompItem"} style="white-space: nowrap">
- <li highlight="CompDesc">{desc}&#160;</li>
- </div>;
- };
-
- if (args.bang && !/^[-+]/.test(args[0])) {
- targetContext.title = ["Name","Entry"];
- list = history.map(function(s) ("retweeted_status" in s) ?
- ["@" + s.retweeted_status.user.screen_name, s] :
- ["@" + s.user.screen_name, s]);
- } else if (/(?:^|\b)RT\s+@[A-Za-z0-9_]{1,15}$/.test(args[0])) {
- targetContext.title = ["Name + Text"];
- list = history.map(function(s) ("retweeted_status" in s) ?
- ["@" + s.retweeted_status.user.screen_name + "#" + s.retweeted_status.id +
- ": " + s.retweeted_status.text, s] :
- ["@" + s.user.screen_name + "#" + s.id + ": " + s.text, s]);
- } else {
- targetContext.title = ["Name#ID","Entry"];
- list = history.map(function(s) ("retweeted_status" in s) ?
- ["@" + s.retweeted_status.user.screen_name + "#" + s.retweeted_status.id + " ", s] :
- ["@" + s.user.screen_name+"#" + s.id + " ", s]);
- }
-
- if (target)
- list = list.filter(function($_) $_[0].indexOf(target) >= 0);
- targetContext.completions = list;
- targetContext.incomplete = false;
- targetContext = getting = null;
- }
-
let matches = context.filter.match(/@([A-Za-z0-9_]{0,15})$/);
if (!matches) return;
let list = [];
- let target = matches[1];
let doGet = (expiredStatus || !(history && history.length)) && autoStatusUpdate;
context.offset += matches.index;
@@ -1463,10 +1459,10 @@ function setup() { // {{{
if (doGet) {
if (!getting) {
getting = true;
- getFollowersStatus(null, compl);
+ getFollowersStatus(null, function () commandCompelter(context, args));
}
} else {
- compl();
+ commandCompelter(context, args);
}
}
}, true);