-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
87 lines (80 loc) · 4.26 KB
/
Copy pathindex.html
File metadata and controls
87 lines (80 loc) · 4.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pink Pau</title>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.8/dist/umd/popper.min.js" integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.min.js" integrity="sha384-0pUGZvbkm6XF6gxjEnlmuGrJXVbNuzT9qBBavbLwCsOGabYfZo0T0to5eqruptLy" crossorigin="anonymous"></script>
<script src="components/header.js" type="text/javascript" defer></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@100..900&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
<link rel="stylesheet" href="styles.css">
</head>
<body>
<header-component></header-component>
<div class="container">
<div class="jumbotron jumbotron-img">
<div class="content">
<h1 class="display-4 website-color">Welcome to <strong>Pink Pau!</strong></h1>
<p class="lead">Discover a world of delicious recipes, from appetizers to desserts, perfect for every skill level. Our easy-to-follow instructions and diverse cuisine options inspire your culinary journey.
</p>
<hr class="my-4">
<p>Join our community of food lovers, share your creations, and find your next favorite dish. Happy cooking!</p>
<p class="lead">
<button class="browse-button" type="button" onclick="location.href = 'dishes.html';">Browse recipes now!</button>
</p>
</div>
</div>
<!--recommendation-->
<section>
<h2 class="center" id="reccomendations-text">Recommendations</h2>
<div class="container">
<div class="meals-container" id="featured-meals"></div>
</div>
</section>
</div>
<script>
function sendQuery() {
const query = document.getElementById('searchQuery').value;
// Redirect to results.html with the query as a URL parameter
window.location.href = `dishes.html?query=${encodeURIComponent(query)}`;
return false; // Prevent the default form submission
}
const buildCard = (meal) => {
const card = document.createElement('div')
card.className = 'meal';
card.innerHTML = `
<img src="${meal['strMealThumb']}" alt="${meal['strMeal']} class="meal-img" style="width:100%">
<div class="meal-content">
<h5>${meal.strMeal}</h5>
<form action="specificdish.html" method="GET">
<input type="text" name="meal_id" value=${meal.idMeal} hidden>
<button class="select-btn " type="submit">Start cooking!</button>
</form>
</div>
`
return card
}
const getPopularRecipe = (search) => {
const url = `https://www.themealdb.com/api/json/v1/1/search.php?s=${search}`
fetch(url)
.then(response => {
return response.json()
})
.then(data => {
const meal = data['meals'][0]
const card = buildCard(meal)
const cardContainer = document.getElementById('featured-meals')
cardContainer.appendChild(card)
})
}
getPopularRecipe('baked salmon')
getPopularRecipe('Kung Pao Chicken')
getPopularRecipe('onion soup')
</script>
</body>
</html>