From 8c191041a833f88920b23dd44a8769a4d0677936 Mon Sep 17 00:00:00 2001 From: Augusto Gunsch Date: Sun, 26 Dec 2021 13:11:21 -0300 Subject: [PATCH] =?UTF-8?q?Use=20multip=C4=BAe=20tags?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/index.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/static/index.js b/static/index.js index 43388f2..ab61396 100644 --- a/static/index.js +++ b/static/index.js @@ -72,7 +72,7 @@ function generateTable(schemas, pos, forms) { if(!schema) return generateList(forms); - let html = '
'; + let html = '
'; html += ''; schema.rows.forEach(row => { @@ -90,7 +90,7 @@ function generateTable(schemas, pos, forms) { }); html += '
'; - html += '
'; + html += '
'; let unusedCells = forms.filter(cell => !cell.used); @@ -117,9 +117,17 @@ function generateHtml(word, data) { data.forEach(entry => { html += `

${entry.word} (${entry.pos})

` if('senses' in entry) { - if('tags' in entry.senses[0]) { - html += '
' - html += entry.senses[0].tags.map(tag => `${tag}`).join(', '); + let tags = []; + entry.senses.forEach(sense => { + if('tags' in sense) { + tags.push(...sense.tags); + } + }); + + if(tags.length > 0) { + tags = [...new Set(tags)]; + html += '
Tags: ' + html += tags.map(tag => `${tag}`).join(', ') html += '
' }