2023-02-05 03:04:28 +00:00
|
|
|
$(function() {
|
2023-02-18 08:12:33 +00:00
|
|
|
$('#word').each(function(index, elem) {
|
2023-02-05 03:04:28 +00:00
|
|
|
$.getJSON(
|
2023-02-11 06:08:51 +00:00
|
|
|
'http://ksenia.causa-arcana.com/api/words/' + $(elem).data('id'),
|
2023-02-05 03:04:28 +00:00
|
|
|
function(data) {
|
2023-02-18 11:47:55 +00:00
|
|
|
var primary_form = data['primary_form']
|
2023-02-18 08:12:33 +00:00
|
|
|
var part_of_speech = data['part_of_speech']
|
2023-02-19 05:09:55 +00:00
|
|
|
var commentary = data['commentary']
|
2023-02-18 08:12:33 +00:00
|
|
|
|
2023-02-18 14:24:07 +00:00
|
|
|
var translations = []
|
|
|
|
data['translations'].forEach(function(item) {
|
2023-02-18 14:31:04 +00:00
|
|
|
var commentary = ''
|
|
|
|
if (item['commentary']) {
|
|
|
|
commentary = ' (' + item['commentary'] + ')'
|
|
|
|
}
|
2023-02-18 14:24:07 +00:00
|
|
|
translations.push(
|
2023-02-18 14:31:04 +00:00
|
|
|
'<li>' + item['translation'] + commentary + '</li>'
|
2023-02-18 14:24:07 +00:00
|
|
|
)
|
|
|
|
})
|
|
|
|
|
2023-02-19 05:34:15 +00:00
|
|
|
var inflections = data['inflections']
|
|
|
|
|
2023-02-18 08:12:33 +00:00
|
|
|
var examples = []
|
2023-02-11 06:08:51 +00:00
|
|
|
data['examples'].forEach(function(item) {
|
2023-02-18 08:12:33 +00:00
|
|
|
examples.push('<li>' + item[0] + ' — ' + item[1] + '</li>')
|
2023-02-05 03:04:28 +00:00
|
|
|
})
|
2023-02-18 08:12:33 +00:00
|
|
|
|
2023-02-18 11:47:55 +00:00
|
|
|
$('#primary-form').text(primary_form)
|
2023-02-18 08:12:33 +00:00
|
|
|
$('#part-of-speech').text(part_of_speech)
|
|
|
|
|
2023-02-19 05:09:55 +00:00
|
|
|
if (commentary) {
|
|
|
|
$('#commentary-data').text(commentary)
|
|
|
|
$('#commentary').removeClass('invisible')
|
|
|
|
}
|
|
|
|
|
2023-02-18 14:24:07 +00:00
|
|
|
if (translations.length > 0) {
|
|
|
|
$('#translations-data').html('<ol>' + translations.join('') + '</ol>')
|
|
|
|
$('#translations').removeClass('invisible')
|
|
|
|
}
|
|
|
|
|
2023-02-19 05:34:15 +00:00
|
|
|
if (inflections) {
|
|
|
|
$('#inflections').html(inflections)
|
|
|
|
$('#inflections').removeClass('invisible')
|
|
|
|
}
|
|
|
|
|
2023-02-18 08:12:33 +00:00
|
|
|
if (examples.length > 0) {
|
2023-02-18 08:14:19 +00:00
|
|
|
$('#examples-data').html('<ul>' + examples.join('') + '</ul>')
|
2023-02-18 08:12:33 +00:00
|
|
|
$('#examples').removeClass('invisible')
|
|
|
|
}
|
2023-02-05 03:04:28 +00:00
|
|
|
},
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|