Skip to content

Instantly share code, notes, and snippets.

@Yasushi
Created February 16, 2009 06:42
Show Gist options
  • Save Yasushi/65057 to your computer and use it in GitHub Desktop.
Save Yasushi/65057 to your computer and use it in GitHub Desktop.
/**
* The LDOCE Online Dictionary.
*/
+function(){
const $j = jQuery;
const LDOCE_QUERY_URL = {
def: "http://www.ldoceonline.com",
html: "http://www.ldoceonline.com/search/?q="
};
const LDOCE_RENDER = function(pb, prm){
Utils.parseRemoteDocument(
LDOCE_QUERY_URL.html+prm, null,
function(doc){
var tmpl= LDOCE_STYLE+"${c}"+LDOCE_LOGO;
$j(doc).find(".content .folded a").each(function(){
var href = $j(this).attr("href");
$j(this).attr("href", LDOCE_QUERY_URL.def + href);
});
$j(pb).html(
CmdUtils.renderTemplate(tmpl,
{"c":$j(doc).find(".content").html()})
).css({"height":"600px","overflow-y":"auto"});
},
function(){pb.innerHTML = 'AjaxError'.italics() + LDOCE_LOGO}
);
};
CmdUtils.CreateCommand({
names: ["ldoce"],
description: "Recall The Longman Dictionary of Contemporary English Online.",
help: "ldoce [Word]",
icon: "http://www.ldoceonline.com/favicon.ico",
arguments: {"object search word": noun_arb_text},
preview: function(pb, inp){
pb.innerHTML = LDOCE_LOGO;
if(inp.object.text.length > 0){
pb.innerHTML = "Loading..."+LDOCE_LOGO;
LDOCE_RENDER(pb, inp.object.text);
}
},
execute: function(inp){
var inpt;
inpt = inp.object.text.length > 0 ? LDOCE_QUERY_URL.html + inp.object.text : LDOCE_QUERY_URL.def;
Utils.openUrlInBrowser(inpt);
},
author: "powchin".link("http://tako3.com/search/powchin"),
licence: 'MIT'
});
const LDOCE_LOGO = "<p><a href='"+LDOCE_QUERY_URL.def+"/'><img src='"+LDOCE_QUERY_URL.def+"/images/509/longman-english-dictionary.png' style='border: none;'></a></p>";
const LDOCE_STYLE = <style><![CDATA[
.dictionary-results-title{
FONT-WEIGHT:normal;
FONT-SIZE:11px;
FONT-FAMILY:Tahoma, Arial, Helvetica;
COLOR:#5ACBF9;
}
.headword{
font-family:Verdana, Helvetica, sans-serif;
font-weight:bold;
font-size:13pt;
color:#70EE0A;
}
.homographs{
font-family:Verdana, Helvetica, sans-serif;
font-weight:bold;
font-size:8pt;
vertical-align:top;
color:#fff;
margin-left:-3px;
}
.wordclass{
font-family:Verdana, Helvetica, sans-serif;
font-weight:normal;
font-size:10pt;
font-style:italic;
color:#FFAE9A;
margin-left:8px;
}
a.aspell-suggest{
font-family:Verdana, Helvetica, sans-serif;
font-size:12pt;
color:#70EE0A;
text-decoration:none;
margin-left:6px;
border:none;
cursor:pointer;
}
div.aspell-header{
font-family:Verdana, Helvetica, sans-serif;
font-style:normal;
font-weight:bold;
font-size:14pt;
color:#fff;
margin-left:6px;
}]]></style>.toXMLString();
}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment