Skip to content

Instantly share code, notes, and snippets.

@bogomil
Created September 7, 2009 13:00
Show Gist options
  • Save bogomil/182349 to your computer and use it in GitHub Desktop.
Save bogomil/182349 to your computer and use it in GitHub Desktop.
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