Created
January 20, 2009 03:40
-
-
Save sealence/49305 to your computer and use it in GitHub Desktop.
Ubiquity: juku
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
/* command "jukuu" */ | |
CmdUtils.CreateCommand({ | |
names: ["juku"], | |
icon: "http://www.jukuu.com/images/logo.ico", | |
homepage: "http://www.jukuu.com/", | |
author: { name: "Sealence", email: "[email protected]"}, | |
license: "GPL", | |
description: "Search in Juku", | |
help: "juku: your word", | |
arguments: [ {role: 'object', nountype: noun_arb_text, label: 'input'} ], | |
baseurl: "http://www.jukuu.com/search.php?q=", | |
execute:function(args){ | |
var input = Utils.trim(args.object.text); | |
var url = this.baseurl + encodeURIComponent(input); | |
Utils.openUrlInBrowser(url); | |
}, | |
preview: function( pblock, args ) { | |
var input = args.object.text; | |
var url = this.baseurl + encodeURIComponent(input); | |
jQuery.get(url, function(data){ | |
if (!data) {return;} | |
var pronounce = jQuery('#Table1 td[width="70%"] table:first', data).html(); | |
var sentences = '<br/>'; | |
jQuery('#Table1 table[width="680"] tr.e, #Table1 table[width="680"] tr.c', data) | |
.each(function(key, value) { | |
if (key < 6) { | |
sentences += $(value).text() +"<br/>"; | |
if (key%2 != 0){ | |
sentences += "<br/>"; | |
} | |
} | |
}); | |
var pre_template = "\ | |
<style> \ | |
#container {background-color: #595A5F; margin: 10pt; padding 5pt;} \ | |
#word {background-color: #3399CC; font-family: arial black; font-size: x-large; padding: 3pt;} \ | |
a {font-family: arial black; font-size: large; padding: 3pt;} \ | |
#explanation {font-size: medium; font-family: tahoma;padding:3px 0;} \ | |
</style> \ | |
<div id=\"container\"> \ | |
<div id=\"word\">${w.word}</div> \ | |
<div id=\"explanation\">${w.def}</div> \ | |
</div>"; | |
var foobar = { | |
word : pronounce, | |
def : sentences | |
}; | |
pblock.innerHTML = CmdUtils.renderTemplate(pre_template, { | |
w:foobar | |
}); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment