(function(window) {
teilod = {
/**
* Map of languge code to lexicon for lemma lookup
**/
lexicons: {
'grc' : 'lsj',
'lat' : 'ls',
'ara' : 'lan'
},
/**
* Map of language codes to morphology engine for form lookup
*/
morphEngines: {
'grc': 'morpheusgrc',
'lat': 'morpheuslat',
'ara': 'aramorph'
},
/**
* Url to morphology service
*/
morphUrl : 'http://services.perseids.org/bsp/morphologyservice/analysis/word?word=WORD&lang=LANG&engine=ENGINE',
/**
* Url to lexicon service
*/
lexiconUrl: 'http://repos1.alpheios.net/exist/rest/db/xq/lexi-get.xq?lx=LEXICON&lg=LANG&out=html&l=LEMMA',
/**
* Url to treebank viewer
*/
syntaxUrl: 'http://repos.alpheios.net:8081/exist/rest/db/xq/treebank-xb-viewer.xq?&fmt=FORMAT&lang=LANG',
/**
* jQuery document ready function
*/
ready : function() {
$('.tei-word').dblclick(teilod.getLemmas);
$('.tei-word[data-corresp]').mouseover(teilod.showTranslation);
$('.tei-word[data-corresp]').mouseout(teilod.hideTranslation);
$('.tei-aligned-word[data-corresp]').mouseover(teilod.showTranslation);
$('.tei-aligned-word[data-corresp]').mouseout(teilod.hideTranslation);
$('.tbref').click(teilod.getSyntax);
},
/**
* Click handler for syntax lookup.
*/
getSyntax: function(a_event)
{
// update the syntax frame to show data is loading
$("#tei-syntax-frame").contents().find('body').prepend('
Loading...
');
// retrieve sentence XML from the document
var treebank = $(".data sentence",this);
var fmt = treebank.get(0).getAttribute("format");
var lang = treebank.get(0).getAttribute("xml:lang");
var sent = '' + $(".data sentence",this).get(0).innerHTML + '';
// send the sentence to the remote treebank view loader app
var url = teilod.syntaxUrl;
url = url.replace('FORMAT',fmt);
url = url.replace('LANG',lang);
$.ajax(url, {
type: 'GET',
dataType: "xml",
isLocal: "true",
success: function(data) {
var jdata = $(data).contents().find('body').html();
$("#tei-syntax-frame").contents().find('body').html(jdata);
$("#tei-syntax-frame").contents().find('#sentence-xml').html(sent);
$("#tei-syntax-frame").contents().find('#sentence-xml').change();
},
error: function() {
$("#tei-syntax-frame").contents().find('body').html('Error Loading Syntax View
');
}
});
},
/**
* Mouseover handler for highlighting aligned translation
*/
showTranslation: function(a_event) {
var resource = $(this).attr('data-corresp');
var isTranslation = false;
if ($(this).parents('.tei-aligned-text').length > 0) {
isTranslation = true;
}
if (resource != null && resource != '') {
var resources = resource.split(' ');
for (var i=0; i 0) {
isTranslation = true;
}
if (resource != null && resource != '') {
var resources = resource.split(' ');
for (var i=0; i