Improve frontend

This commit is contained in:
Augusto Gunsch
2021-12-26 00:03:45 -03:00
parent b918498930
commit 0064653cdf
5 changed files with 60 additions and 36 deletions

View File

@@ -31,7 +31,9 @@ function getWord(word) {
success: (data) => {
$('#ajax-content').html(generateHtml(data))
searchBar.autocomplete('close');
}
},
error: err => console.error(err)
})
}
@@ -90,6 +92,12 @@ function generateTable(schemas, pos, forms) {
let unusedCells = forms.filter(cell => !cell.used);
if(schema.ignoreUnused) {
unusedCells = unusedCells.filter(cell =>
!schema.ignoreUnused.map(tags => tags.every(tag => cell.tags.includes(tag)))
);
}
if(unusedCells.length > 0) {
html += '<h3>Other</h3>';
html += generateList(unusedCells);
@@ -101,10 +109,6 @@ function generateTable(schemas, pos, forms) {
function generateHtml(data) {
let html = '';
if(Object.prototype.toString.call(data) !== '[object Array]') {
data = [data];
}
data.forEach(entry => {
html += `<h1>${entry.word} <span class="pos">(${entry.pos})</span></h1>`
if('senses' in entry) {

View File

@@ -142,6 +142,11 @@
},
{
"pos": "adj",
"ignoreUnused": [
["dative", "feminine", "singular"],
["instrumental", "feminine", "singular"],
["locative", "masculine", "neuter", "singular"]
],
"rows": [
[
{