Created
September 18, 2009 22:05
-
-
Save BrunoCaimar/189322 to your computer and use it in GitHub Desktop.
TFD Ubiquity command
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: "[email protected]" | |
}, | |
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