diff options
author | mattn | 2008-06-20 04:18:45 +0000 |
---|---|---|
committer | mattn | 2008-06-20 04:18:45 +0000 |
commit | 0b45866de72dfe0d0f99f23f59b15161f858b334 (patch) | |
tree | 9f26a693a11c40fe709b4f603695fce15c4529d2 /twitter.js | |
parent | a4bab7e91d733e8f5909633aa302730b46295325 (diff) | |
download | vimperator-plugins-0b45866de72dfe0d0f99f23f59b15161f858b334.tar.bz2 |
「:twitter!@」でリプライを表示する様修正
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@14286 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'twitter.js')
-rw-r--r-- | twitter.js | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -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 = <style type="text/css"><![CDATA[
+ span.twitter.entry-content a { text-decoration: none; }
+ img.twitter.photo { border; 0px; width: 16px; height: 16px; vertical-align: baseline; }
+ ]]></style>.toSource()
+ .replace(/(?:\r?\n|\r)[ \t]*/g, " ") +
+ statuses.map(function(status)
+ <>
+ <img src={status.user.profile_image_url}
+ alt={status.user.screen_name}
+ title={status.user.screen_name}
+ class="twitter photo"/>
+ <strong>{status.user.name}‬</strong>
+ </>.toSource()
+ .replace(/(?:\r?\n|\r)[ \t]*/g, " ") +
+ sprintf(': <span class="twitter entry-content">%s‬</span>', status.text))
+ .join("<br/>");
+
+ //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
|