Skip to content

Instantly share code, notes, and snippets.

@bogomil bogomil/x.js
Created Sep 7, 2009

Embed
What would you like to do?
CmdUtils.CreateCommand({
names: ["smali", "смали"],
arguments: noun_type_url,
description: ("Заменя вашия URL с по-къс, за по-лесно споделяне."),
homepage: "http://www.bogomil.info/",
author: {name: "Bogomil Shopov", email: "shopov.bogomil@gmail.com"},
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
You can’t perform that action at this time.