2025-03-21 14:14:03 +03:00
|
|
|
|
$( document ).ready(function() {
|
|
|
|
|
$('#abv-select-lang').on('input', function() {
|
|
|
|
|
let $selected = $(this).children('option:selected');
|
2025-03-21 15:38:05 +03:00
|
|
|
|
let url = `./api/languages/${$selected.attr('value')}`;
|
2025-03-21 14:14:03 +03:00
|
|
|
|
|
|
|
|
|
fetch(url)
|
|
|
|
|
.then(res => res.json())
|
|
|
|
|
.then(out => {
|
|
|
|
|
let $select_word = $('#abv-select-word');
|
|
|
|
|
let $select_entry = $('#abv-select-entry');
|
|
|
|
|
$select_word.empty();
|
|
|
|
|
$select_entry.empty();
|
|
|
|
|
for (w of out.words) {
|
|
|
|
|
$select_word.append(new Option(w.text,w.id))
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.catch(err => console.log(err));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('#abv-select-word').on('input', function() {
|
|
|
|
|
let $selected = $(this).children('option:selected');
|
|
|
|
|
let wordid = $selected.attr('value');
|
|
|
|
|
let lang = $('#abv-select-lang').children('option:selected').attr('value');
|
2025-03-21 15:38:05 +03:00
|
|
|
|
let url = `./api/languages/${lang}/words/${wordid}`;
|
2025-03-21 14:14:03 +03:00
|
|
|
|
|
|
|
|
|
fetch(url)
|
|
|
|
|
.then(res => res.json())
|
|
|
|
|
.then(out => {
|
|
|
|
|
let $select_entry = $('#abv-select-entry');
|
|
|
|
|
$select_entry.empty();
|
|
|
|
|
for (e of out.entries) {
|
2025-03-21 15:38:05 +03:00
|
|
|
|
url_entry = `./api/entries/${e.id}`;
|
2025-03-21 14:14:03 +03:00
|
|
|
|
fetch(url_entry)
|
|
|
|
|
.then(res => res.json())
|
|
|
|
|
.then(out => {
|
2025-03-21 15:48:44 +03:00
|
|
|
|
let entrystring = '';
|
2025-03-21 14:14:03 +03:00
|
|
|
|
let glosses = [];
|
|
|
|
|
for (r of e.refs) {
|
|
|
|
|
if (r.glosses) {
|
|
|
|
|
for(g of r.glosses){
|
2025-03-21 15:48:44 +03:00
|
|
|
|
glosses.push(`‘${g}’`);
|
2025-03-21 14:14:03 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(glosses.length > 0) {
|
2025-03-21 15:48:44 +03:00
|
|
|
|
entrystring = `${glosses.join('; ')}: `
|
2025-03-21 14:14:03 +03:00
|
|
|
|
}
|
2025-03-22 23:43:48 +03:00
|
|
|
|
opt = $(`<option value="${out.xmlid}" data-abv-xpath="${e.refs[0].path}">${entrystring}<i>${out.form}</i>
|
2025-03-21 19:57:16 +03:00
|
|
|
|
${out.glosses.map(g => `‘${g}’`).join(', ')}</option>`);
|
2025-03-21 15:48:44 +03:00
|
|
|
|
$select_entry.append(opt)
|
2025-03-21 14:14:03 +03:00
|
|
|
|
})
|
|
|
|
|
.catch(err => console.log(err));
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.catch(err => console.log(err));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('#abv-select-entry').on("dblclick", function() {
|
|
|
|
|
let $selected = $(this).children('option:selected');
|
2025-03-22 23:43:48 +03:00
|
|
|
|
let entry = $selected.attr('value');
|
|
|
|
|
let path = $selected.attr('data-abv-xpath');
|
|
|
|
|
window.location.replace('./dict/' + entry + `?entry=${entry}&xpath=${path}`);
|
2025-03-21 14:14:03 +03:00
|
|
|
|
});
|
|
|
|
|
});
|