Add not found message
This commit is contained in:
parent
4c01f546b5
commit
b81849a63a
|
@ -29,7 +29,7 @@ function getWord(word) {
|
||||||
url: '/langs/polish/words/' + word,
|
url: '/langs/polish/words/' + word,
|
||||||
|
|
||||||
success: (data) => {
|
success: (data) => {
|
||||||
$('#ajax-content').html(generateHtml(data))
|
$('#ajax-content').html(generateHtml(word, data))
|
||||||
searchBar.autocomplete('close');
|
searchBar.autocomplete('close');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -108,9 +108,12 @@ function generateTable(schemas, pos, forms) {
|
||||||
return html;
|
return html;
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateHtml(data) {
|
function generateHtml(word, data) {
|
||||||
let html = '';
|
let html = '';
|
||||||
|
|
||||||
|
if(data.length === 0) {
|
||||||
|
html += `<h1>Not found: <mark>${word}</mark></h1>`;
|
||||||
|
} else {
|
||||||
data.forEach(entry => {
|
data.forEach(entry => {
|
||||||
html += `<h1>${entry.word} <span class="pos">(${entry.pos})</span></h1>`
|
html += `<h1>${entry.word} <span class="pos">(${entry.pos})</span></h1>`
|
||||||
if('senses' in entry) {
|
if('senses' in entry) {
|
||||||
|
@ -161,6 +164,11 @@ function generateHtml(data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return html;
|
return html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('#search-bar').select();
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in New Issue