Yes, Mozilla Ubiquity does rock. However, having no API to your site does not rock. It is the exact opposite of rock, in fact!
function __searchMetaCritic(pblock, searchText) {
jQuery.get("http://www.metacritic.com/search/process?sb=0&tfs=all&ty=3&x=0&y=0&ts=" + escape(searchText),
function(response) {
var resultsREGXP = /\[0-9]\.(.*)\<\/p\>/gmi;
var results = response.match(resultsREGXP);
found = true;
if (results == null) {
var msg = 'No results for "${what}"';
var subs = {what: searchText};
pblock.innerHTML = CmdUtils.renderTemplate( msg, subs );
return;
}
var tempElement = CmdUtils.getHiddenWindow().document.createElementNS("http://www.w3.org/1999/xhtml", "div");
tempElement.innerHtml = '<link href="http://www.metacritic.com/general.css" rel="stylesheet" type="text/css">';
tempElement.innerHtml = tempElement.innerHtml + results.join('');
var msg = 'Searching for "${what}"
${results}';
var subs = {what: searchText, results: tempElement.innerHtml};
pblock.innerHTML = CmdUtils.renderTemplate( msg, subs );
});
}
CmdUtils.CreateCommand({
name: "metacritic",
takes: {"what": noun_arb_text},
preview: function(pblock, what) {
__searchMetaCritic(pblock, what.text);
var msg = 'Searching for "${what}"';
var subs = {what: what.text};
pblock.innerHTML = CmdUtils.renderTemplate( msg, subs );
},
execute: function(what) { __searchMetaCritic(what); }
});
1 comment:
Hey, hows it going? I'm attempting to surf the web and find a variety of Ubiquity coders. I'm noticing allot of people are sharing there scripts. If you would like you are welcome to use our site at www.cipherhive.org . You can upload your javascript to folder and then put the link in a html block. That way when someone wants to install your script they can just view your page and opt to install it. We are fairly new so we are starting with what ever coders we can find to build the site up. Let me know what you think if you check it out. here is the Ubiquity tutorial...
http://www.cipherhive.org/course/view.php?id=19
Make sure to briefly review the Course Making Tutorial First just to learn how to add html blocks. It a no brainer and uses a simple gui.
http://www.cipherhive.org/course/view.php?id=11
V/r
Jason Mansfield
Post a Comment