Created
February 21, 2011 12:27
-
-
Save ricardopontes/836986 to your computer and use it in GitHub Desktop.
Comando do add-on Ubiquity (Firefox) para o encurtador toma.ai
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
| /* | |
| Criado por Ricardo Pontes (@ricardopontes) | |
| Email: [email protected] | |
| */ | |
| CmdUtils.CreateCommand({ | |
| names: ["tomai", "toma.ai"], | |
| arguments: noun_type_url, | |
| icon: 'http://toma.ai/favicon.ico', | |
| description: ("Encurte sua URL com o toma.ai."), | |
| preview: function(pblock, {object: {text}}){ | |
| if (!text) { | |
| pblock.innerHTML = this.description; | |
| return; | |
| } | |
| var shortener = this; | |
| pblock.innerHTML = _("Encurtando URL..."); | |
| CmdUtils.previewGet(pblock, this._api(text), function(tomai) { | |
| if(tomai !== "Error") | |
| pblock.innerHTML = _("Url encurtada <b>${tomai}</b>.", | |
| {tomai:shortener._link(tomai)}); | |
| }); | |
| }, | |
| execute: function(args) { | |
| var shortener = this; | |
| jQuery.get(this._api(args.object.text), function(tomai) { | |
| CmdUtils.setSelection(shortener._link(tomai), {text: tomai}); | |
| Utils.clipboard.text = tomai; | |
| }); | |
| }, | |
| _api: function(url)("http://toma.ai/encurtar.php?return_type=txt&url=" + | |
| encodeURIComponent(url)), | |
| _link: function(url) { | |
| var conteudo = Utils.escapeHtml(url); | |
| return conteudo.link(conteudo); | |
| }, | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment