-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinner-page.html
1183 lines (1006 loc) · 49.1 KB
/
inner-page.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
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<title>Magna</title>
<meta content="" name="description">
<meta content="" name="keywords">
<!-- Favicons -->
<link href="assets/img/favicon.png" rel="icon">
<link href="assets/img/apple-touch-icon.png" rel="apple-touch-icon">
<!-- Google Fonts -->
<link
href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i|Raleway:300,300i,400,400i,500,500i,600,600i,700,700i|Poppins:300,300i,400,400i,500,500i,600,600i,700,700i"
rel="stylesheet">
<!-- Vendor CSS Files -->
<link href="assets/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="assets/vendor/bootstrap-icons/bootstrap-icons.css" rel="stylesheet">
<link href="assets/vendor/boxicons/css/boxicons.min.css" rel="stylesheet">
<link href="assets/vendor/glightbox/css/glightbox.min.css" rel="stylesheet">
<link href="assets/vendor/swiper/swiper-bundle.min.css" rel="stylesheet">
<!-- Template Main CSS File -->
<link href="assets/css/style.css" rel="stylesheet">
<script>
</script>
</head>
<body>
<!-- ======= Header ======= -->
<header id="header" class="fixed-top">
<div class="container d-flex align-items-center justify-content-between">
<h1 class="logo"> <i onclick="goBackToProductPage()"
style="margin-right: 30px; position: absolute; left: 40px; font-size: 35px; cursor: pointer;"
class="bi bi-arrow-left-short"></i><a href="index.html">Magna</a></h1>
<!-- Uncomment below if you prefer to use an image logo -->
<!-- <a href="index.html" class="logo"><img src="assets/img/logo.png" alt="" class="img-fluid"></a>-->
<nav id="navbar" class="navbar">
<ul>
<li><a class="nav-link scrollto active" href="index.html"><i style="font-size: 25px;" class="bi bi-house-door-fill"></i></a></li>
<li style="cursor: pointer;" onclick="gotoCartPage(),addCurrentCartId(1)" data-bs-toggle="offcanvas"
data-bs-target="#offcanvasRight" aria-controls="offcanvasRight">
<a>
<i style="font-size: 25px;" class="bi bi-cart-fill" style="font-size: 20px; margin-left: 25px; color: #5f687b;"></i>
<span id="cartCount" class="cart-count">0</span>
</a>
</li>
<li id="logged-in" id="cartButton" style="display: none;"><a id="logout" class="nav-link scrollto" href="#"><i style="font-size: 25px;" class="bi bi-box-arrow-right"></i></a></li>
</ul>
<i class="bi bi-list mobile-nav-toggle"></i>
</nav><!-- .navbar -->
<style>
.cart-count {
position: absolute;
top: 5px;
right: 15px;
background-color: #ff0000;
color: #fff;
width: 25px;
text-align: center;
border-radius: 40%;
padding: 5px;
font-size: 12px;
}
</style>
</div>
</header><!-- End Header -->
<main id="main">
<section id="product-page-real">
<section id="portfolio" class="portfolio">
<div class="container">
<div class="section-title">
<span>Products</span>
<h2>Products</h2>
<p onclick="speakText('Experience shopping made simple with our uniquely user-friendly platform')" class="font-size-element">Experience shopping made simple with our uniquely user-friendly platform</p>
</div>
<div class="row">
<div class="col-lg-12 d-flex justify-content-center">
<ul id="portfolio-flters">
<li class="font-size-element" data-filter="*" class="filter-active">All</li>
<li class="font-size-element" data-filter=".filter-elec">Electronics</li>
<li class="font-size-element" data-filter=".filter-cloth">Clothes</li>
<li class="font-size-element" data-filter=".filter-sport">Sports</li>
</ul>
</div>
</div>
<style>
.product-card {
background-color: rgb(109, 117, 172);
color: aliceblue;
border-radius: 15px;
padding: 5px 15px;
}
.product-actions {
display: flex;
justify-content: space-around;
right: 0%;
font-size: 30px;
background-color: #1c1033;
border-radius: 20px;
margin-bottom: 15px;
}
.product-item img {
margin-top: 12px;
margin-bottom: 12px;
border-radius: 10px;
}
.product-card p {
font-size: 30px;
}
</style>
<div class="row portfolio-container">
<div class="product-item col-lg-4 col-md-6 portfolio-item filter-cloth">
<div class="product-card">
<img src="assets/img/portfolio/portfolio1.jpg" class="img-fluid" alt="Product Image">
<div class="product-info">
<h4 style="color: aliceblue;">Graphic Black T-Shirt</h4>
<p style="color: aliceblue;font-size: 30px;" class="price">$49.99</p>
<!-- Additional information like product description, ratings, etc. can be added here -->
<div style="align-content: center;" class="product-actions">
<a onclick="gotoCartPage(),addCurrentCartId(1)" style="cursor: pointer; color: rgb(77, 238, 99);"
title="add to cart"><i class="bx bx-cart-add"></i></a>
<a onclick="changepage(1)" class="details-link"><button class="btn btn-success">Buy Now</button></a>
</div>
</div>
</div>
</div>
<div class="product-item col-lg-4 col-md-6 portfolio-item filter-sport">
<div class="product-card">
<img src="assets/img/portfolio/portfolio2.jpg" class="img-fluid" alt="">
<div class="product-info">
<h4 style="color: aliceblue;">Leather Football</h4>
<p style="font-size: 30px;" class="price">$30.00</p>
<div class="product-actions">
<a onclick="gotoCartPage(),addCurrentCartId(2)" style="cursor: pointer; color: rgb(77, 238, 99);"
title="add to cart"><i class="bx bx-cart-add"></i></a>
<a onclick="changepage(2)" class="details-link"><button class="btn btn-success">Buy Now</button></a>
</div>
</div>
</div>
</div>
<div class="product-item col-lg-4 col-md-6 portfolio-item filter-sport">
<div class="product-card">
<img src="assets/img/portfolio/portfolio3.jpg" class="img-fluid" alt="">
<div class="product-info">
<h4 style="color: aliceblue;">Cricket Bat</h4>
<p style="font-size: 30px;" class="price">$19.89</p>
<div class="product-actions">
<a onclick="gotoCartPage(),addCurrentCartId(3)" style="cursor: pointer; color: rgb(77, 238, 99);"
title="add to cart"><i class="bx bx-cart-add"></i></a>
<a onclick="changepage(3)" class="details-link"><button class="btn btn-success">Buy Now</button></a>
</div>
</div>
</div>
</div>
<div class="product-item col-lg-4 col-md-6 portfolio-item filter-cloth">
<div class="product-card">
<img src="assets/img/portfolio/portfolio-4.jpg" class="img-fluid" alt="">
<div class="product-info">
<h4 style="color: aliceblue;">Black Sunglasses</h4>
<p style="font-size: 30px;" class="price">$14.49</p>
<div class="product-actions">
<a onclick="gotoCartPage(),addCurrentCartId(4)" style="cursor: pointer; color: rgb(77, 238, 99);"
title="add to cart"><i class="bx bx-cart-add"></i></a>
<a onclick="changepage(4)" class="details-link"><button class="btn btn-success">Buy Now</button></a>
</div>
</div>
</div>
</div>
<div class="product-item col-lg-4 col-md-6 portfolio-item filter-elec">
<div class="product-card">
<img src="assets/img/portfolio/portfolio-5.jpg" class="img-fluid" alt="">
<div class="product-info">
<h4 style="color: aliceblue;">Swing Arm Desk Lamp</h4>
<p style="font-size: 30px;" class="price">$65.00</p>
<div class="product-actions">
<a onclick="gotoCartPage(),addCurrentCartId(5)" style="cursor: pointer; color: rgb(77, 238, 99);"
title="add to cart"><i class="bx bx-cart-add"></i></a>
<a onclick="changepage(5)" class="details-link"><button class="btn btn-success">Buy Now</button></a>
</div>
</div>
</div>
</div>
<div class="product-item col-lg-4 col-md-6 portfolio-item filter-elec">
<div class="product-card">
<img src="assets/img/portfolio/portfolio6.jpg" class="img-fluid" alt="">
<div class="product-info">
<h4 style="color: aliceblue;">Wireless Headphones (Black)</h4>
<p style="font-size: 30px;" class="price">$89.99</p>
<div class="product-actions">
<a onclick="gotoCartPage(),addCurrentCartId(6)" style="cursor: pointer; color: rgb(77, 238, 99);"
title="add to cart"><i class="bx bx-cart-add"></i></a>
<a onclick="changepage(6)" class="details-link"><button class="btn btn-success">Buy Now</button></a>
</div>
</div>
</div>
</div>
<div class="product-item col-lg-4 col-md-6 portfolio-item filter-elec">
<div class="product-card">
<img src="assets/img/portfolio/portfolio-7.jpg" class="img-fluid" alt="">
<div class="product-info">
<h4 style="color: aliceblue;">EX Macro Lens</h4>
<p style="font-size: 30px;" class="price">$249.99</p>
<div class="product-actions">
<a onclick="gotoCartPage(),addCurrentCartId(8)" style="cursor: pointer; color: rgb(77, 238, 99);"
title="add to cart"><i class="bx bx-cart-add"></i></a>
<a onclick="changepage(8)" class="details-link"><button class="btn btn-success">Buy Now</button></a>
</div>
</div>
</div>
</div>
<div class="product-item col-lg-4 col-md-6 portfolio-item filter-sport">
<div class="product-card">
<img src="assets/img/portfolio/portfolio8.jpg" class="img-fluid" alt="">
<div id="7" class="product-info">
<h4 style="color: aliceblue;">Cricket Helmet</h4>
<p style="font-size: 30px;" class="price">$149.99</p>
<div class="product-actions">
<a onclick="gotoCartPage(),addCurrentCartId(7)" style="cursor: pointer; color: rgb(77, 238, 99);"
title="add to cart"><i class="bx bx-cart-add"></i></a>
<a onclick="changepage(7)" class="details-link"><button class="btn btn-success">Buy Now</button></a>
</div>
</div>
</div>
</div>
<div class="product-item col-lg-4 col-md-6 portfolio-item filter-cloth">
<div class="product-card">
<img src="assets/img/portfolio/portfolio9.jpg" class="img-fluid" alt="">
<div class="product-info">
<h4 style="color: aliceblue;">Puffer Jacket (Yellow)</h4>
<p style="font-size: 30px;" class="price">$35.00</p>
<div class="product-actions">
<a onclick="gotoCartPage(),addCurrentCartId(9)" style="cursor: pointer; color: rgb(77, 238, 99);"
title="add to cart"><i class="bx bx-cart-add"></i></a>
<a onclick="changepage(9)" class="details-link"><button class="btn btn-success">Buy Now</button></a>
</div>
</div>
</div>
</div>
</div>
</div>
</section><!-- End Portfolio Section -->
<!-- ======= Testimonials Section ======= -->
<section id="testimonials" class="testimonials section-bg">
<div class="container">
<div class="section-title">
<span>You may also like</span>
<h2>You may also like</h2>
</div>
<div class="testimonials-slider swiper" data-aos="fade-up" data-aos-delay="100">
<div class="swiper-wrapper">
<div class="swiper-slide">
<div style="width: 300px" class="product-item col-lg-4 col-md-6 portfolio-item filter-cloth">
<div class="product-card">
<img src="assets/img/portfolio/watch.jpg" class="img-fluid" alt="">
<div class="product-info">
<h4>Mens Watch </h4>
<p>$240.00</p>
<div class="product-actions">
<a onclick="gotoCartPage(),addCurrentCartId(11)"
style="cursor: pointer; color: rgb(77, 238, 99);" title="add to cart"><i
class="bx bx-cart-add"></i></a>
<a onclick="changepage(11)" class="details-link"><button class="btn btn-success">Buy
Now</button></a>
</div>
</div>
</div>
</div>
</div><!-- End testimonial item -->
<div class="swiper-slide">
<div style="width: 300px" class="product-item col-lg-4 col-md-6 portfolio-item filter-cloth">
<div class="product-card">
<img src="assets/img/portfolio/blazer.jpg" class="img-fluid" alt="">
<div class="product-info">
<h4>Blazer (Women)</h4>
<p>$50.00</p>
<div class="product-actions">
<a onclick="gotoCartPage(),addCurrentCartId(13)"
style="cursor: pointer; color: rgb(77, 238, 99);" title="add to cart"><i
class="bx bx-cart-add"></i></a>
<a onclick="changepage(13)" class="details-link"><button class="btn btn-success">Buy
Now</button></a>
</div>
</div>
</div>
</div>
</div><!-- End testimonial item -->
<div class="swiper-slide">
<div style="width: 300px" class="product-item col-lg-4 col-md-6 portfolio-item filter-cloth">
<div class="product-card">
<img src="assets/img/portfolio/night light.jpg" class="img-fluid" alt="">
<div class="product-info">
<h4>Night Light</h4>
<p>$150.00</p>
<div class="product-actions">
<a onclick="gotoCartPage(),addCurrentCartId(12)"
style="cursor: pointer; color: rgb(77, 238, 99);" title="add to cart"><i
class="bx bx-cart-add"></i></a>
<a onclick="changepage(12)" class="details-link"><button class="btn btn-success">Buy
Now</button></a>
</div>
</div>
</div>
</div>
</div><!-- End testimonial item -->
</div><!-- End testimonial item -->
</div>
<div class="swiper-pagination"></div>
</div>
</div>
</section><!-- End Testimonials Section -->
<style>
.product-actions{
display: flex;
align-items: center;
justify-content: space-between;
padding: 15px;
}
</style>
</main><!-- End #main -->
</section>
<!-- =========================================================================================================== -->
<!-- PRODUCT DESCRIPTION PAGE -->
<!-- =========================================================================================================== -->
<section id="productDescripton-section" style="display: none;">
<main id="main">
<!-- ======= Breadcrumbs ======= -->
<section id="breadcrumbs" class="breadcrumbs">
<div class="container">
<div class="d-flex justify-content-between align-items-center">
<h2>Product Details</h2>
<ol>
<li><a href="index.html">Home</a></li>
<li class="font-size-element">Product Details</li>
</ol>
</div>
</div>
</section><!-- End Breadcrumbs -->
<!-- ======= Products Details Section ======= -->
<section id="portfolio-details" class="portfolio-details">
<div class="container">
<div class="row gy-4">
<div class="col-lg-8">
<div class="portfolio-details-slider swiper">
<div class="swiper-wrapper align-items-center">
<div class="swiper-slide">
<img id="productImage1" src="assets/img/portfolio/portfolio-1.jpg" alt="">
</div>
<div class="swiper-slide">
<img src="assets/img/portfolio/portfolio-2.jpg" alt="">
</div>
<div class="swiper-slide">
<img src="assets/img/portfolio/portfolio-3.jpg" alt="">
</div>
</div>
<div class="swiper-pagination"></div>
</div>
</div>
<div class="col-lg-4">
<div class="portfolio-info">
<h2 id="productName"></h2>
<ul>
<!-- <li><strong>Category</strong>: design</li> -->
<li class="font-size-element"><strong>Client</strong>: Navigo Company</li>
<li class="font-size-element"><strong>Product date</strong>: 24 March, 2024</li>
<li class="font-size-element"><strong>Status</strong>: Available</li>
</ul>
</div>
<form method="post"> <!-- Change the form action to your purchase processing page -->
<label for="quantity">Quantity</label>
<input onchange="window.updatePrice()" name="quantity" placeholder="Quantity" type="number" id="quantity"
value="1" min="1">
<h2 id="productPrice" style="font-weight: 500;font-size:50px;">
</h3>
<a class="btn btn-primary btn-lg" style="cursor: pointer; margin-top: 20px;" href=""
onclick="alert('Purchased yey!!'); return false;">Buy Now</a>
</form>
<div class="portfolio-description">
<h2>Product Details</h2>
<p class="font-size-element" id="productDescriptionMore">
Autem ipsum nam porro corporis rerum. Quis eos dolorem eos itaque inventore commodi labore quia quia.
Exercitationem repudiandae officiis neque suscipit non officia eaque itaque enim. Voluptatem officia
accusantium nesciunt est omnis tempora consectetur dignissimos. Sequi nulla at esse enim cum deserunt
eius.
</p>
</div>
</div>
<style>
/* Style for custom input */
#quantity {
padding: 10px;
border-radius: 5px;
border: 1px solid #ced4da;
font-size: 1em;
width: 100%;
margin-bottom: 15px;
box-sizing: border-box;
}
#quantity:focus {
border-color: #007bff;
outline: none;
}
</style>
</div>
</div>
</section><!-- End Portfolio Details Section -->
</main><!-- End #main -->
</section>
<!-- ================================================================================================================================= -->
<!-- cart section -->
<!-- ================================================================================================================================= -->
<section id="cart-section" style="display: none">
<section id="cart-section">
<div style=" position: absolute;width: 100%;margin-left: 5%; top:5%;bottom: 100px;" class="container mt-5">
<!-- Cart Summary (fixed top) -->
<div style="width: 50%; position:absolute;top: 100px;">
<div class="card">
<div class="card-body">
<h5 style="font-size: 40px" class="card-title mb-4">Cart Summary</h5>
<hr>
<p style="font-size: 25px;" class="mb-1">Total Items: <span id="totalItems" class="fw-bold">0</span></p>
<p style="font-size: 25px;" class="mb-4">Total Price: <span id="totalPrice" class="fw-bold">$0.00</span>
</p>
<button class="btn btn-primary btn-block" onclick="checkout()">Checkout</button>
</div>
</div>
</div>
<!-- Product Cards -->
<div style="align-items:center;position:absolute;top: 350px;bottom:20px;margin-bottom: 30px;" id="product-cards"
class="mt-5">
<!-- Product cards will be dynamically added here -->
</div>
</div>
<br><br><br>
</section>
<style>
.cart-summary {
width: 300px;
/* Adjust width as needed */
top: 90px;
right: 10px;
z-index: 1000;
/* Ensure it appears above other elements */
}
.card-container {
margin-top: 120px;
/* Adjust margin to leave space for cart summary */
}
</style>
<script>
window.currentlyAddedProduct = 1
function addCurrentCartId(btnid) {
window.currentlyAddedProduct = btnid
window.addToCartIfNeeded(window.currentlyAddedProduct)
}
function checkout()
{
alert("Purchased worth of "+window.alltotalprice)
}
</script>
</section>
<script type="module">
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.8.0/firebase-app.js";
import { getFirestore, collection, addDoc,doc, deleteDoc, setDoc, getDocs, query, where } from "https://www.gstatic.com/firebasejs/10.8.0/firebase-firestore.js";
import { getAuth } from "https://www.gstatic.com/firebasejs/10.8.0/firebase-auth.js"
// Firebase configuration
const firebaseConfig = {
apiKey: "AIzaSyAbzDGgeZCaiq-dmWQNqnpq_yi6KLyn_Q0",
authDomain: "miniproject-740e2.firebaseapp.com",
projectId: "miniproject-740e2",
storageBucket: "miniproject-740e2.appspot.com",
messagingSenderId: "493659960891",
appId: "1:493659960891:web:d8908059f91a37a6bc8e1e",
measurementId: "G-49BHFJDWQD",
databaseURL: "https://miniproject-740e2-default-rtdb.asia-southeast1.firebasedatabase.app/"
};
const app = initializeApp(firebaseConfig);
const db = getFirestore(app);
initializeApp(firebaseConfig);
const auth = getAuth(app);
// product description read out
function speakText(text) {
const selectedVoicePromise = getSpecificVoice();
selectedVoicePromise.then(selectedVoice => {
if (selectedVoice) {
const utterance = new SpeechSynthesisUtterance(text);
utterance.voice = selectedVoice;
speechSynthesis.cancel(); // Stop any ongoing speech
speechSynthesis.speak(utterance);
utterance.onend = function () {
// Speech has ended
console.log('Speech ended');
};
} else {
console.error('No valid voice selected');
}
}).catch(error => {
console.error('Error getting specific voice:', error);
});
}
function getSpecificVoice() {
const voiceName = 'Google UK English Female';
return new Promise((resolve, reject) => {
const waitForVoices = setInterval(() => {
const voices = speechSynthesis.getVoices();
if (voices.length) {
clearInterval(waitForVoices);
const selectedVoice = voices.find(voice => voice.name === voiceName);
resolve(selectedVoice);
}
}, 100);
// Timeout after 5 seconds if voices are not available
setTimeout(() => {
clearInterval(waitForVoices);
reject('Voices not available');
}, 5000);
});
}
// Call getSpecificVoice() and handle the promise
getSpecificVoice().then(selectedVoice => {
// console.log(selectedVoice);
}).catch(error => {
console.error(error);
});
const productDetailsArray = {
1: {
title: "Black Tshirt",
description: "Elevate your style with this classic Men's Printed Round Neck Pure Cotton Black T-Shirt. Crafted for comfort and designed to make a statement, this timeless piece is a must-have for every wardrobe.",
price: "$49.99",
image1: "assets/img/portfolio/portfolio1.jpg",
productId: 1000,
},
2: {
title: "Leather Football",
description: "Unleash your skills on the field with the MAYOR Sammy-3 Football. Made from high-quality leather and designed for optimal performance, this football ensures precision and durability in every game.",
price: "$30.00",
image1: "assets/img/portfolio/portfolio2.jpg",
productId: 1200,
},
3: {
title: "Cricket Bat",
description: "Dominate the cricket pitch with the CEAT Poplar Willow Cricket Bat. Handcrafted for power and precision, this bat delivers exceptional performance and responsiveness, making it the perfect choice for every aspiring cricketer.",
price: "$19.89",
image1: "assets/img/portfolio/portfolio3.jpg",
productId: 1300,
},
4: {
title: "Black Sunglasses",
description: "Stay cool and stylish with these RAYBAN Aviator Sunglasses. Featuring UV protection and a timeless design, these sunglasses are the perfect blend of fashion and function for both men and women.",
price: "$14.49",
image1: "assets/img/portfolio/portfolio-4.jpg",
productId: 1400,
},
5: {
title: "Swing Arm Desk Lamp",
description: "Illuminate your workspace with the Ziggy Flexible Wooden LED Desk Lamp. With its adjustable swing arm and touch-sensitive controls, this lamp provides versatile lighting options for study, reading, or relaxing.",
price: "$65.00",
image1: "assets/img/portfolio/portfolio-5.jpg",
productId: 1500,
},
6: {
title: "Wireless Headphones (Black)",
description: "Immerse yourself in your favorite music with the JBL Tune 770NC Wireless Headphones. Featuring active noise cancellation and a long battery life, these headphones deliver superior sound quality and comfort for an unparalleled listening experience.",
price: "$89.99",
image1: "assets/img/portfolio/portfolio6.jpg",
productId: 1600,
},
7: {
title: "Cricket Helmet",
description: "Stay protected on the cricket field with the MOONWALKR Cricket Helmet. Designed for players aged 11 and above, this helmet features a detachable grill for added convenience and safety.",
price: "$149.99",
image1: "assets/img/portfolio/portfolio8.jpg",
productId: 1700,
},
8: {
title: "EX Macro Lens",
description: "Capture stunning close-up shots with the SONY SEL90M28G Macro Zoom Lens. Whether you're photographing nature, food, or intricate details, this lens delivers exceptional image quality and clarity.",
price: "$249.99",
image1: "assets/img/portfolio/portfolio-7.jpg",
productId: 1800,
},
9: {
title: "Puffer Jacket (Yellow)",
description: "Stay warm and stylish in the colder months with this Men's Colorblock Puffer Jacket. Featuring a vibrant yellow hue and a cozy design, this jacket is perfect for outdoor adventures or casual outings.",
price: "$35.00",
image1: "assets/img/portfolio/portfolio9.jpg",
productId: 1900,
},
10: {
title: "Water Bottle",
description: "Stay hydrated on the go with the MILTON Handy 650 Stainless Steel Water Bottle. Designed for durability and convenience, this bottle is perfect for workouts, travel, or everyday use.",
price: "$100.00",
image1: "assets/img/portfolio/bottle.jpg",
productId: 11000,
},
11: {
title: "Men's Watch",
description: "Upgrade your wrist game with this Matte Black Dial Analog Watch. Featuring a minimalistic design and premium craftsmanship, this watch is both stylish and functional, making it the perfect accessory for any occasion.",
price: "$240.00",
image1: "assets/img/portfolio/watch.jpg",
productId: 1110,
},
12: {
title: "Night Light",
description: "Add a warm glow to any room with the QERINKLE LED Sensor Plug Night Lamp. With its compact size and soft orange light, this night light is perfect for bedrooms, offices, or living rooms.",
price: "$150.00",
image1: "assets/img/portfolio/night light.jpg",
productId: 1130,
},
13: {
title: "Blazer (Women)",
description: "Make a bold statement with this Women's Solid Formal Blazer in striking red. Whether you're heading to the office or a special event, this blazer adds a touch of sophistication and elegance to any outfit.",
price: "$50.00",
image1: "assets/img/portfolio/blazer.jpg",
productId: 1140,
}
}
let globalid = 0
window.changepage = function (btnid) {
let page2 = document.getElementById("productDescripton-section")
let page1 = document.getElementById("product-page-real")
page2.style.display = 'block'
page1.style.display = 'none'
globalid = btnid
let productHeadingElement = document.getElementById("productName")
let productPriceElement = document.getElementById("productPrice")
let productDescriptionElement = document.getElementById("productDescriptionMore")
let productImageElement1 = document.getElementById("productImage1")
productHeadingElement.innerText = productDetailsArray[btnid].title
productPriceElement.innerText = productDetailsArray[btnid].price
productDescriptionElement.innerText = productDetailsArray[btnid].description
productImageElement1.src = productDetailsArray[btnid].image1
const readOutText = `You are proceeding to buy ${productDetailsArray[btnid].title} of price ${productDetailsArray[btnid].price}. Please click the blue button to proceed payment.`;
speakText(readOutText);
}
let priceElement = document.getElementById("productPrice");
console.log(priceElement.innerText)
// Define the updatePrice function
window.updatePrice = function() {
let priceString = productDetailsArray[globalid].price; // Get the price string from the product details array
let originalPrice = parseFloat(priceString.replace("$", ""));
let quantityElement = document.getElementById("quantity");
let quantityValue = parseInt(quantityElement.value);
let newPrice = originalPrice * quantityValue;
priceElement.innerText = "$" + newPrice.toFixed(2);
speakText(`Price changed to ${priceElement.innerText}. Click the blue button to proceed`)
}
window.goBackToProductPage = function () {
let page2 = document.getElementById("productDescripton-section")
let page1 = document.getElementById("product-page-real")
let page3 = document.getElementById("cart-section")
if (page2.style.display == 'block') {
page2.style.display = 'none'
page1.style.display = 'block'
page3.style.display = 'none'
}
else if (page3.style.display == 'block') {
page2.style.display = 'none'
page1.style.display = 'block'
page3.style.display = 'none'
}
else{
window.location.href = 'index.html'
}
// Stop any ongoing speech synthesis
speechSynthesis.cancel();
}
// text increase script
var FontSizeElements = document.querySelectorAll('.font-size-element');
let savedSize = localStorage.getItem("fontSize");
// console.log(savedSize)
if (savedSize) {
FontSizeElements.forEach(function (element) {
element.style.fontSize = savedSize;
element.style.lineHeight = savedSize;
});
}
auth.onAuthStateChanged(user=>{
if (user)
{
function getCartItemCount(userId) {
const cartCollectionRef = collection(db, "cart");
const userCartQuery = query(cartCollectionRef, where("user", "==", userId));
return getDocs(userCartQuery)
.then((querySnapshot) => {
return querySnapshot.size;
})
.catch((error) => {
console.error("Error getting cart items:", error);
return 0;
});
}
var userId = user.uid
// Example usage to update cart count
var cartCountElement = document.getElementById("cartCount");
getCartItemCount(userId).then((count) => {
document.getElementById("totalItems").textContent = count;
cartCountElement.textContent = count;
});
}
})
window.addToCartIfNeeded = function (correctId) {
function addToCart(item) {
// Add a new document with a generated ID to the "cart" collection
return addDoc(collection(db, "cart"), item)
.then((docRef) => {
console.log("Document written with ID: ", docRef.id);
return docRef.id; // Return the ID of the newly added document
})
.catch((error) => {
console.error("Error adding document: ", error);
return null; // Return null if there's an error
});
}
var newItem = {};
// Function to fetch cart items for a specific user
function fetchCartItems(userId) {
const cartItems = []; // Array to store cart items
const Cartquery = query(collection(db, "cart"), where("user", "==", userId));
// Execute the query
return getDocs(Cartquery)
.then((querySnapshot) => {
// Loop through the query results
querySnapshot.forEach((doc) => {
// Get the data of each document and push it to the cartItems array
cartItems.push(doc.data());
});
return cartItems;
})
.catch((error) => {
console.error("Error fetching cart items: ", error);
return []; // Return an empty array if there's an error
});
}
auth.onAuthStateChanged(async user => {
if (user) {
console.log(user.uid);
// Construct the new item to add to the cart
var newItem = {
name: productDetailsArray[window.currentlyAddedProduct].title,
price: productDetailsArray[window.currentlyAddedProduct].price,
description: productDetailsArray[window.currentlyAddedProduct].description,
productId: productDetailsArray[window.currentlyAddedProduct].productId,
image: productDetailsArray[window.currentlyAddedProduct].image1,
user: user.uid,
};
// Check if the product already exists in the user's cart
const ProductexistsQuery = query(collection(db, "cart"), where("user", "==", user.uid), where("productId", "==", productDetailsArray[window.currentlyAddedProduct].productId));
const ProductexistsSnapshot = await getDocs(ProductexistsQuery);
const productExists = !ProductexistsSnapshot.empty;
if (!productExists) {
// If the product does not exist in the cart, add it
addToCart(newItem)
.then((docId) => {
if (docId) {
console.log(`Item added to cart with ID: ${docId}`);
} else {
console.log("Failed to add item to cart.");
}
})
.catch(error => {
console.error("Error adding item to cart:", error);
});
} else {
console.log("Product already exists in the cart");
}
// Fetch cart items for the user
const userId = user.uid;
const cartItemsContainer = document.getElementById("product-cards");
fetchCartItems(userId)
.then((cartItems) => {
// Clear existing content
cartItemsContainer.innerHTML = '';
// Create a row to contain the cart items
const row = document.createElement("div");
row.classList.add("row", "row-cols-1", "row-cols-md-5", "g-4");
let totalPrice = 0;
cartItems.forEach((item) => {
totalPrice += parseFloat(item.price.replace("$",""));
});
const totalPriceElement = document.getElementById("totalPrice");
totalPriceElement.textContent = "$" + totalPrice.toFixed(2);
window.alltotalprice = "$" + totalPrice.toFixed(2);
// Loop through the cart items and append them to the container
cartItems.forEach((item) => {
// Display total price in the cart page
// Create a column for each cart item
const col = document.createElement("div");
col.classList.add("col");
col.style.width = '250px';
// Create a card for the cart item
const card = document.createElement("div");
card.classList.add("card", "h-100");
// Construct the card body with item details
const cardBody = document.createElement("div");
cardBody.classList.add("card-body");
// Add item details to the card body
cardBody.innerHTML = `
<h5 class="font-size-element" class="card-title">${item.name}</h5>
<img style="object-fit: contain;height:100px;width:100px;" src="${item.image}">
<p class="font-size-element" class="card-text"><strong>Price: ${item.price}</strong></p>
`;
// Add a delete button
const deleteButton = document.createElement("button");
deleteButton.classList.add("btn", "btn-danger", "btn-sm");
deleteButton.innerText = "Remove";
deleteButton.addEventListener("click", () => {
// Call a function to delete the item from the cart
const productIdString = item.productId.toString();
deleteCartItem(productIdString);
deleteButton.closest('.col').remove();
});
// Append the delete button to the card body
cardBody.appendChild(deleteButton);
// Append the card body to the card
card.appendChild(cardBody);
// Append the card to the column
col.appendChild(card);
// Append the column to the row
row.appendChild(col);
});
// Append the row to the container
cartItemsContainer.appendChild(row);
})
.catch(error => {
console.error("Error fetching cart items:", error);
});
// Function to delete an item from the cart
async function deleteCartItem(productId) {
try {
// Get a reference to the document to delete
const docRef = doc(db, "cart", productId);
// Delete the document
await deleteDoc(docRef);
console.log("Item removed from cart successfully");
} catch (error) {
console.error("Error removing item from cart:", error);
}
}
// Function to get the count of cart items for a user
function getCartItemCount(userId) {
const cartCollectionRef = collection(db, "cart");
const userCartQuery = query(cartCollectionRef, where("user", "==", userId));
return getDocs(userCartQuery)
.then((querySnapshot) => {
return querySnapshot.size;
})
.catch((error) => {
console.error("Error getting cart items:", error);
return 0;
});
}
// Example usage to update cart count
var cartCountElement = document.getElementById("cartCount");
getCartItemCount(userId).then((count) => {
document.getElementById("totalItems").textContent = count;