From 77f31047e50b48e82188277e54838d54a2a2c2d1 Mon Sep 17 00:00:00 2001
From: teramako
Date: Tue, 23 Sep 2008 14:22:48 +0000
Subject: * id:... のリンク化 * post時に'\n'で改行
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@19778 d0d07461-0603-4401-acd4-de1884942a52
---
haiku.js | 26 ++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)
(limited to 'haiku.js')
diff --git a/haiku.js b/haiku.js
index 428594e..f3e71fb 100644
--- a/haiku.js
+++ b/haiku.js
@@ -39,13 +39,14 @@
function sayHaiku(username, password, stat){
var keyword = '';
if (stat.match(/^#([^ ].+)\s+(.*)$/)) [keyword, stat] = [RegExp.$1, RegExp.$2];
+ stat = stat.split("\\n").map(function(str) encodeURIComponent(str)).join("\n");
var xhr = new XMLHttpRequest();
xhr.open("POST", "http://h.hatena.ne.jp/api/statuses/update.json", false, username, password);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
if (keyword)
- xhr.send("status=" + encodeURIComponent(stat) + '&keyword=' + encodeURIComponent(keyword));
+ xhr.send("status=" + stat + '&keyword=' + encodeURIComponent(keyword));
else
- xhr.send("status=" + encodeURIComponent(stat));
+ xhr.send("status=" + stat);
}
function favHaiku(username, password, user){
var xhr = new XMLHttpRequest();
@@ -79,14 +80,17 @@
var html = .toSource()
.replace(/(?:\r?\n|\r)[ \t]*/g, " ") +
statuses.map(function(status) {
var text = status.text;
- if (text.indexOf(status.keyword+"=") == 0) text = status.text.substr(status.keyword.length + 1);
+ var keyword = status.keyword;
+ if (text.indexOf(keyword+"=") == 0) text = status.text.substr(keyword.length + 1);
text = convert(text);
+ keyword = convert(keyword);
return <>
.toSource()
.replace(/(?:\r?\n|\r)[ \t]*/g, " ") +
sprintf(': %s
%s