-
-
Save jadonk/48771 to your computer and use it in GitHub Desktop.
This file contains 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({ | |
name: "s2", | |
icon: "http://www.hasbrotoyshop.com/favicon.ico", | |
searchURL: "http://www.hasbro.com/games/adult-games/scrabble/home.cfm?page=Dictionary/dict", | |
description: "Searches Hasbro's Scrabble dictionary for words that use your letters.", | |
takes: {"keywords": noun_arb_text}, | |
modifiers: {"in": noun_arb_text }, | |
execute: function(keywords, modifiers) { | |
var query = this.buildQuery(keywords,modifiers); | |
Utils.openUrlInBrowser( this.searchURL, query ); | |
}, | |
preview: function(pblock, keywords, modifiers) { | |
var query = this.buildQuery(keywords,modifiers); | |
if(query.length < 1) { | |
pblock.innerHTML = this.description; | |
return; | |
} | |
var pTemplate = "Searches Hasbro's Scrabble dictionary for <b>${query}</b>"; | |
var pData = {query: query.Word }; | |
pblock.innerHTML = CmdUtils.renderTemplate(pTemplate, pData); | |
var url = "http://www.hasbro.com/games/adult-games/scrabble/home.cfm?page=Dictionary/dict"; | |
//var params = { v: "1.0", q: query }; | |
CmdUtils.previewGet( pblock, url, query, function(data) { | |
var numToDisplay = 3; | |
//var results = data.responseData.results.splice( 0, numToDisplay ); | |
//var format = ''; | |
//pblock.innerHTML = CmdUtils.renderTemplate( format, {results:results, searchTerm:query}); | |
pblock.innerHTML = data; //$('div[@id == "dict_return"]', data); | |
}, "html"); | |
}, | |
buildQuery: function(keywords, modifiers) | |
{ | |
return { dummy: "todo-error", type: "wordbuilder", Word: keywords.text, length: keywords.text.length }; | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment