-
Notifications
You must be signed in to change notification settings - Fork 0
/
recipe_details.html
208 lines (167 loc) · 6.24 KB
/
recipe_details.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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<!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="recipe_details.css">
<link rel="stylesheet" href="styles.css">
<script src="https://kit.fontawesome.com/99fa6e3e66.js" crossorigin="anonymous"></script>
<title>Recipe Details</title>
<style>
/* Add styling for the popup */
.share-popup {
display: none;
position: fixed;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
background-color: white;
border: 1px solid #ccc;
padding: 20px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
z-index: 1000;
}
.share-icons {
display: flex;
justify-content: space-around;
align-items: center;
}
.share-icons i {
font-size: 24px;
cursor: pointer;
}
</style>
</head>
<body>
<script>
document.addEventListener("DOMContentLoaded", function () {
const recipe = JSON.parse(localStorage.getItem('recipe-details'));
const recipeTitleElement = document.querySelector(".recipe-title");
const cookingTimeElement = document.querySelector(".cooking-time");
const ingredientsElement = document.querySelector(".ingredients");
const instructionsElement = document.querySelector(".instructions");
const recipeDetailsImage = document.querySelector(".recipe-details-image");
if (recipe ) {
recipeDetailsImage.src = recipe.image_url;
// Set the recipe title
recipeTitleElement.textContent = recipe.title.toUpperCase();
// Set the cooking time
cookingTimeElement.textContent = ` ${recipe.cooking_time} mins`;
// Set the ingredients
ingredientsElement.textContent = recipe.ingredients;
// Set the instructions
instructionsElement.textContent = recipe.instructions;
}
});
// Function to handle the share button click
function showSharePopup() {
const popup = document.getElementById("sharePopup");
popup.style.display = "block";
}
// Function to hide the share popup
function closeSharePopup() {
const popup = document.getElementById("sharePopup");
popup.style.display = "none";
}
// Function to copy link to clipboard
function copyLinkToClipboard() {
const copyText = document.createElement("textarea");
copyText.value = window.location.href;
document.body.appendChild(copyText);
copyText.select();
document.execCommand("copy");
document.body.removeChild(copyText);
alert("Link copied to clipboard!");
closeSharePopup(); // Close the popup after copying the link
}
// Functions for sharing on social media
function shareOnWhatsApp() {
// Add logic to share on WhatsApp
alert("Share on WhatsApp clicked!");
}
function shareOnFacebook() {
// Add logic to share on Facebook
alert("Share on Facebook clicked!");
}
function shareOnInstagram() {
// Add logic to share on Instagram
alert("Share on Instagram clicked!");
}
</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>
<h2 class="recipe-title"></h2>
<div class="recipe-details-container">
<div class="recipe-details-div">
<div class="recipe-image-container">
<div class="recipe-image">
<img class="recipe-details-image" alt="Recipe Image">
</div>
<div class="icons-container">
<div class="btn iconbtn" ><i onclick="showSharePopup()" class="fa fa-share"></i><br>Share</div>
<div class="btn iconbtn" ><i class="fa fa-comment"></i><br>Comment</div>
<div class="btn iconbtn" ><i id="favoriteIcon" onclick="toggleFavorite()" class="far fa-heart"></i><br>Favourite</div>
<div class="btn iconbtn" ><i id="saveIcon" onclick="toggleSave()" class="far fa-bookmark"></i><br>Save</div>
</div>
</div>
<div class="recipe-info">
<div class="details-container">
<div >
<h3>Cooking Time</h3>
<p class="cooking-time"></p>
</div>
<div >
<h3>Ingredients</h3>
<p class="ingredients"></p>
</div>
<div >
<h3>Instructions</h3>
<p class="instructions"></p>
</div>
</div>
</div>
</div>
<div class="comment-container">
<div class="comments">
<h2>Comments</h2>
<div class="comment-form">
<textarea id="user-comment" placeholder="Write your review"></textarea>
<button onclick="submitComment()">Submit</button>
</div>
<!-- Comments will be dynamically added here -->
<div class="comment-list"></div>
</div>
</div>
</div>
</div>
</main>
</div>
<div id="sharePopup" class="share-popup">
<span onclick="closeSharePopup()" style="cursor: pointer; float: right; font-size: 20px; margin-bottom: 10px;">×</span>
<h2>Share Recipe</h2>
<div class="share-icons">
<i class="fab fa-whatsapp" onclick="shareOnWhatsApp()"></i>
<i class="fab fa-facebook" onclick="shareOnFacebook()"></i>
<i class="fab fa-instagram" onclick="shareOnInstagram()"></i>
<i class="fas fa-copy" onclick="copyLinkToClipboard()"></i>
</div>
</div>
<script src="recipe_details.js"></script>
</body>
</html>