-
-
Save jadonk/48779 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: "scrabble-dictionary", | |
icon: "http://www.hasbrotoyshop.com/favicon.ico", | |
homepage: "http://www.hasbro.com/games/adult-games/scrabble/home.cfm?page=home", | |
author: { name: "Jason Kridner", email: "jkridner@gmail.com"}, | |
license: "GPL", | |
description: "Looks up letters in the Scrabble dictionary", | |
help: "provide letters to perform lookup", | |
takes: {"search term": noun_arb_text}, | |
execute: function (directObject, modifiers) | |
{ | |
var query = directObject.text; | |
// For some reason, the first entry in the postData has a '?' prepended to it. | |
var postData = { dummy: "todo-error", type: "wordbuilder", Word: query }; | |
var url = "http://www.hasbro.com/games/adult-games/scrabble/home.cfm?page=Dictionary/dict"; | |
Utils.openUrlInBrowser(url, postData); | |
CmdUtils.setLastResult(url); | |
}, | |
preview: function (pblock, directObject, modifiers) | |
{ | |
var query = directObject.text; | |
var postData = { dummy: "todo-error", type: "wordbuilder", Word: query }; | |
var url = "http://www.hasbro.com/games/adult-games/scrabble/home.cfm?page=Dictionary/dict"; | |
var content = "Performs a scrabble-dictionary search"; | |
if (query.length > 0) | |
{ | |
content += " for <b>" + query + "</b>"; | |
CmdUtils.previewGet | |
( | |
pblock, url, postData, | |
function (data) | |
{ | |
pblock.innerHTML = $('div[@id == "dict_return"]', data); | |
}, | |
"html" | |
); | |
} | |
pblock.innerHTML = content; | |
}, | |
previewDelay: 10 | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment