Skip to content

Instantly share code, notes, and snippets.

@BrunoCaimar
Created September 18, 2009 22:46
Show Gist options
  • Save BrunoCaimar/189335 to your computer and use it in GitHub Desktop.
Save BrunoCaimar/189335 to your computer and use it in GitHub Desktop.
TFD Thesaurus ubiquity command
CmdUtils.CreateCommand({
names: ["thesaurus", "tfdThesaurus"],
icon: "http://img.tfd.com/favicon.ico",
description: "Looks for synonyms on TFD (The Free Dictionary)",
help: "Looks for synonyms on TFD (The Free Dictionary)" + "Developed by Bruno Caimar - Version 0.1.0_20090918",
author: {
name: "Bruno Caimar",
email: "[email protected]"
},
license: "MIT",
homepage: "http://brunocaimar.com/blog",
arguments: [{
role: 'object',
nountype: noun_arb_text,
label: 'Word to search synonyms'
}],
preview: function preview(pblock, args) {
var template = "Search for synonyms <b style='color: lightblue'>${word}</b>"
if (Utils.trim(args.object.text) !== "") {
pblock.innerHTML = CmdUtils.renderTemplate(template, {
word: args.object.text
});
CmdUtils.previewGet(pblock, this._api(args.object.text), function (retorno) {
var _ret = jQuery('#Thesaurus', retorno);
if (_ret.length > 0) {
pblock.innerHTML += "<br\>" + _ret.html();
} else {
var _err = jQuery('table', retorno);
pblock.innerHTML += "<br\>" + _err[1].parentNode.parentNode.innerHTML;
}
});
}
},
execute: function execute(args) {
Utils.openUrlInBrowser(this._api(args.object.text));
},
_api: function (url)("http://tfd.com/" + encodeURIComponent(url)),
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment