-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresults.html
82 lines (70 loc) · 2.47 KB
/
results.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
<!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="results.css">
<link href="https://fonts.googleapis.com/css?family=Lato:400,700" rel="stylesheet">
<title>Recipe Results</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>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam auctor nisi ut urna blandit, at tempor metus bibendum.</p>
<a href="#">Explore Recipes</a>
</section>
<section class="results">
<h2>Search Results</h2>
<div id="results-container"></div>
</section>
<footer>
<p>© Recipe Website 2021</p>
</footer>
<script src="https://use.fontawesome.com/releases/v5.13.0/js/all.js"></script>
<script src="script.js"></script>
<script>
const urlParams = new URLSearchParams(window.location.search);
const resultsJSON = urlParams.get('results');
if (resultsJSON) {
const results = JSON.parse(decodeURIComponent(resultsJSON));
const resultsContainer = document.getElementById('results-container');
results.forEach((result) => {
const card = document.createElement('div');
card.classList.add('card');
const img = document.createElement('img');
img.src = result.strMealThumb;
img.alt = result.strMeal;
const title = document.createElement('h3');
title.textContent = result.strMeal;
const link = document.createElement('a');
link.href = result.strSource || result.strYoutube;
link.textContent = 'View Recipe';
link.target = '_blank';
card.appendChild(img);
card.appendChild(title);
card.appendChild(link);
resultsContainer.appendChild(card);
});
} else {
const resultsContainer = document.getElementById('results-container');
const message = document.createElement('p');
message.textContent = 'No results found.';
resultsContainer.appendChild(message);
}
</script>
</body>
</html>