forked from Rohit27698/carver_Clone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prodata.js
123 lines (81 loc) · 3.2 KB
/
prodata.js
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
// import navbar from "./navbar.js";
// let navbarDiv = document.getElementById("navbar_div");
// navbarDiv.innerHTML = navbar();
// import footer from ".footer.js";
// let footerdiv=document.getElementById("footer")
// footerdiv.innerHTML=footer();
var Descdata = JSON.parse(localStorage.getItem('productDetail'))|| [];
display(Descdata)
function display(Descdata){
document.getElementById("container").innerText = ""
Descdata.map((elem)=>{
var imgDiv = document.createElement("div")
imgDiv.id = "imgdiv"
// imgDiv.style.boxShadow = " rgba(0, 0, 0, 0.24) 0px 3px 8px"
let img = document.createElement("img")
img.src = elem.image;
img.style.height = "700px";
img.style.width = "800px";
let descriptionDiv = document.createElement("div")
descriptionDiv.id='seconddiv'
let description = document.createElement("p")
description.textContent = elem.description;
description.style.fontSize = "30px"
description.id = "descdiv"
// description.style.font-weight = "bold";
let price = document.createElement("p")
price.textContent = "price: $"+ elem.price;
price.style.fontSize = "23px"
price.id = "textPrice"
let hr = document.createElement("hr")
hr.style.border= "solid";
let addbtn = document.createElement("button")
addbtn.textContent = "Add to Bag";
// addbtn.style.fontSize = "50px"
addbtn.id = "addbtn";
addbtn.addEventListener("click",function(){
addToCart(elem);
})
let Description = document.createElement("p")
Description.textContent = elem.Description;
price.style.fontSize = "23px"
let TruckOption = document.createElement("p")
TruckOption.textContent= "Truck Option : " +elem.Truck_Option;
let Truck_Color = document.createElement("p")
Truck_Color.textContent= "Truck Color :"+ elem.Truck_Color;
let Wheels = document.createElement("p")
Wheels.textContent= "Wheels : " +elem.Wheels;
let Bearings = document.createElement("p")
Bearings.textContent= "Bearings : " +elem.Bearings;
let Grip_Tape = document.createElement("p")
Grip_Tape.textContent= "Grip_Tape : " + elem.Grip_Tape;
let Hardware = document.createElement("p")
Hardware.textContent= "Hardware : "+ elem.Hardware;
let Length = document.createElement("p")
Length.textContent= "Length : " +elem.Length;
let Width = document.createElement("p")
Width.textContent= "Width : " +elem.Width;
let Wheelbase = document.createElement("p")
Wheelbase.textContent= "Wheelbase : " + elem.Wheelbase;
descriptionDiv.append(description , price ,hr, addbtn ,Description , TruckOption,Truck_Color,Wheels, Bearings,Grip_Tape,Hardware,Length, Width,Wheelbase )
imgDiv.append(img)
container.append(imgDiv , descriptionDiv )
})
}
let cartdata = []
function addToCart(elem){
cartdata.push(elem)
localStorage.setItem('cartDetail' , JSON.stringify(cartdata))
// window.location.href = "cart.html";
}
// let cartArray = JSON.parse(localStorage.getItem("cartItem")) || [];
// let count=0;
// function addToCart(products) {
// count+=1;
// if(count>1){
// alert("Already added to Cart");
// return;
// }
// cartArray.push(products);
// localStorage.setItem("cartItem", JSON.stringify(cartArray));
// }