Skip to content

Instantly share code, notes, and snippets.

@BrunoCaimar
Created September 18, 2009 22:05
Show Gist options
  • Save BrunoCaimar/189322 to your computer and use it in GitHub Desktop.
Save BrunoCaimar/189322 to your computer and use it in GitHub Desktop.
TFD Ubiquity command
CmdUtils.CreateCommand({
names: ["tfd"],
icon: "http://img.tfd.com/favicon.ico",
description: "Looks for a word definition on TFD (The Free Dictionary)",
help: "Looks for a word definition on TFD (The Free Dictionary)" +
"Developed by Bruno Caimar - Version 0.1.0_20090918",
author: {
name: "Bruno Caimar",
email: "bruno.caimar@gmail.com"
},
license: "MIT",
homepage: "http://brunocaimar.com/blog",
arguments: [{
role: 'object',
nountype: noun_arb_text,
label: 'Word to search the definition'
}],
preview: function preview(pblock, args) {
var template = "Search for a definition for <b style='color: lightblue'>${word}</b>"
pblock.innerHTML = CmdUtils.renderTemplate(template, {word: args.object.text});
CmdUtils.previewGet(pblock, this._api(args.object.text),
function(retorno) {
var _ret = jQuery('#MainTxt > table', retorno);
pblock.innerHTML += "<br\>" + _ret.html();
});
},
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