1
1
mirror of https://github.com/neosubhamoy/neosubhamoy-portfolio.git synced 2025-12-20 01:09:35 +05:30

(feat): added no results found message

This commit is contained in:
2023-11-17 22:08:39 +05:30
parent 9bd71fd132
commit 02834eb5f6
4 changed files with 25 additions and 7 deletions

View File

@@ -100,7 +100,13 @@ function perform_search(searchInput, searchDef, searchRes) {
dataType: 'json',
data: { keyword: searchString },
success: function(response) {
inject_search_results(response);
console.log(response);
if(response.results && response.results === "none") {
inject_no_results(response);
}
else {
inject_search_results(response);
}
},
error: function(error) {
console.error('error:', error);
@@ -144,6 +150,10 @@ function inject_search_results (results) {
});
}
function inject_no_results(results) {
searchRes.innerHTML = `<div class="resultitem w-full h-[59vh] flex flex-col justify-center items-center"><p class="text-xl text-accent_three">${results.message}</p</div>`;
}
searchInput.addEventListener('input', function() {
if (searchInput.value != "") {
perform_search(searchInput, searchDef, searchRes);