-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwatches.js
151 lines (90 loc) · 3.06 KB
/
watches.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
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
var p=JSON.parse(localStorage.getItem("productdetail"))
function iswatch(value) {
return value.type=="watch"
}
var prod=p.filter(iswatch)
Displayitem(prod)
function handlepricesort(){
var selected=document.querySelector("#priceSort").value
if(selected=="low"){
prod.sort(function(a,b){
return Number(a.price)-Number(b.price)
})
Displayitem(prod)
}
else{
prod.sort(function(a,b){
return Number(b.price)-Number(a.price)
})
Displayitem(prod)
}
}
function Displayitem(products){
document.querySelector('#cont').textContent=""
products.map(function (ele){
var imag=document.createElement("img")
imag.setAttribute("src",ele.img)
var c=ele
var h3=document.createElement('h3')
h3.textContent=ele.name
var h2=document.createElement('h2')
h2.textContent="Rs."+ele.price
var h5=document.createElement('h5')
h5.textContent= "Rs. "+ele.mrp
var disc=document.createElement('h3')
disc.textContent="Discount "+ele.discount+"%"
var button=document.createElement("button")
button.addEventListener("click",function(){
addtocart(ele)
})
button.textContent="Add to cart"
button.setAttribute('id','addtocartbtn')
var discdiv=document.createElement('div')
discdiv.append(disc,button)
discdiv.setAttribute('id',"disc")
// var p=document.createElement("p")
// p.textContent=ele.type
var divi=document.createElement('div')
var divii=document.createElement('div')
var diviii=document.createElement('div')
var pricediv=document.createElement('div')
divi.append(imag)
divii.append(h3,pricediv,discdiv)
pricediv.append(h2,h5)
diviii.append(divi,divii)
document.querySelector('#cont').append(diviii)
divi.addEventListener("click",function(){
localStorage.setItem("one",JSON.stringify(c))
window.location.href="onepro.html"
})
})
}
var cart=[]||JSON.parse(localStorage.getItem("procart"))
function addtocart(ele){
cart.push(ele)
localStorage.setItem("procart",JSON.stringify(cart))
}
document.querySelector("#shop").addEventListener("click",function(){
window.location.href="productpage.html"
})
document.querySelector("#boatlogo").addEventListener('click',function(){
window.location.href="home.html"
})
document.querySelector(".gg-shopping-cart").addEventListener("click",function(){
window.location.href="cart.html"
})
document.querySelector(".gg-user").addEventListener("click",function(){
window.location.href="signin.html"
})
document.querySelector("#daily").addEventListener("click",function(){
window.location.href="dailydeals.html"
})
document.querySelector("#Wiredpage").addEventListener("click",function(){
window.location.href="wired.html"
})
document.querySelector("#Wirelesspage").addEventListener("click",function(){
window.location.href="wireless.html"
})
document.querySelector("#Watchespage").addEventListener("click",function(){
window.location.href="watches.html"
})