Skip to content

Instantly share code, notes, and snippets.

@sealence sealence/gist:718941
Created Nov 28, 2010

Embed
What would you like to do?
Ubiquity:iciba
CmdUtils.CreateCommand({
names: ["iciba"],
description: "A short description of your command.",
help: "How to use your command.",
author: {
name: "sealence",
email: "sealence@gmail.com",
homepage: "http://labs.mozilla.com/",
},
license: "GPL",
homepage: "http://ubiquity.mozilla.com/",
icon: "http://www.iciba.com/favicon.ico",
arguments: [{role: "object", nountype: noun_arb_text, label: "text"}],
baseurl: "http://www.iciba.com/",
execute: function execute(args) {
var input = Utils.trim(args.object.text);
var url = this.baseurl + encodeURIComponent(input);
Utils.openUrlInBrowser(url);
},
preview: function preview(pblock, args) {
var input = args.object.text;
var url = this.baseurl + encodeURIComponent(input);
jQuery.get(url, function(data){
if (!data) {return;}
var word = jQuery('#word_name', data).text();
var prons = jQuery('#word_top span:not(.font_black.marginleft5)', data).text();
var def = jQuery('#sentence_open', data).html();
var pre_template = "\
<style> \
#container {background-color: #595A5F; margin: 10pt; padding 5pt;} \
#word {background-color: #3399CC; font-family: arial black; font-size: x-large; padding: 3pt;} \
#explanation {font-size: medium; font-family: tahoma;padding:3px 0;} \
</style> \
<div id=\"container\"> \
<div id=\"word\">${w.word} (${w.prons})</div> \
<div id=\"explanation\">${w.def}</div> \
</div>";
var foobar = {
word : word,
prons : prons,
def : def
};
pblock.innerHTML = CmdUtils.renderTemplate(pre_template, {
w:foobar
});
});
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.