From 4ca3ee635c6624add6514b2b8a5675ef61c67813 Mon Sep 17 00:00:00 2001
From: teramako
Date: Wed, 15 Oct 2008 14:54:10 +0000
Subject: E4X化
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@21393 d0d07461-0603-4401-acd4-de1884942a52
---
haiku.js | 125 +++++++++++++++++++++++++++++++++++++--------------------------
1 file changed, 73 insertions(+), 52 deletions(-)
(limited to 'haiku.js')
diff --git a/haiku.js b/haiku.js
index 8fb60c7..e9145fd 100644
--- a/haiku.js
+++ b/haiku.js
@@ -25,7 +25,7 @@
(function(){
var passwordManager = Cc["@mozilla.org/login-manager;1"].getService(Ci.nsILoginManager);
- var CLIENT_NAME = encodeURIComponent(liberator.config.name + "::plugin::haiku.js");
+ var CLIENT_NAME = encodeURIComponent(config.name + "::plugin::haiku.js");
var evalFunc = window.eval;
var statuses = null;
try {
@@ -103,48 +103,64 @@
}
return "http://h.hatena.ne.jp/api/statuses/friends_timeline.json";
}
- function showFollowersStatus(username, password, target){
- var xhr = new XMLHttpRequest();
- var endPoint = getTimelineURLFromTarget(target);
- /*
- var endPoint = target ?
- target == "/" ?
- "http://h.hatena.ne.jp/api/statuses/public_timeline.json"
- : "http://h.hatena.ne.jp/api/statuses/user_timeline/" + target + ".json"
- : "http://h.hatena.ne.jp/api/statuses/friends_timeline.json";
- */
- xhr.open("POST", endPoint, false, username, password);
- xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
- xhr.send(null);
- statuses = evalFunc(xhr.responseText);
-
+ function statusToXML(statuses){
var html = .toSource()
- .replace(/(?:\r?\n|\r)[ \t]*/g, " ") +
- statuses.map(function(status) {
- var text = status.text;
- var keyword = status.keyword;
- var star = status.favorited > 0 ? 'x' + status.favorited + '' : '';
- if (text.indexOf(keyword+"=") == 0) text = status.text.substr(keyword.length + 1);
- text = convert(text);
- keyword = convert(keyword);
- return <>
+ ]]>;
+
+ statuses.forEach(function(status) {
+ var text = status.text;
+ var keyword = status.keyword;
+ var star = status.favorited > 0 ? <>
{'x' + status.favorited}> : <>>;
+ var replies = <>>;
+
+ if (text.indexOf(keyword+"=") == 0) text = status.text.substr(keyword.length + 1);
+ text = convert(text);
+ keyword = convert(keyword);
+
+ if (status.replies.length > 0){
+ replies =