-
-
Save arunshivaram/59899 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: "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