Skip to content

Commit

Permalink
Displayed No results found message (#1015)
Browse files Browse the repository at this point in the history
  • Loading branch information
Janani-m17 authored May 31, 2024
1 parent 76e8df1 commit f964bea
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 4 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2500,6 +2500,10 @@ <h3>Calculates the linear density of the yarn from unit system to another.</h3>
</div>
</div>
</div>

<br><br><br><br><br>
<div id="noResults" style="color: white; font-weight: bold; font-size: 18px;"><p>No results found 🙃</p></div>

</div>

<!-- Calculator Section Ends Here -->
Expand Down
15 changes: 13 additions & 2 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ function filterCalculators() {
input = document.getElementById('calculatorSearch');
filter = input.value.toUpperCase();
calculators = document.querySelectorAll('.container .box');
console.log(filter)
console.log(calculators)
var noResults = document.getElementById('noResults');
var hasResults = false;

for (i = 0; i < calculators.length; i++) {
var calculator = calculators[i];
Expand All @@ -121,12 +121,23 @@ function filterCalculators() {

if (calculatorName.toUpperCase().indexOf(filter) > -1) {
calculator.style.display = "flex";
hasResults = true;
} else {
calculator.style.display = "none";
}
}

if (hasResults) {
noResults.style.display = 'none';
} else {
noResults.style.display = 'block';
}
}

document.addEventListener('DOMContentLoaded', function() {
document.getElementById('noResults').style.display = 'none';
});

// Voice command in search bar feature
const searchBar = document.querySelector("#searchBar");
const searchBarInput = searchBar.querySelector("input");
Expand Down

0 comments on commit f964bea

Please sign in to comment.