-
-
Save bogomil/182349 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({ | |
names: ["smali", "смали"], | |
arguments: noun_type_url, | |
description: ("Заменя вашия URL с по-къс, за по-лесно споделяне."), | |
homepage: "http://www.bogomil.info/", | |
author: {name: "Bogomil Shopov", email: "[email protected]"}, | |
license: "GPL", | |
preview: function(pblock, {object: {text}}){ | |
if (!text) { | |
pblock.innerHTML = this.description; | |
return; | |
} | |
var me = this; | |
pblock.innerHTML = _("Заменяме вашият дълъг URL с този..."); | |
CmdUtils.previewGet(pblock, this._api(text), function(smalimeurl) { | |
if(smalimeurl !== "Error") | |
pblock.innerHTML = _("Заменяме вашият дълъг URL с този по-къс:<b>${smalimeurl}</b>.", | |
{smalimeurl:me._link(smalimeurl)}); | |
}); | |
}, | |
execute: function(args) { | |
var me = this; | |
jQuery.get(this._api(args.object.text), function(smalimeurl) { | |
CmdUtils.setSelection(me._link(smalimeurl), {text: smalimeurl}); | |
Utils.clipboard.text = smalimeurl; | |
}); | |
}, | |
_api: function(url)("http://smali.me/api.php?longurl=" + | |
encodeURIComponent(url)), | |
_link: function(url) { | |
var eu = Utils.escapeHtml(url); | |
return eu.link(eu); | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment