From 0b45866de72dfe0d0f99f23f59b15161f858b334 Mon Sep 17 00:00:00 2001 From: mattn Date: Fri, 20 Jun 2008 04:18:45 +0000 Subject: 「:twitter!@」でリプライを表示する様修正 git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@14286 d0d07461-0603-4401-acd4-de1884942a52 --- twitter.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/twitter.js b/twitter.js index a0f17af..cd20f91 100644 --- a/twitter.js +++ b/twitter.js @@ -45,6 +45,33 @@ .replace(/(?:\r?\n|\r)[ \t]*/g, " "); liberator.echo(html, true); } + function showTwitterReply(username, password){ + var xhr = new XMLHttpRequest(); + xhr.open("GET", "http://twitter.com/statuses/replies.json", false, username, password); + xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); + xhr.send(null); + var statuses = window.eval(xhr.responseText); + + var html = .toSource() + .replace(/(?:\r?\n|\r)[ \t]*/g, " ") + + statuses.map(function(status) + <> + {status.user.screen_name} + {status.user.name}‬ + .toSource() + .replace(/(?:\r?\n|\r)[ \t]*/g, " ") + + sprintf(': %s‬', status.text)) + .join("
"); + + //liberator.log(html); + liberator.echo(html, true); + } function showFollowersStatus(username, password, target){ var xhr = new XMLHttpRequest(); var endPoint = target ? "http://twitter.com/statuses/user_timeline/" + target + ".json" @@ -97,6 +124,9 @@ if (special && arg.match(/^\?\s*(.*)/)) showTwitterSearchResult(RegExp.$1) else + if (special && arg.match(/^@/)) + showTwitterReply(username, password) + else if (special || arg.length == 0) showFollowersStatus(username, password, arg) else -- cgit v1.2.3