Skip to content

Commit 8e407ef

Browse files
committed
project done
1 parent bf9f548 commit 8e407ef

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

assets/images/icons/favicon.png

1.46 KB
Loading

css/style.css

+6-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ ul input {
5656
.banner {
5757
display: flex;
5858
justify-content: center;
59-
margin-top: 60px;
59+
margin-top: 70px;
6060
}
6161
.banner-item {
6262
display: flex;
@@ -91,7 +91,7 @@ ul input {
9191
}
9292
#supporters {
9393
text-align: center;
94-
margin-bottom: 60px;
94+
margin-top: 15px;
9595
}
9696

9797
.main {
@@ -334,4 +334,8 @@ footer a {
334334
}
335335
.food-details a{
336336
color: white;
337+
}
338+
#no-search-result{
339+
display: none;
340+
margin-top: 30px;
337341
}

index.html

+6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<meta name="viewport" content="width=device-width, initial-scale=1.0">
88
<script src="https://kit.fontawesome.com/ff4421e871.js" crossorigin="anonymous"></script>
99
<link rel="stylesheet" href="css/style.css">
10+
<link rel="shortcut icon" href="assets/images/icons/favicon.png" type="image/png">
1011
<title>TheMealDB.com</title>
1112
</head>
1213

@@ -393,6 +394,11 @@ <h1>Welcome to TheMealDB</h1>
393394
<div id="preloader">
394395
<img src="assets/images/preloader.webp" alt="">
395396
</div>
397+
398+
<!-- no search result found -->
399+
<div id="no-search-result">
400+
<p style="color: red; text-align: center; font-size: 22px;"><del><b>No search result found</b></del></p>
401+
</div>
396402
<!-- display food details -->
397403
<div id="food-details" class="food-details">
398404

js/app.js

+17-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,19 @@ const loadFoods = () => {
22
document.getElementById('preloader').style.display = 'block';
33
const inputField = document.getElementById('input-field');
44
const inputFieldValue =inputField.value;
5+
if(!inputFieldValue){
6+
alert('Write something.............');
7+
document.getElementById('preloader').style.display = 'none';
8+
return;
9+
}
10+
else if(inputFieldValue < 0){
11+
alert('Enter positive number');
12+
document.getElementById('preloader').style.display = 'none';
13+
return;
14+
}
515

616
document.getElementById('display-search-result').innerHTML = '';
17+
document.getElementById('no-search-result').style.display = 'none';
718
document.getElementById('main').style.display = "none";
819
document.getElementById('footer').style.display = "none";
920
fetch(`https://www.themealdb.com/api/json/v1/1/search.php?s=${inputFieldValue}`)
@@ -14,6 +25,10 @@ const loadFoods = () => {
1425
}
1526

1627
const displayFoods = foods => {
28+
if(!foods){
29+
document.getElementById('no-search-result').style.display = 'block';
30+
document.getElementById('preloader').style.display = 'none';
31+
}
1732
console.log(foods);
1833
// document.getElementById('display-search-result').innerHTML = '';
1934
const searchResult = document.getElementById('display-search-result');
@@ -31,6 +46,7 @@ const displayFoods = foods => {
3146
searchResult.appendChild(div);
3247
})
3348
document.getElementById('preloader').style.display = 'none';
49+
document.getElementById('no-search-result').style.display = 'none';
3450
}
3551

3652
const loadFoodDetails = foodId => {
@@ -47,7 +63,7 @@ const getFoodDetails = food => {
4763
<img src="${food.strMealThumb}">
4864
<h4>${food.strMeal}</h4>
4965
<p>${food.strInstructions}</p>
50-
<button><a href="${food.strYoutube}" target="_blank">Visit Youtube</a></button>
66+
<button><a href="${food.strYoutube}" target="_blank">Watch in Youtube</a></button>
5167
5268
</div>
5369

0 commit comments

Comments
 (0)