aboutsummaryrefslogtreecommitdiffstats
path: root/twitter.js
diff options
context:
space:
mode:
authordrry2008-04-09 17:40:36 +0000
committerdrry2008-04-09 17:40:36 +0000
commitf75a7728bb3c3c8191f74ef57574391ee72f6760 (patch)
tree6d912eb7183993324149959c2e60f79cb0c9ddb2 /twitter.js
parentcb274a60ac6596a215fa83c7eb2695f4bac3784a (diff)
downloadvimperator-plugins-f75a7728bb3c3c8191f74ef57574391ee72f6760.tar.bz2
lang/javascript/vimperator-plugins/trunk/twitter.js:
* fixed a typo "tyep". * et cetera... git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@9229 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'twitter.js')
-rw-r--r--twitter.js75
1 files changed, 37 insertions, 38 deletions
diff --git a/twitter.js b/twitter.js
index 680734f..60dd987 100644
--- a/twitter.js
+++ b/twitter.js
@@ -3,78 +3,77 @@
// License: Creative Commons
// Maintainer: Trapezoid <trapezoid.g@gmail.com> - http://unsigned.g.hatena.ne.jp/Trapezoid
//
-// update twitter status script for vimperator0.6.*
+// update Twitter status script for Vimperator 0.6.*
(function(){
var passwordManager = Cc["@mozilla.org/login-manager;1"].getService(Ci.nsILoginManager);
- function sayTwitter(username,password,stat){
+ function sayTwitter(username, password, stat){
var xhr = new XMLHttpRequest();
- xhr.open("POST","http://twitter.com/statuses/update.json",false,username,password);
+ xhr.open("POST", "http://twitter.com/statuses/update.json", false, username, password);
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){
+ //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.open("GET", "http://twitter.com/statuses/friends_timeline.json", false, username, password);
// for debug
- //xhr.open("GET","http://twitter.com/statuses/user_timeline/otsune.json",false,username,password);
+ //xhr.open("GET", "http://twitter.com/statuses/user_timeline/otsune.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"><!--
+ <style type="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];
+ ]]></>.toString()
+ .replace(/(?:\r?\n|\r)\s*/g, '');
+ followers_status.forEach(function(stat){
stat.user.name += "\u202c";
stat.text += "\u202c";
- html += sprintf(
- <><![CDATA[
- <img src="%s" title="%s" border="0" />
- <strong>%s</strong>
- : %s<br />
- ]]></>.toString().replace(/\n\s*/g, ''),
- stat.user.profile_image_url,
- stat.user.screen_name,
- stat.user.name,
- stat.text
- );
- }
- liberator.log(html);
+ html += <><![CDATA[
+ <img src={stat.user.profile_image_url}
+ title={stat.user.screen_name}
+ border="0"/>
+ <strong>{stat.user.name}</strong>
+ : {stat.text}<br/>
+ ]]></>.toString()
+ .replace(/(?:\r?\n|\r)\s*/g, '');
+ });
+ liberator.log(html);
liberator.echo(html, true);
}
- liberator.commands.addUserCommand(['twitter'], 'Change twitter status',
- function(arg,special){
+ liberator.commands.addUserCommand(['twitter'], 'Change Twitter status',
+ function(arg, special){
var password;
var username;
try {
var logins = passwordManager.findLogins({}, 'http://twitter.com', 'https://twitter.com', null);
- if(logins.length)
+ if (logins.length)
[username, password] = [logins[0].username, logins[0].password];
else
- liberator.echoerr("Twitter: account not found");
+ throw "Twitter: account not found";
}
- catch(ex) {
+ catch (ex){
+ liberator.echoerr(ex);
}
- if(special){
+ if (special){
arg = arg.replace(/%URL%/g, liberator.buffer.URL)
- .replace(/%TITLE%/g ,liberator.buffer.title);
+ .replace(/%TITLE%/g, liberator.buffer.title);
}
if (!arg || arg.length == 0)
- showFollowersStatus(username,password);
+ showFollowersStatus(username, password);
else
- sayTwitter(username,password,arg);
- },{ }
+ sayTwitter(username, password, arg);
+ }, { }
);
})();
+// vim:sw=4 ts=4 et: