|
|
/**
* @author t3knomanser
*/
/* IDENTICA SECTION */
function buildIdentica() {
const LACONICA_STATUS_MAXLEN = 140;
const LACONICA_API_ROOT = "http://identi.ca/api/statuses/";
const LACONICA_ROOT = "http://identi.ca/";
//##STYLESHEET DEFINITION
//Here's where the stlyesheet is born.
const STYLESHEET = "\n";
var linkify = function(text) {
var urlRegex = /\b(((https?|ftp|irc|telnet|nntp|gopher|file):\/\/|(mailto|news|data):)[^\s\"<>\{\}\'\(\)]*)/g;
var res = text.replace(urlRegex, "$1");
return res;
};
var atify = function(text) {
var atRegex = /@([^\s\"<>\{\}\'\(\)]*)/g;
var res = text.replace(atRegex, "@$1");
return res;
};
var hashify = function(text) {
var hashRegex = /\s#([^\s\"<>\{\}\'\(\)]*)/g;
var res = text.replace(hashRegex, " #$1");
return res;
};
CmdUtils.CreateCommand({
name: "get-dents",
takes: {n: noun_arb_text},
homepage: "http://a.a.a/",
author: {name: "Remy Porter", homepage: "http://identi.ca/t3knomanser"},
license: "MPL",
preview: function(previewBlock, numPosts) {
previewBlock.innerHTML = "....."; //See, I build all these bits...
var link_start = ""; var link_end = "";
var image_template = "" + link_start + "  " + link_end +" ";
var user_cell = "" +
link_start + "${user}" + link_end + ": ";
var stat_cell = "${dent} " //And put them into a DIV container.
var dent_template = "" + user_cell + image_template + stat_cell + " ";
var num = 5;
if ((numPosts) && isNumeric(numPosts.text) && numPosts.text.length > 0) { num = numPosts.text; } else { num = 5; }
var updateURL;
updateURL = LACONICA_API_ROOT + "friends_timeline.xml?count=" + num;
jQuery.ajax({
type: "GET",
url: updateURL,
success: function(xml) {
var body = ""; var count = 0;
jQuery("status", xml).each(function() {
body += CmdUtils.renderTemplate(dent_template,
{user:jQuery("screen_name", this).text(),
dent:atify(hashify(linkify(jQuery("text", this).text()))),
imageUrl:jQuery("profile_image_url", this).text(),
color:(count%2==0)?"#222277":"#222244"}
);
count+=1;
});
previewBlock.innerHTML = STYLESHEET + body; //And output it. But the DIV is the size BEFORE the relative positioning takes effect, not after. That's my problem.
//The container DIV is bigger than it needs to be.
},
error: function() {displayMessage("Failed getting dents."); }
});
},
execute: function() {}
});
};
buildIdentica();
|