-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPageskeleton.html
More file actions
332 lines (287 loc) · 10.2 KB
/
Copy pathPageskeleton.html
File metadata and controls
332 lines (287 loc) · 10.2 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Online Products</title>
<style>
#heading{
width:75%;
margin: auto;
color: rgb(24, 24, 24);
}
#optionsForSort{
width:75%;
margin: auto;
padding-top: 10px;
padding-bottom : 15px;
background-color: white;
display: flex;
gap: 1.4% ;
border-bottom: 1px solid rgba(56, 55, 55, 0.479);
position: sticky;
top:0;
}
#container{
width: 75%;
display: grid ;
grid-template-columns: repeat(4, 24%);
/* border: 1.5px solid red; */
margin: auto;
column-gap : 1.4%;
row-gap : 20px;
font-family: Lato,sans-serif;
}
#optionsForSort > select{
width : 33% ;
height: 55px;
padding: 10px;
border-radius: 6px;
padding-right: 10px;
font-size: 15px;
}
select option {
margin: 40px;
background: rgba(0, 0, 0, 0.3);
color: #fff;
text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}
#maindiv {
height: 280px ;
box-shadow: rgba(9, 30, 66, 0.25) 0px 1px 1px, rgba(9, 30, 66, 0.13) 0px 0px 1px 1px;
border-radius: 8px;
line-height: 15px;
padding: 2%;
color:rgba(41, 40, 40, 0.904);
}
#maindiv:hover{
box-shadow: rgba(0, 0, 0, 0.16) 0px 3px 6px, rgba(0, 0, 0, 0.23) 0px 3px 6px;
}
#picture{
width: 45%;
height: 55%;
margin: auto;
margin-left: 25%;
margin-bottom: 8%;
border-top-right-radius: 8px;
border-top-left-radius: 8px;
}
p{
margin:0;
padding:0;
line-height: 15px;
margin-left : 10px;
margin-right : 10px;
}
#nameofprod{
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
line-clamp: 2;
-webkit-box-orient: vertical;
font-size: 14px;
font-weight: 500;
color : black;
}
#brandofprod{
font-size: 12px;
font-weight: 500;
}
#sub1div{
display: flex;
justify-content: space-between;
font-size: 12px;
margin-top: 5%;
}
#cost{
font-size: 14px;
margin-top: 25%;
font-weight: 700;
}
</style>
</head>
<body>
<div id="optionsForSort">
<select name= "price" id="forPrice" onchange="priceSort()">
<option value="nofilter">Any Price</option>
<option value="1"> Below INR 1,000 </option>
<option value="2">INR 1,000 - INR 2000</option>
<option value="3">INR 2,000 - INR 3000</option>
<option value="4">INR 3,000 - INR 10000</option>
<option value="5"> INR 10000 + </option>
</select>
<select name="IMPORTED_FROM" id="forCountry" onchange="countrySort()">
<option value="nofilter">Any Country</option>
<option value="USA"> IMPORTED FROM USA</option>
<option value="UK">IMPORTED FROM UK</option>
<option value="UAE">IMPORTED FROM UAE</option>
<option value="INDIA">IMPORTED FROM INDIA</option>
</select>
<select name = "DELIVERY_TIME" id="fortime" onchange="deliverySort()">
<option value="0">Any delivery time</option>
<option value="1"> Same Day </option>
<option value="2"> 2 days </option>
<option value="4"> 3-5 days </option>
<option value="6"> 5-8days </option>
<option value="10"> 9-15days</option>
<option value="16"> 15+ days </option>
</select>
</div>
<div id= "heading">
<h2>Online Shopping Store in India</h2>
</div>
<div id="container">
</div>
</body>
</html>
<script>
var data = [
{
name : "",
brand : "By ",
rating : 4.6 ,
MRP : 1929 , //write only value
from : "USA",
toCountry : "INDIA",
delivery : "9-15 days",
range: 10, //just the next day of given delivery range (for 9-15 range is 10 )
image: " "
},
]
// for same day delivery range is 1
// for 1-2 days delivery range is 2
// for 3-5 days delivery range is 4
// for 5-8 days delivery range is 6
// for 9-15 days delivery range is 10
// for 15 + days delivery range is 16
function priceSort(){
var select = document.querySelector("#forPrice").value;
if(select == "nofilter"){
displayProducts(data);
}
else if(select == 1){
var level1 = data.filter(function(item){
var cost =item.MRP;
cost = String(cost);
var prices = cost.replace(",","");
prices = Number(prices);
if(prices < 1000) {
return item;
}
});
displayProducts(level1);
}
else if(select == 2){
var level1 = data.filter(function(item){
var cost =item.MRP;
cost = String(cost);
var prices = cost.replace(",","");
prices = Number(prices);
if(prices >= 1000 && prices < 2000) {
return item;
}
});
displayProducts(level1);
}
else if(select == 3){
var level1 = data.filter(function(item){
var cost =item.MRP;
cost = String(cost);
var prices = cost.replace(",","");
prices = Number(prices);
if(prices >= 2000 && prices < 3000) {
return item;
}
});
displayProducts(level1);
}
else if(select == 4){
var level1 = data.filter(function(item){
var cost =item.MRP;
cost = String(cost);
var prices = cost.replace(",","");
prices = Number(prices);
if(prices >= 3000 && prices < 10000) {
return item;
}
});
displayProducts(level1);
}
else if(select == 5){
var level1 = data.filter(function(item){
var cost =item.MRP;
cost = String(cost);
var prices = cost.replace(",","");
prices = Number(prices);
if(prices >= 10000) {
return item;
}
});
displayProducts(level1);
}
}
function countrySort(){
var select = document.querySelector("#forCountry").value;
console.log(select);
var selected = data.filter(function(item){
if(select === item.from) return item ;
if(select == "nofilter") return item ;
});
displayProducts(selected);
}
function deliverySort(){
var select = Number(document.querySelector("#fortime").value);
var selected = data.filter(function(item){
var days = item.range ;
if(select === 0) return item ;
else if(select === days) return item ;
});
displayProducts(selected);
}
displayProducts(data);
function displayProducts(data){
document.querySelector("#container").innerHTML = "";
data.map(function(item){
var prodiv = document.createElement("div");
prodiv.setAttribute("id","maindiv");
prodiv.addEventListener("click",productShow);
var image = document.createElement("img");
image.setAttribute("id","picture");
image.setAttribute("src",item.image)
var ptag1 = document.createElement("p");
ptag1.setAttribute("id","nameofprod");
ptag1.textContent = item.name ;
var ptag2 = document.createElement("p");
ptag2.setAttribute("id","brandofprod");
ptag2.textContent = item.brand ;
var personaldiv = document.createElement("div");
personaldiv.setAttribute("id","sub1div");
var leftdiv = document.createElement("div");
leftdiv.setAttribute("id","div1");
var rightdiv = document.createElement("div");
rightdiv.setAttribute("id","div2");
var rating1 = document.createElement("p");
rating1.setAttribute("id","rating");
rating1.textContent = item.rating ;
var price = document.createElement("p");
price.setAttribute("id","cost");
price.textContent = "₹ " + item.MRP ;
var origin = document.createElement("p");
origin.setAttribute("id","fromCounty");
origin.textContent = "from " + item.from ;
var dispatch = document.createElement("p");
dispatch.setAttribute("id","toCounty");
dispatch.textContent = "to "+item.toCountry;
var when = document.createElement("p");
when.setAttribute("id","delivery");
when.textContent = "in " +item.delivery ;
leftdiv.append(rating1, price);
rightdiv.append(origin,dispatch, when);
personaldiv.append(leftdiv, rightdiv);
prodiv.append(image , ptag1 ,ptag2 ,personaldiv) ;
document.querySelector("#container").append(prodiv);
});
function productShow(){
window.location.href = "productShow.html" ;
}
}
</script>