Skip to content

Instantly share code, notes, and snippets.

@endolith
Created July 20, 2009 17:28
Show Gist options
  • Select an option

  • Save endolith/150462 to your computer and use it in GitHub Desktop.

Select an option

Save endolith/150462 to your computer and use it in GitHub Desktop.
My test commands
// Search for synonyms of a word using thesaurus.com
// Should probably create an actual list of words and remove any duplicates, alphabetize them, etc.
CmdUtils.CreateCommand({
names: ["thesaurus", "synonyms of"],
homepage: "http://www.zacharyspencer.com/",
author: { name: "Zachary Spencer", email: "[email protected]"},
contributors: ["Zachary Spencer"],
license: "MPL",
arguments: [{role: "object",
nountype: noun_arb_text,
label: "word"}],
preview: function (pblock, wordParam) {
word = wordParam.object.text
pblock.innerHTML = "Searching for " + word + ' on <b><a href="http://thesaurus.com">thesaurus.com...</a></b>';
url = "http://thesaurus.reference.com/search";
params = {q: word};
previewTemplate = this.previewTemplate;
jQuery.get(url, params, function (htmlData){
pblock.innerHTML = "";
var doc = context.focusedWindow.document;
var domDiv = doc.createElement( "div" );
domDiv.innerHTML = htmlData;
content = jQuery(".the_content > tbody > tr:last-child > td:last-child > span", domDiv);
if (content.length == 0){
pblock.innerHTML += "No direct matches.<br> <b>Hit enter for suggested alternative searches...</b>";
return;
}
for(var i =0; i< content.length; i++){
pblock.innerHTML += content.eq(i).html() + ",";
}
pblock.innerHTML += "<br> <b>Hit enter for more information...</b>";
});
},
execute: function( word ) {
Utils.openUrlInBrowser('http://thesaurus.reference.com/browse/' + word.object.text);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment