Skip to content

Instantly share code, notes, and snippets.

@edbond
Created February 4, 2009 16:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edbond/58174 to your computer and use it in GitHub Desktop.
Save edbond/58174 to your computer and use it in GitHub Desktop.
/* This is a template command */
CmdUtils.CreateCommand({
name: "Yandex.Slovari",
icon: "http://lingvo.yandex.ru/favicon.ico",
homepage: "http://slovari.yandex.ru/",
author: { name: "Eduard Bondarenko", email: "edbond@gmail.com"},
license: "GPL",
description: "Translate selection on yandex slovari",
help: "Input text for translation",
takes: {"word": noun_arb_text},
preview: function( pblock, word ) {
// load page
var url="http://lingvo.yandex.ru/en?text="+word.text+"&st_translate=on";
jQuery.get(url, function(yhtml) {
//CmdUtils.log(yhtml);
var article = jQuery( ".lingvo-article:first", yhtml );
//CmdUtils.log(article);
if (article.length > 0) {
pblock.innerHTML = article[0].innerHTML;
};
});
},
execute: function(word) {
Utils.openUrlInBrowser("http://lingvo.yandex.ru/en?text="+word.text+"&st_translate=on");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment