-
Notifications
You must be signed in to change notification settings - Fork 76
/
productdetail.html
345 lines (328 loc) · 13.9 KB
/
productdetail.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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Product Details</title>
<link rel="stylesheet" href="style.css" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap" rel="stylesheet" />
<link href="https://unpkg.com/[email protected]/dist/aos.css" rel="stylesheet" />
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />
<link rel="icon" type="image/x-icon" href="images/logo.png" />
</head>
<body>
<div class="container">
<div class="navbar">
<div class="logo">
<a href="index.html">
<img src="images/logo.png" width="125px" />
</a>
</div>
<div class="search_bar">
<input type="text" name="search" placeholder="Search for products, brands and more">
<button type="submit" class="search-button"><img src="images\icons8-search-24.png"></button>
</div>
<nav>
<ul id="MenuItems">
<li><a href="index.html">Home</a></li>
<li><a href="allproducts.html">Products</a></li>
<li><a href="">About</a></li>
<li><a href="contact.html">Contact</a></li>
<li><a href="account.html">Account</a></li>
</ul>
</nav>
<a href="cart.html">
<img src="images/cart.png" width="30px" height="30px" />
</a>
<div class="toggle">
<i class="fa-solid fa-moon toggle-icon"></i>
<i class="fa-solid fa-sun toggle-icon"></i>
<div class="toggle-ball"></div>
</div>
<img src="images/menu.png" class="menu-icon" onclick="menutoggle()" />
</div>
</div>
<!----------single product details-------->
<div class="small-container single-product" data-aos="fade-up">
<div class="row">
<div class="col-2">
<img src="images/gallery-1.jpg" width="100%" id="ProductImg" />
<div class="small-img-row">
<div class="small-img-col">
<img src="images/gallery-1.jpg" width="100%" class="small-img" />
</div>
<div class="small-img-col">
<img src="images/gallery-2.jpg" width="100%" class="small-img" />
</div>
<div class="small-img-col">
<img src="images/gallery-3.jpg" width="100%" class="small-img" />
</div>
<div class="small-img-col">
<img src="images/gallery-4.jpg" width="100%" class="small-img" />
</div>
</div>
</div>
<div class="col-2">
<p><a href="./allproducts.html">Home</a> / T-Shirt</p>
<h1 id="productName">Red Printed T-Shirt by PUMA</h1>
<h4 style="display: flex">
Rs.
<p id="productPrice" style="margin-right: 0.25em">450</p>
</h4>
<!-- original html: -->
<!-- <select>
<option>Select Size</option>
<option>XXL</option>
<option>XL</option>
<option>Large</option>
<option>Medium</option>
<option>Small</option>
</select> -->
<select id="productSize">
<option>XXL</option>
<option>XL</option>
<option>Large</option>
<option selected>Medium</option>
<option>Small</option>
</select>
<button class="btn-quantity" onClick="decreaseQuantity()">-</button>
<input type="number" value="1" min="1" id="productQuantity" oninput="checkValid()" />
<button type="button" class="btn-quantity" onClick="increaseQuantity()">+</button>
<!-- <a href="" class="btn">Add To Cart</a> -->
<p onclick="func()" class="btn">Add To Cart</p>
<h3>Product Details<i class="fa fa-indent"></i></h3>
<br />
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Rerum doloribus eligendi quidem hic, facere atque sit laborum maiores nostrum eveniet amet non sunt deserunt. Dolor commodi voluptatibus minus atque doloribus?
</p>
</div>
</div>
</div>
<!-- -------------title--------------- -->
<div class="small-container">
<div class="row row-2" data-aos="fade-up">
<h2>Related Products</h2>
<p><a href="./allproducts.html" class="viewMore--btn">View More</a></p>
</div>
</div>
<!-- ---------------product---------------- -->
<div class="small-container">
<div class="row">
<div class="col-4" id="box" data-aos="fade-up">
<img src="images/product-9.jpg" />
<h4>Wrist Watch</h4>
<div class="rating">
<!-- for adding star cdn link-> font awesome 4cdn by stackpath -->
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star-o"></i>
</div>
<p>Rs. 450.00</p>
</div>
<div class="col-4" id="box" data-aos="fade-up">
<img src="images/product-10.jpg" />
<h4>Black Ranger shoes</h4>
<div class="rating">
<!-- for adding star cdn link-> font awesome 4cdn by stackpath -->
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star-o"></i>
<i class="fa fa-star-o"></i>
</div>
<p>Rs. 850.00</p>
</div>
<div class="col-4" id="box" data-aos="fade-up">
<img src="images/product-11.jpg" />
<h4>New style shoes</h4>
<div class="rating">
<!-- for adding star cdn link-> font awesome 4cdn by stackpath -->
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star-half-o"></i>
</div>
<p>Rs. 450.00</p>
</div>
<div class="col-4" id="box" data-aos="fade-up">
<img src="images/product-12.jpg" />
<h4>Black jogger Puma</h4>
<div class="rating">
<!-- for adding star cdn link-> font awesome 4cdn by stackpath -->
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star-half-o"></i>
<i class="fa fa-star-o"></i>
</div>
<p>Rs. 550.00</p>
</div>
</div>
<div id="toast">Red Printed T-Shirt added to the cart</div>
</div>
<!------footer--------->
<div class="footer">
<div class="container" data-aos="fade-up">
<div class="row">
<div class="footer-col-1">
<h3>Download Our App</h3>
<p>Download App for Android and ios mobile phone</p>
<div class="app-logo">
<img src="images/play-store.png" />
<img src="images/app-store.png" />
</div>
</div>
<div class="footer-col-2">
<img src="images/logo-white.png" />
<p>
Our Purpose is to Sustainably make the Pleasure and Benefits of Sports Accessible to the many
</p>
</div>
<div class="footer-col-3">
<h3>Useful Links</h3>
<ul>
<li>Coupons</li>
<li>Blog Post</li>
<li>Return Policy</li>
<li>Join Affiliate</li>
</ul>
</div>
<div class="footer-col-4" data-aos="fade-up">
<h3>Follow Us</h3>
<ul>
<li>Facebook</li>
<li>Twitter</li>
<li>Instagram</li>
<li>Youtube</li>
</ul>
</div>
</div>
<hr />
<p class="copyright">
Copyright ©
<script type="text/javascript">
document.write(new Date().getFullYear());
</script>
- RedStore
</p>
</div>
</div>
<!-- --------------JS for toggle menu--------- -->
<script>
var MenuItems = document.getElementById("MenuItems");
MenuItems.style.maxHeight = "0px";
function menutoggle() {
if (MenuItems.style.maxHeight == "0px") {
MenuItems.style.maxHeight = "200px";
} else {
MenuItems.style.maxHeight = "0px";
}
}
</script>
<!-- ----------------------JS for Product gallery------------------ -->
<script>
var ProductImg = document.getElementById("ProductImg");
var SmallImg = document.getElementsByClassName("small-img");
SmallImg[0].onclick = function() {
ProductImg.src = SmallImg[0].src;
};
SmallImg[1].onclick = function() {
ProductImg.src = SmallImg[1].src;
};
SmallImg[2].onclick = function() {
ProductImg.src = SmallImg[2].src;
};
SmallImg[3].onclick = function() {
ProductImg.src = SmallImg[3].src;
};
</script>
<script src="https://unpkg.com/[email protected]/dist/aos.js"></script>
<script>
AOS.init();
</script>
<script>
const user = {
cart: []
};
let userString = JSON.stringify(user);
if (!localStorage.getItem("user")) {
localStorage.setItem("user", userString);
}
let func = () => {
let img = document.getElementById("ProductImg");
let productName = document.getElementById("productName").textContent;
let productPrice = parseFloat(
document.getElementById("productPrice").textContent
);
let select = document.getElementById("productSize");
let productSize = select.options[select.selectedIndex].value;
let productQuantity = parseFloat(
document.getElementById("productQuantity").value
);
let isProductDuplicate = false;
let id = 0;
let product = {
id,
img: img.src,
productName,
productPrice,
productSize,
productQuantity,
};
console.log("product: ", product);
userString2 = localStorage.getItem("user");
const retrievedUser = JSON.parse(userString2);
console.log("user after retrieving: ", retrievedUser);
retrievedUser.cart.forEach(cartItem => {
if (cartItem.id === product.id && cartItem.productSize === product.productSize) {
cartItem.productQuantity = +cartItem.productQuantity + +product.productQuantity
isProductDuplicate = true;
}
})
if (!isProductDuplicate) retrievedUser.cart.push(product);
console.log("user after updating: ", retrievedUser);
const updatedUserString = JSON.stringify(retrievedUser);
localStorage.setItem("user", updatedUserString);
showToast();
};
const ball = document.querySelector(".toggle-ball");
const items = document.querySelectorAll(".row,body,.menu-icon,.container,.navbar,.header,.toggle");
ball.addEventListener("click", () => {
items.forEach(item => {
item.classList.toggle("active")
})
ball.classList.toggle("active")
})
// const myObjectString = JSON.stringify(myObject);
// localStorage.setItem("objectGreeting", myObjectString);
const showToast = () => {
let toast = document.getElementById("toast");
toast.className = "showToast";
setTimeout(function() {
toast.className = toast.className.replace("showToast", "");
}, 3000);
}
const increaseQuantity = () => {
const productQuantity = document.querySelector("#productQuantity");
productQuantity.value = Number(productQuantity.value) + 1;
}
const decreaseQuantity = () => {
const productQuantity = document.querySelector("#productQuantity");
if (productQuantity.value >= 2)
productQuantity.value = Number(productQuantity.value) - 1;
}
const checkValid = () => {
const productQuantity = document.querySelector("#productQuantity");
if (Number(productQuantity.value) < 1) {
productQuantity.value = 1;
}
}
</script>
</body>
</html>