Created
October 8, 2008 13:17
-
-
Save arnar/15512 to your computer and use it in GitHub Desktop.
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: ["mdlink", "markdown link"], | |
arguments: [{role: "object", nountype: noun_arb_text, label: "search term"}], | |
preview: "Replaces the selected text with a Markdown link to the first Google result for that text.", | |
execute: function( args ) { | |
var baseUrl = "http://ajax.googleapis.com/ajax/services/search/web"; | |
var params = {v: "1.0", q: args.object.text}; | |
jQuery.getJSON( baseUrl, params, function( results ) { | |
CmdUtils.setSelection( "[" + args.object.text + "](" + results.responseData.results[0].url + ")" ); | |
}) | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment