aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--twitter.js45
1 files changed, 43 insertions, 2 deletions
diff --git a/twitter.js b/twitter.js
index b2d465d..9ab8fca 100644
--- a/twitter.js
+++ b/twitter.js
@@ -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);
},{ }
);
})();