diff options
| author | Kumar Priyansh <[email protected]> | 2020-08-31 01:34:16 +0530 |
|---|---|---|
| committer | Kumar Priyansh <[email protected]> | 2020-08-31 01:34:16 +0530 |
| commit | 3a660d4bb6e70afb7dd5baa8ecb81fd4213f38de (patch) | |
| tree | f6fd1c9ae4f42774c86c1a04e839aee97bc1b640 /app/scripts | |
| parent | 8fc8fdd041263b69de149c68d29670597d6cfa38 (diff) | |
| download | dictionary-3a660d4bb6e70afb7dd5baa8ecb81fd4213f38de.tar.xz dictionary-3a660d4bb6e70afb7dd5baa8ecb81fd4213f38de.zip | |
Add synonyms and remove example text
Diffstat (limited to 'app/scripts')
| -rw-r--r-- | app/scripts/search.js | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/app/scripts/search.js b/app/scripts/search.js index 0da2c91..23479c6 100644 --- a/app/scripts/search.js +++ b/app/scripts/search.js @@ -42,16 +42,27 @@ searchBox.addEventListener('keypress', (e) => { definition.className = 'definition'; results.appendChild(definition); - if (detail.exp.length) { - const exampleArea = document.createElement('p'); - exampleArea.innerHTML = 'Examples:'; - exampleArea.className = 'exampleArea'; - results.appendChild(exampleArea); + if (detail.synonyms.length) { + const synonymText = document.createTextNode('Synonyms: '); + const synonymParagraph = document.createElement('p'); + synonymParagraph.appendChild(synonymText); + + detail.synonyms.forEach(synonym => { + const currentSynonym = document.createElement('a'); + currentSynonym.innerHTML = synonym; + currentSynonym.className = 'synonymLink'; + synonymParagraph.appendChild(currentSynonym); + const spacer = document.createTextNode(' '); + synonymParagraph.appendChild(spacer); + }); + + synonymParagraph.className = 'synonym' + results.appendChild(synonymParagraph); } detail.exp.forEach(example => { const currentExample = document.createElement('p'); - currentExample.innerHTML = `${example}`; + currentExample.innerHTML = example; currentExample.className = 'example'; results.appendChild(currentExample); }); |
