-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
103 lines (83 loc) · 3.49 KB
/
index.html
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="styles.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Untitled</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ionicons/2.0.1/css/ionicons.min.css">
<link rel="stylesheet" href="assets/css/style.css">
<link href="https://fonts.googleapis.com/css?family=Lato:400,700" rel="stylesheet">
<title>Recipe Website</title>
</head>
<body>
<header>
<nav>
<img src="logo.png" alt="Logo">
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="recipes.html">Recipes</a></li>
<li><a href="aboutus.html">About</a></li>
</ul>
<form>
<input type="text" id="search-input" placeholder="Search...">
<button type="submit" id="search-button"><i class="fa fa-search"></i></button>
</form>
</nav>
</header>
<section class="hero">
<h1>Discover delicious recipes</h1>
<p>Find Your Next Meal By Only 1 Ingredient Or Take A Look At The Creators Favriout Meals.</p>
<a href="recipes.html">Explore Recipes</a>
</section>
<div class="footer-clean">
<footer>
<div class="container">
<div class="row justify-content-center">
<div class="col-sm-4 col-md-3 item">
<h3>About</h3>
<ul>
<li><a href="aboutus.html">About Me</a></li>
</ul>
</div>
<div class="col-sm-4 col-md-3 item">
<h3>Recipes</h3>
<ul>
<li><a href="recipes.html">Recipes</a></li>
</ul>
</div>
<div class="col-lg-3 item social"><a href="#"><i class="icon ion-social-facebook"></i></a><a href="#"><i class="icon ion-social-twitter"></i></a><a href="#"><i class="icon ion-social-snapchat"></i></a><a href="#"><i class="icon ion-social-instagram"></i></a>
<p class="copyright">Company Name © 2018</p>
</div>
</div>
</div>
</footer>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/js/bootstrap.bundle.min.js"></script>
<script src="https://use.fontawesome.com/releases/v5.13.0/js/all.js"></script>
<script src="script.js">
const form = document.querySelector('form');
const searchInput = document.querySelector('#search-input');
form.addEventListener('submit', function(event) {
event.preventDefault();
const searchTerm = searchInput.value;
const xhr = new XMLHttpRequest();
xhr.open('GET', 'recipes.json', true);
xhr.onload = function() {
if (this.status === 200) {
const recipes = JSON.parse(this.responseText);
const results = recipes.filter(function(recipe) {
return recipe.ingredients.includes(searchTerm);
});
const queryString = '?results=' + encodeURIComponent(JSON.stringify(results));
window.location.href = 'results.html' + queryString;
}
};
xhr.send();
});
</script>
</body>
</html>