-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdes.js
118 lines (83 loc) · 2.83 KB
/
des.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
// let productData = [
// {
// image:
// "https://pisces.bbystatic.com/image2/BestBuy_US/images/products/6509/6509652_sd.jpg;maxHeight=200;maxWidth=300",
// name: 'MacBook Pro 13.3" Laptop - Apple M2 chip - 8GB Memory - 256GB SSD (Latest Model) - Space Gray',
// price: "1299.00",
// model: "MacBook",
// id: 202216,
// saveprice: "250",
// },]
// import Navabar
// // import navbar here
import { navbar } from "./components/navbar_comp.js";
let navbar_div = document.getElementById('navbar');
navbar_div.innerHTML = navbar();
import {topbarFunc} from "./components/topbar.js"
let topbar_div = document.getElementById('topbar')
topbar_div.innerHTML = topbarFunc()
import {hamburgerdisplay, aieadisplay, holidayDropdown, moreDropdown, accountsDropdown, recentlyViewedDropdown, orderStatusDropdown, savedItemsDropdown, cart_link} from "./scripts/navbar.js"
hamburgerdisplay()
aieadisplay()
holidayDropdown()
moreDropdown()
accountsDropdown()
recentlyViewedDropdown()
orderStatusDropdown()
savedItemsDropdown()
cart_link()
// // import footer
import { footer } from "./components/footer.js";
let footer_div = document.getElementById('footer');
footer_div.innerHTML = footer();
let data=JSON.parse(localStorage.getItem("prod_desc"))
display(data)
var cart=JSON.parse(localStorage.getItem("cart_item"))||[];
function display(productData){
let maindiv=document.getElementById("main12");
let price2=document.getElementById("id123")
let sac2=document.getElementById("sac2")
let sac1=document.getElementById("sac")
productData.forEach(function(el){
let div=document.createElement("div");
let des=document.createElement("p");
des.innerText=el.name;
des.id="des"
let sku=document.createElement("p");
sku.innerText="sku:112321";
sku.id="sku"
let button1=document.createElement("button");
button1.innerText=""
let img1=document.createElement("img");
img1.src=el.image;
img1.id="img11"
let model=document.createElement("p");
model.innerText=`model:${el.model}`;
model.id="model"
let save1=document.getElementById("save")
save1.innerText=`save:$${el.saveprice}`
let price1=document.createElement("h3");
price1.innerText=`$${el.price}`
let btn12=document.createElement("button")
btn12.innerText="Add to Cart"
btn12.id="btn12"
btn12.addEventListener("click",function(){
additem(el)
})
let btn13=document.createElement("button")
btn13.innerText="Build a Bundle"
btn13.id="btn13"
let div2=document.createElement("div");
div2.append(price1)
sac1.append(btn12)
sac2.append(btn13)
price2.append(div2)
div.append(des,model,sku,img1);
maindiv.append(div)
})
// localstora
function additem(el){
let data = JSON.parse(localStorage.getItem("cart_data")) || []
data.push(el)
localStorage.setItem("cart_data",JSON.stringify(data));
}}