From 3016485c434b60bf2b4e8ad12fbb41fd1a37771a Mon Sep 17 00:00:00 2001
From: Rex Tsai
Date: Sun, 29 Nov 2009 19:37:06 +0800
Subject: [PATCH] fixed for Ubiquity Parser 2 API.
---
hellotxt.js | 75 +++++++++++++++++++++++++++++------------------------------
1 files changed, 37 insertions(+), 38 deletions(-)
diff --git a/hellotxt.js b/hellotxt.js
index 15d5487..4198e4f 100644
--- a/hellotxt.js
+++ b/hellotxt.js
@@ -1,15 +1,15 @@
const HELLOTXT_STATUS_MAXLEN = 140;
CmdUtils.CreateCommand({
- name: "hellotxt",
- takes: {status: noun_arb_text},
+ name: ["hellotxt"],
+ arguments: [ {role: 'object', nountype: noun_arb_text, label: 'status'} ],
homepage: "http://hellotxt.com/help/ubiquity",
author: {name: "Fabrizio Giordano", homepage: "http://hellotxt.com/"},
license: "MPL",
- description: "Update your status via HelloTxt",
- help: 'Update your Status via HelloTxt."',
+ description: _("Update your status via HelloTxt"),
+ help: _('Update your Status via HelloTxt."'),
user_key: function() {
var key = Application.prefs.getValue("HelloTxt API key", "");
@@ -17,14 +17,15 @@ CmdUtils.CreateCommand({
else {return null;}
},
- preview: function(previewBlock, statusText) {
+ preview: function(previewBlock, args) {
var key = this.user_key();
+ var statusText = args.object.text;
if (key != null) {
- var previewTemplate = "Posts this to HelloTxt:
" +
- "${status}
" +
- "Characters remaining: ${chars}";
- var truncateTemplate = "
Some services have a 140 character limit, which we need to respect. The last ${truncate} " +
- "characters will be truncated!";
+ var previewTemplate = _("Posts this to HelloTxt:
") +
+ _("${status}
") +
+ _("Characters remaining: ${chars}");
+ var truncateTemplate = _("
Some services have a 140 character limit, which we need to respect. The last ${truncate} ") +
+ _("characters will be truncated!");
var previewData = {
status: statusText.text,
chars: HELLOTXT_STATUS_MAXLEN - statusText.text.length
@@ -42,17 +43,18 @@ CmdUtils.CreateCommand({
previewBlock.innerHTML = previewHTML;
}
else {
- previewBlock.innerHTML = "Please set your HelloTxt Key for this application with the \"hellotxt-key\" command before using this.";
+ previewBlock.innerHTML = _("Please set your HelloTxt Key for this application with the \"hellotxt-key\" command before using this.");
}
},
- execute: function(statusText) {
+ execute: function(args) {
+ var statusText = args.object;
if(this.user_key() == null) {
- displayMessage("HelloTxt Key for this application is required to be able to post. Use the \"hellotxt-key\" command to set it.");
+ displayMessage(_("HelloTxt Key for this application is required to be able to post. Use the \"hellotxt-key\" command to set it."));
return;
}
if(statusText.text.length < 1) {
- displayMessage("Status have to contain at least 3 characters.");
+ displayMessage(_("Status have to contain at least 3 characters."));
return;
}
@@ -66,40 +68,39 @@ CmdUtils.CreateCommand({
jQuery.post(updateUrl,updateParams,
function(data) {
+ CmdUtils.log(data);
- CmdUtils.log(data);
-
- var response = data.documentElement.getAttribute("status");
- if (response == "OK") { displayMessage("Status Updated!"); }
- else { displayMessage("Sorry, something didn't happen right. Your status could not be updated. Try again?"); }
+ var response = data.documentElement.getAttribute("status");
+ if (response == "OK") { displayMessage("Status Updated!"); }
+ else { displayMessage(_("Sorry, something didn't happen right. Your status could not be updated. Try again?")); }
}, "xml");
}
});
CmdUtils.CreateCommand({
- name: "hellotxt-key",
- takes: {app_key: noun_arb_text},
+ name: ["hellotxt-key"],
+ arguments: [ {role: 'object', nountype: noun_arb_text, label: 'app_key'} ],
homepage: "http://hellotxt.com/help/ubiquity",
author: {name: "Fabrizio Giordano", homepage: "http://hellotxt.com/"},
license: "MPL",
- description: "Saves your HelloTxt Key for this application",
- help: 'To set your key, select it and use the command, "hellotxt-key this" or use "hellotxt-key [paste your key here]."',
+ description: _("Saves your HelloTxt Key for this application"),
+ help: _('To set your key, select it and use the command, "hellotxt-key this" or use "hellotxt-key [paste your key here]."'),
preview: function(previewBlock) {
var key = Application.prefs.getValue("HelloTxt API key", "");
- if (key != "") { previewBlock.innerHTML = "Your currently saved HelloTxt Key for this application is:
" + Application.prefs.getValue("HelloTxt API key", ""); }
- else { previewBlock.innerHTML = "Your HelloTxt Key for this application is currently not saved in this application. Set it by selecting the key from http://hellotxt.com/settings/api/ubiquity and using the command, \"hellotxt-key this\" or use \"hellotxt-key [paste your key here]."; }
+ if (key != "") { previewBlock.innerHTML = _("Your currently saved HelloTxt Key for this application is:
") + Application.prefs.getValue("HelloTxt API key", ""); }
+ else { previewBlock.innerHTML = _("Your HelloTxt Key for this application is currently not saved in this application. Set it by selecting the key from http://hellotxt.com/settings/api/ubiquity and using the command, \"hellotxt-key this\" or use \"hellotxt-key [paste your key here]."); }
},
validate_key: function(key) {
return true;
},
- execute: function(key) {
+ execute: function(args) {
var updateUrl = "http://hellotxt.com/api/v1/method/user.validate";
- var key = key.text;
+ var key = args.object.text;
if ( this.validate_key(key) )
{
@@ -112,32 +113,30 @@ CmdUtils.CreateCommand({
response = data.documentElement.getAttribute("status");
if (response == "OK"){
Application.prefs.setValue("HelloTxt API key", key);
- displayMessage("Great, your key has been set. You can now post to HelloTxt");
+ displayMessage(_("Great, your key has been set. You can now post to HelloTxt"));
}
else{
- displayMessage("Hmm, the key doesn't seem to be valid. Confirm it from http://hellotxt.com/settings/api/ubiquity");
+ displayMessage(_("Hmm, the key doesn't seem to be valid. Confirm it from http://hellotxt.com/settings/api/ubiquity"));
}
}, "xml");
}
else {
- displayMessage("The key is not valid in format. Confirm it from http://hellotxt.com/settings/api/ubiquity");
+ displayMessage(_("The key is not valid in format. Confirm it from http://hellotxt.com/settings/api/ubiquity"));
}
}
});
CmdUtils.CreateCommand({
- name: "hellotxt-key-clear",
- //takes: {app_key: noun_arb_text},
-
+ name: ["hellotxt-key-clear"],
homepage: "http://hellotxt.com/help/ubiquity",
author: {name: "Fabrizio Giordano", homepage: "http://hellotxt.com/"},
license: "MPL",
- description: "Clears your saved HelloTxt API key from this application",
- help: 'This command will clear your saved HelloTxt API key from this application. If you have not yet set your key, select it and use the command, "hellotxt-key this" or use "hellotxt-key [paste your key here]."',
+ description: _("Clears your saved HelloTxt API key from this application"),
+ help: _('This command will clear your saved HelloTxt API key from this application. If you have not yet set your key, select it and use the command, "hellotxt-key this" or use "hellotxt-key [paste your key here]."'),
preview: function(previewBlock) {
- previewBlock.innerHTML = "This command will clear your saved HelloTxt API key from this application.";
+ previewBlock.innerHTML = _("This command will clear your saved HelloTxt API key from this application.");
},
execute: function() {
@@ -145,10 +144,10 @@ CmdUtils.CreateCommand({
if (key != "") {
Application.prefs.setValue("HelloTxt API key", "");
- displayMessage("Your HelloTxt API key has been cleared from this application.");
+ displayMessage(_("Your HelloTxt API key has been cleared from this application."));
}
else {
- displayMessage("Your HelloTxt API is currently not saved in this application.");
+ displayMessage(_("Your HelloTxt API is currently not saved in this application."));
}
},
});
--
1.6.5.2