-
Notifications
You must be signed in to change notification settings - Fork 0
/
search-recipes.html
149 lines (117 loc) · 5.31 KB
/
search-recipes.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles.css">
<title>RecipeShare</title>
<script src="https://kit.fontawesome.com/99fa6e3e66.js" crossorigin="anonymous"></script>
</head>
<body>
<script>
function dropdownClick(){
if( document.querySelector('.list').style.display=='none'){
document.querySelector('.list').style.display = 'block';
}else{
document.querySelector('.list').style.display = 'none';
}
}
function searchClick(){
document.querySelector('.list').style.display = 'none';
}
</script>
<header>
<div class="navbar">
<a class="home-icon" href="home.html"><i class="fas fa-home"></i></a>
<div class="logo">RecipeShare</div>
<div class="nav-links">
<a href="about-us.html">About Us</a>
<a href="login.html"><button onclick="logout()"><i class="fas fa-sign-out-alt"></i> Logout</button></a>
</div>
</div>
</header>
<div class="container">
<aside class="sidebar">
<a class="sidebar-item" href="saved.html"><i class="fas fa-bookmark"></i> Saved</a>
<a class="sidebar-item" href="my-recipes.html"><i class="fas fa-book"></i> My Recipes</a>
<a class="sidebar-item" href="favourites.html"><i class="fas fa-heart"></i> Favorites</a>
<a class="sidebar-item" href="upload-recipe.html"><i class="fas fa-cloud-upload-alt"></i> Upload</a>
</aside>
<main>
<div class="search-filter">
<div class="multi-selector">
<div class="select-field" onclick="dropdownClick()">Filter
<span class="down-arrow">▾</span>
</div>
<div class="list">
<label for="task1" class="task">
<input type="checkbox" name="" id="task1">
breakfast
</label>
<label for="task2" class="task">
<input type="checkbox" value="" name="" id="task2">
lunch
</label>
<label for="task3" class="task">
<input type="checkbox" name="" id="task3">
dinner
</label>
<label for="task4" class="task">
<input type="checkbox" name="" id="task4">
veg
</label>
<label for="task4" class="task">
<input type="checkbox" name="" id="task4">
non-veg
</label>
<label for="task4" class="task">
<input type="checkbox" name="" id="task4">
vegan-only
</label>
</div>
</div>
<div class="search-input">
<input type="text" placeholder="Search...">
<i onClick="searchClick()" class="fas fa-search"></i>
</div>
</div>
<div id="recipeCardsContainer"></div>
<script>
document.addEventListener("DOMContentLoaded", function () {
const recipeCardsContainer = document.getElementById("recipeCardsContainer");
const data = localStorage.getItem('search');
console.log(data);
if (data) {
const JSONData = JSON.parse(data);
JSONData.forEach((recipe, index) => {
const card = document.createElement("div");
card.classList.add("recipeCard");
// Create title element
const title = document.createElement("p");
title.onclick = function () {
handleRecipeCardClick(index);
};
title.textContent = recipe.title;
card.appendChild(title);
// Create image element
const imgDiv = document.createElement("div");
imgDiv.onclick = function () {
handleRecipeCardClick(index);
};
const image = document.createElement("img");
image.src = recipe.image_url;
image.alt = recipe.title;
imgDiv.appendChild(image);
card.appendChild(imgDiv);
card.classList.add("recipeCard");
// Append the card to the container
recipeCardsContainer.appendChild(card);
});
}
});
</script>
</main>
</div>
<script src="search-recipes.js"></script>
</body>
</html>