Created
February 24, 2009 02:36
-
-
Save brianhanifin/69356 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({ | |
name: "snipurl", | |
synonyms: ["Snipr", "snim", "sn.im", "snurl"], | |
icon: "http://snipurl.com/site/favicon.ico", | |
description: "Replaces the selected URL with a <a href=\"http://snipr.com\">Snipr</a> 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: function( pblock, input ){ | |
pblock.innerHTML = "Replaces the selected URL with a SnipUrl shortened URL."; | |
var baseUrl = "http://sn.im/site/snip"; | |
var params = { | |
r: "simple", | |
link: input.text | |
}; | |
pblock.innerHTML = "Replaces the selected URL with ", | |
jQuery.get( baseUrl, params, function( snipUrl ) { | |
if(snipUrl != "Error") pblock.innerHTML += snipUrl; | |
}); | |
}, | |
execute: function( urlToShorten ) { | |
var baseUrl = "http://sn.im/site/snip"; | |
var params = { | |
r: "simple", | |
link: input.text | |
}; | |
jQuery.get( baseUrl, params, function( results ) { | |
CmdUtils.setSelection( results ); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment