Improve frontend
This commit is contained in:
@@ -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) {
|
||||
|
@@ -142,6 +142,11 @@
|
||||
},
|
||||
{
|
||||
"pos": "adj",
|
||||
"ignoreUnused": [
|
||||
["dative", "feminine", "singular"],
|
||||
["instrumental", "feminine", "singular"],
|
||||
["locative", "masculine", "neuter", "singular"]
|
||||
],
|
||||
"rows": [
|
||||
[
|
||||
{
|
||||
|
Reference in New Issue
Block a user