Skip to content

Instantly share code, notes, and snippets.

@arunshivaram
Created February 7, 2009 15:04
Show Gist options
  • Save arunshivaram/59899 to your computer and use it in GitHub Desktop.
Save arunshivaram/59899 to your computer and use it in GitHub Desktop.
CmdUtils.CreateCommand({
name: "is.gd",
icon: "http://is.gd/favicon.ico",
homepage: "http://arunstechcorner.blogspot.com/2009/02/shorten-urls-in-ubiquity-with-isgd.html",
author: { name: "Arun Shivaram", email: "arunsonnet@gmail.com"},
license: "GPL",
description: "Shortens the selected URL using is.gd",
help: "is.gd <long url>",
takes: {"longurl": noun_arb_text},
preview: function( pblock, lurl ) {
pblock.innerHTML = "Replaces the selected URL with a is.gd URL";
this._shorturl(pblock,lurl,"preview");
},
execute: function(lurl) {
this._shorturl("",lurl,"execute");
},
_shorturl: function( pblock,lurl,call){
var baseUrl = "http://is.gd/api.php";
var params = {longurl: lurl.text};
jQuery.get( baseUrl, params,function(sUrl){
if (call=="preview"){
pblock.innerHTML = "Replaces the selected URL with "+sUrl;
}
if (call=="execute"){
CmdUtils.setSelection(sUrl);
CmdUtils.copyToClipboard(sUrl);
}
})
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment