Created
July 20, 2009 17:28
-
-
Save endolith/150462 to your computer and use it in GitHub Desktop.
My test commands
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
| // 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