Wrap text
Report abuse
const LACONICA_STATUS_MAXLEN = 140;
const LACONICA_ROOT = "http://identi.ca/api/statuses/";
CmdUtils.CreateCommand({
name: "identica",
takes: {status: noun_arb_text},
root: "http://identi.ca/api/statuses/",
homepage: "http://theunfocused.net/moz/ubiquity/verbs/",
author: {name: "Blair McBride; Find and replaced by Remy Porter", homepage: "http://theunfocused.net/"},
license: "MPL",
preview: function(previewBlock, statusText) {
var previewTemplate = "Updates your Identi.ca status to:
" +
"${status}
" +
"Characters remaining: ${chars}";
var truncateTemplate = "
The last ${truncate} " +
"characters will be truncated!";
var previewData = {
status: statusText.text,
chars: LACONICA_STATUS_MAXLEN - statusText.text.length
};
var previewHTML = CmdUtils.renderTemplate(previewTemplate,
previewData);
if(previewData.chars < 0) {
var truncateData = {
truncate: 0 - previewData.chars
};
previewHTML += CmdUtils.renderTemplate(truncateTemplate,
truncateData);
}
previewBlock.innerHTML = previewHTML;
},
execute: function(statusText) {
if(statusText.text.length < 1) {
displayMessage("Identi.ca requires a status to be entered");
return;
}
var updateUrl = LACONICA_ROOT + "update.json";
var updateParams = {
source: "ubiquity",
status: statusText.text.substring(0,140)
};
jQuery.ajax({
type: "POST",
url: updateUrl,
data: updateParams,
dataType: "json",
error: function() {
displayMessage("Identi.ca error - status not updated");
},
success: function() {
displayMessage("Identi.ca status updated");
}
});
}
});
CmdUtils.CreateCommand({
name: "get-dents",
//takes: {num_posts: noun},
homepage: "http://theunfocused.net/moz/ubiquity/verbs/",
author: {name: "Remy Porter", homepage: "http://identi.ca/t3knomanser"},
license: "MPL",
preview: function(previewBlock) {
var dent_template = " | " +
"${user}: | ${dent} |
";
//previewBlock.innerHTML = "" + CmdUtils.renderTemplate(dent_template, {user:"Joebob",status:"Testing dent"}) + "
";
var numPosts = 10;
var updateURL;
updateURL = LACONICA_ROOT + "friends_timeline.xml?count=" + numPosts;
jQuery.ajax({
type: "GET",
url: updateURL,
success: function(xml) {
var body = "";
jQuery("status", xml).each(function() {
body += CmdUtils.renderTemplate(dent_template,
{user:jQuery("screen_name", this).text(),
dent:jQuery("text", this).text(),
imageUrl:jQuery("profile_image_url", this).text()}
);
});
previewBlock.innerHTML = "
";
},
error: function() {displayMessage("Failed getting dents."); }
});
}
});