diff options
author | mattn | 2008-04-09 11:13:29 +0000 |
---|---|---|
committer | mattn | 2008-04-09 11:13:29 +0000 |
commit | 97902d2f705724fedca485847bd709ab9b396e44 (patch) | |
tree | 52d8d7c497b043efb0817a81da8dea5b11fe0853 /twitter.js | |
parent | 413f2fea0be1bdab74aede4bf35793f9fd3db235 (diff) | |
download | vimperator-plugins-97902d2f705724fedca485847bd709ab9b396e44.tar.bz2 |
lang/javascript/vimperator-plugins/trunk/twitter.js:
* 「:twitter」だけで実行した場合はfollower statusを表示する様修正
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@9199 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'twitter.js')
-rw-r--r-- | twitter.js | 45 |
1 files changed, 43 insertions, 2 deletions
@@ -1,5 +1,5 @@ // Vimperator plugin: 'Update Twitter'
-// Last Change: 21-Mar-2008. Jan 2008
+// Last Change: 09-Apr-2008. Jan 2008
// License: Creative Commons
// Maintainer: Trapezoid <trapezoid.g@gmail.com> - http://unsigned.g.hatena.ne.jp/Trapezoid
//
@@ -13,6 +13,44 @@ xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.send("status=" + encodeURIComponent(stat));
}
+ function sprintf(format) {
+ var i = 1, re = /%s/, result = "" + format;
+ while (re.test(result) && i < arguments.length) result = result.replace(re, arguments[i++]);
+ return result;
+ }
+ function showFollowersStatus(username,password){
+ var xhr = new XMLHttpRequest();
+ xhr.open("GET","http://twitter.com/statuses/friends_timeline.json",false,username,password);
+ xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
+ xhr.send(null);
+ var followers_status = window.eval(xhr.responseText);
+
+ var html = <><![CDATA[
+ <style tyep="text/css"><!--
+ a { text-decoration: none; }
+ img { border; 0px; width: 16px; height: 16px; vertical-align: baseline; }
+ --></style>
+ ]]></>.toString().replace(/\n\s*/g, '');
+ for (var i = 0; i < followers_status.length; i++) {
+ var stat = followers_status[i];
+ html += sprintf(
+ <><![CDATA[
+ <a href="%s">
+ <img src="%s" title="%s" border="0" />
+ <strong>%s</strong>
+ </a>: <a href="%s">%s</a><br />
+ ]]></>.toString().replace(/\n\s*/g, ''),
+ "http://twitter.com/" + stat.user.screen_name,
+ stat.user.profile_image_url,
+ stat.user.name,
+ stat.user.name,
+ "http://twitter.com/" + stat.user.screen_name + "/" + stat.id,
+ stat.text
+ );
+ }
+ liberator.log(html);
+ liberator.echo(html, true);
+ }
liberator.commands.addUserCommand(['twitter'], 'Change twitter status',
function(arg,special){
var password;
@@ -32,7 +70,10 @@ .replace(/%TITLE%/g ,liberator.buffer.title);
}
- sayTwitter(username,password,arg);
+ if (!arg || arg.length == 0)
+ showFollowersStatus(username,password);
+ else
+ sayTwitter(username,password,arg);
},{ }
);
})();
|