CmdUtils.CreateCommand({ name: "is.gd", icon: "http://is.gd/favicon.ico", homepage: "http://arunstechcorner.blogspot.com", author: { name: "Arun Shivaram", email: "arunsonnet@gmail.com"}, license: "GPL", description: "Shortens the selected URL using is.gd", help: "is.gd ", 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); } }) } });