-
Notifications
You must be signed in to change notification settings - Fork 0
/
my-recipes.html
135 lines (111 loc) · 5.57 KB
/
my-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
<!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 highlighted" 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>MY RECIPES</h2>
<div id="recipeCardsContainer"></div>
<script>
document.addEventListener("DOMContentLoaded", function () {
const recipeCardsContainer = document.getElementById("recipeCardsContainer");
const data = localStorage.getItem('recipes');
if (data) {
const JSONData = JSON.parse(data);
JSONData.forEach((recipe, index) => {
const card = document.createElement("div");
card.classList.add("recipeCard");
// Create edit icon
const editIcon = document.createElement("i");
editIcon.classList.add("fas", "fa-edit", "edit-icon");
editIcon.addEventListener("click", () => openEditModal(index));
card.appendChild(editIcon);
// 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>
<div id="editModal" class="modal">
<div class="modal-content">
<span class="close" onclick="closeEditModal()">×</span>
<h2>Edit Recipe</h2>
<div class="modal-section">
<label class="modal-label" for="editTitle">Title:</label>
<input type="text" id="editTitle" class="modal-input" >
</div>
<div class="modal-section">
<label class="modal-label" for="editInstructions">Instructions:</label>
<textarea id="editInstructions"
class="modal-textarea"></textarea>
</div>
<div class="modal-section">
<label class="modal-label" for="editIngredients">Ingredients:</label>
<input type="text" id="editIngredients" class="modal-input">
</div>
<!-- Add more sections for other fields as needed -->
<div class="button-container">
<button class="upload-button" onclick="saveChanges()">Save Changes</button>
<button class="cancel-button" onclick="closeEditModal()">Cancel</button>
</div>
</div>
</div>
</main>
</div>
<div id="uploadSuccessMessage" class="popup-message"></div>
<script src="my-recipes.js"></script>
<script src="upload-recipe.js"></script>
</body>
</html>