Skip to content

Instantly share code, notes, and snippets.

@brianhanifin
Created February 24, 2009 02:37
Show Gist options
  • Save brianhanifin/69358 to your computer and use it in GitHub Desktop.
Save brianhanifin/69358 to your computer and use it in GitHub Desktop.
CmdUtils.CreateCommand({
name: "trim",
synonyms: ["tr.im"],
icon: "http://tr.im/favicon.ico",
description: "Replaces the selected URL with a <a href=\"http://tr.im\">tr.im</a> shortened URL.",
//help: "how to use your command",
homepage: "http://code.brianhanifin.com/",
author: { name: "Brian J. Hanifin", email: "[email protected]"},
license: "GPL",
takes: {"input": noun_type_url},
preview: "Replaces the selected URL with a shortened tr.im URL.",
execute: function( input ) {
var baseUrl = "http://tr.im/api/trim_url.json";
var params = {
url: input.text
};
jQuery.get( baseUrl, params, function( results ) {
results = Utils.decodeJson( results );
CmdUtils.setSelection( results.url );
})
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment