From 271b4c95613d9178d1b8605320b90eeb25cb4e11 Mon Sep 17 00:00:00 2001
From: teramako
Date: Wed, 21 Oct 2009 12:47:32 +0000
Subject: add completion for reply
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@35668 d0d07461-0603-4401-acd4-de1884942a52
---
twitter.js | 45 +++++++++++++++++++++++++++++++++++++++------
1 file changed, 39 insertions(+), 6 deletions(-)
diff --git a/twitter.js b/twitter.js
index f6c3490..06ca838 100644
--- a/twitter.js
+++ b/twitter.js
@@ -22,7 +22,7 @@ let PLUGIN_INFO =
{NAME}
The script allows you to update Twitter status from Vimperator
-1.0.1
+1.1.1
http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/twitter.js
Trapezoid
Creative Commons
@@ -46,7 +46,8 @@ let PLUGIN_INFO =
]]>
;
-(function(){
+liberator.modules.twitter = (function(){
+ var statuses = null;
var passwordManager = Cc["@mozilla.org/login-manager;1"].getService(Ci.nsILoginManager);
var evalFunc = window.eval;
try {
@@ -80,10 +81,19 @@ let PLUGIN_INFO =
return result.singleNodeValue ? result.singleNodeValue : null;
}
function sayTwitter(username, password, stat){
+ var sendData = '';
+ if (stat.match(/^@([^\s#]+)(?:#(\d+))\s+(.*)$/)){
+ var [replyUser, replyID] = [RegExp.$1, RegExp.$2];
+ stat = "@" + replyUser + " " + RegExp.$3;
+ sendData = "status=" + encodeURIComponent(stat) + "&in_reply_to_status_id=" + replyID;
+ } else {
+ sendData = "status=" + encodeURIComponent(stat);
+ }
+ sendData += "&source=Vimperator";
var xhr = new XMLHttpRequest();
xhr.open("POST", "https://twitter.com/statuses/update.json", false, username, password);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
- xhr.send("status=" + encodeURIComponent(stat) + "&source=Vimperator");
+ xhr.send(sendData);
liberator.echo("[Twitter] Your post " + '"' + stat + '" (' + stat.length + " characters) was sent. " );
}
function favTwitter(username, password, user){
@@ -104,7 +114,7 @@ let PLUGIN_INFO =
var xhr = new XMLHttpRequest();
xhr.open("GET", "https://twitter.com/statuses/mentions.json", false, username, password);
xhr.send(null);
- var statuses = evalFunc(xhr.responseText);
+ statuses = evalFunc(xhr.responseText);
var html =