返回信息流function setup() {
commands.addUserCommand(["tw[ittperator]"], "Twittperator command",
function (arg) {
var special = arg.bang;
arg = arg.string.replace(/%URL%/g, liberator.modules.buffer.URL)
.replace(/%TITLE%/g, liberator.modules.buffer.title);
if (special && arg.match(/^\?\s*(.*)/))
showTwitterSearchResult(RegExp.$1);
else
if (special && arg.match(/^\+\s*.*#(\d+)/))
favTwitter(RegExp.$1);
else
if (special && arg.match(/^-\s*.*#(\d+)/))
unfavTwitter(RegExp.$1);
else
if (special && arg.match(/^@/))
showTwitterMentions();
else
if (special || arg.length == 0)
showFollowersStatus(arg, special);
else
sayTwitter(arg);
}, {
bang: true,
literal: 0,
completer: let (getting, targetContext) function(context, args){
function compl(){
if (args.bang && !/^[-+]/.test(args[0])){
targetContext.title = ["Name","Entry"];
list = statuses.map(function(s) ("retweeted_status" in s) ?
["@" + s.retweeted_status.user.screen_name, s.retweeted_status.text ] :
["@" + s.user.screen_name, s.text]);
} else if (/RT\s+@\w*$/.test(args[0])){
targetContext.title = ["Name + Text"];
list = statuses.map(function(s) ("retweeted_status" in s) ?
["@"+s.retweeted_status.user.screen_name+"#"+s.retweeted_status.id+": "+s.retweeted_status.text, "-" ] :
["@"+s.user.screen_name+"#"+s.id+": "+s.text, "-"]);
} else {
targetContext.title = ["Name#ID","Entry"];
list = statuses.map(function(s) ("retweeted_status" in s) ?
["@"+s.retweeted_status.user.screen_name+"#"+s.retweeted_status.id+" ", s.retweeted_status.text] :
["@"+s.user.screen_name+"#"+s.id+" ", s.text]);
}
if (target){
list = list.filter(function($_) $_[0].indexOf(target) >= 0);
}
targetContext.completions = list;
targetContext.incomplete = false;
targetContext = getting = null;
}
var matches= context.filter.match(/@(\w*)$/);
if (!matches) return;
var list = [];
var target = matches[1];
var doGet = (expiredStatus || !(statuses && statuses.length)) && autoStatusUpdate;
context.offset += matches.index;
context.incomplete = doGet;
context.hasitems = !doGet;
targetContext = context;
if (doGet) {
if (!getting) {
getting = true;
getFollowersStatus(null, compl);
}
} else {
compl();
}
}
}, true);
}
这是一条镜像帖。来源:北邮人论坛 / www-technology / #10426同步于 2010/7/23
WWWTechnology机器人发帖
一个js函数求解释
mmgroup
2010/7/23镜像同步0 回复
订阅后,新回复会通过你的通知中心匿名送达。
0 条回复
暂无回复 · 你可以订阅本帖等待新回复。