forked from aakarshpatel84/Ideacart-clone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
homePage.js
322 lines (302 loc) · 20 KB
/
homePage.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
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
let productArr = [
{
img: "https://images-eu.ssl-images-amazon.com/images/I/51JX2xan0gL.jpg",
name: "Like Blood on the Bitten Tongue Delhi Poems",
details:
"Like Blood on the Bitten Tongue is a collection of poems in which beats an old city’s heart, visceral and noetic, brash and gentle, unyielding and evolving, all at the same time. Akhil Katyal combines the Urdu and Hindi traditions of Poetry writing with English forms and sensibilities. His bittersweet poems are shot through with empathy. In an increasingly cynical world, Katyal’s is a stirring and sincere voice.",
category: "Literature & Fiction",
price: 283,
rating: 4.2,
},
{
img: "https://images-eu.ssl-images-amazon.com/images/I/41nAji-PPOL.jpg",
name: "5 Questions of the Inquisitive Ape",
details:
"Humans ascended to the top of the Food chain through their uncanny ability to weave stories. Some stories are hardwired in our brains, while some we create over time. It is such stories that have steered the History of the world. While technologies are bringing disruptive changes and global warming is threatening our existence, it is more imperative than ever before to craft a global story that benefits all. This book discusses five profound questions whose answers will lay the Foundation of Future stories, and those stories will decide the fate of inquisitive apes. ! how we came to be? Was it a chance episode, or were things predetermined? ! how we make sense of the universe around us? Are we hallucinating reality? ! is sex bad? Are we naturally monogamous? ! who are we? Is there a unique us? ! how to be happy? Can we hack our brain and control the bio-chemicals?.",
category: "Health",
price: 2083,
rating: 3.9,
},
{
img: "https://images-eu.ssl-images-amazon.com/images/I/41M%2B10LTRJL.jpg",
name: "The Shiva Sutras",
details:
"As the legend has it, Lord Shiva appeared to sage vasugupta in a dream and instructed him to go to a particular stone near a stream. When sage vasugupta went there the next day, the Stone turned over at his touch, and on its face were inscribed the Shiva sutras. These sutras were to be revealed to those fit for grace as per Lord Shiva instructions. Explaining our true nature and the illusion were living in, the Shiva sutras guides us as to how we can set aside the illusion and experience ultimate reality. The sutras with their transformative message have the power to end our suffering and open up a whole new world for us.",
category: "Religion",
price: 883,
rating: 4.5,
},
{
img: "https://images-eu.ssl-images-amazon.com/images/I/51obtAdzhkL.jpg",
name: "Health Care Economics",
details:
"Delivering the most detailed and exhaustive content available, market-leading HEALTH CARE ECONOMICS, 7th Edition demonstrates how Basic economic concepts, principles, and theories can be used to think about and illustrate various health care issues. This introductory economics text is geared toward graduate students who will be medical and health services managers, administrators, or executives. The seventh edition of HEALTH CARE ECONOMICS includes recent data on the medical sector, updated figures and tables, the latest information on legislative changes affecting this industry, and new Literature and research. It also provides an insightful historical perspective within which these changes are occurring.",
category: "Business & Economics",
price: 7283,
rating: 4.8,
},
{
img: "https://images-eu.ssl-images-amazon.com/images/I/41%2B173HNAzL.jpg",
name: "Water Politics: Governance, Justice and the Right to Wate",
details:
"Scholarship on the right to water has proliferated in Interesting and unexpected ways in recent years. This book broadens existing discussions on the right to water in order to shed critical light on the pathways, pitfalls, prospects, and constraints that exist in achieving global goals, as well as advancing debates around water governance and water justice. The book shows how both discourses and struggles around the right to water have opened new perspectives, and possibilities in water governance, fostering new collective and moral claims for water justice, while effecting changes in laws and policies around the world. In light of the 2010 UN ratification on the human right to water and sanitation, shifts have taken place in policy, legal frameworks, local implementation, as well as in national dialogues. Chapters in the book illustrate the novel ways in which the right to water has been taken up in locations drawn globally, highlighting the material Politics that are enabled and negotiated through this framework in order to address ongoing water insecurities. This book reflects the urgent need to take stock of debates in light of new concerns around post-neoliberal political developments, the challenges of the Anthropocene and climate change, the transition from the Millennium Development Goals (MDGs) to the Sustainable Development Goals (SDGs), as well as the mobilizations around the right to water in the global North. This book is essential reading for scholars and students of water governance, environmental policy, Politics, geography, and law. It will be of great Interest to policymakers and practitioners working in water governance, as well as the human right to water and sanitation.",
category: "Business & Economics",
price: 2455,
rating: 3.2,
},
{
img: "https://images-eu.ssl-images-amazon.com/images/I/41UnmchZ9WL.jpg",
name: "How Many Countries Does the Indus Cross",
details:
"Akhil Katyal is a worthy successor to Agha Shahid Ali, the dedicatee of How Many Countries Does the Indus Cross, which addresses the continuing tragedy of the conflict in Kashmir with a formal dexterity, imaginative reach, and compassion that the late poet would have cherished. The intimate relationship between Politics and literature, which Shahid rigorously explored in The Country Without a Post Office, is the true question posed on page after page of How Many Countries Does the Indus Cross. The answers will astonish readers,Using frank eroticism, surreptitious rhymes, and a molecular understanding of how History seeps into our lives, Akhil Katyal seamlessly entwines the political and the poetical. In poems addressed to dead friends and lost lovers, to vanished poets and remembered cities, he reminds us that Poetry's subjects and pleasures are everywhere.Violent histories are being made every day, if not every moment, in Contemporary India. Akhil Katyal is one of the finest new generation poets who makes lasting poetic documents out of these histories. The poems in this book deal remarkably with our external realities-a News report, an unnoticed tragedy, a loss-and interiorizes them with a fine acumen, an eye for structure and varied dictions. It's a marvel to see how brilliantly he uses Personal memories to express the ironies of our troubled times",
category: " Literature & Fiction",
price: 297,
rating: 3.5,
},
{
img: "https://images-eu.ssl-images-amazon.com/images/I/51tuKDCmCLL.jpg",
name: "Ashworth's Principles of Criminal Law",
details:
"Ashworth's Principles of Criminal Law, now in its ninth edition, takes a distinctive approach to the subject of criminal Law, whilst still covering all of the vital topics found on criminal Law courses. Uniquely theoretical, it seeks to enlighten the reader as to the underlying principles and theoretical foundations of the criminal Law, critically engaging readers by contextualizing and analysing the Law. This is essential reading for students seeking a sophisticated and critically engaging exploration of the subject. Online ResourcesThe text is accompanied by online resources housing a full bibliography as well as a selection of useful web links",
category: "law",
price: 2950,
rating: 3.9,
},
{
img: "https://images-eu.ssl-images-amazon.com/images/I/41%2Bju675f0L.jpg",
name: "Law & Practice relating to SFIO and Inspection, Investigation & Fraud",
details:
"Law & Practice relating to SFIO and Inspection, Investigation & Fraud",
category: "Law",
price: 475,
rating: 3.4,
},
{
img: "https://images-eu.ssl-images-amazon.com/images/I/51tWvkIfJVL.jpg",
name: "Lectures on Criminal Procedure",
details: "Lectures on Criminal Procedure",
category: "Law",
price: 385,
rating: 4.6,
},
{
img: "https://images-eu.ssl-images-amazon.com/images/I/41QpuoHuC-L.jpg",
name: "Simpson's Forensic Medicine",
details:
"Prestigious and authoritative, this fully updated fourteenth edition of Simpson's Forensic Medicine remains a classic; one of the world's leading introductory texts in the field of forensic medicine. It presents all that the generalist or student needs to know about the interface between medicine and the law.",
category: "Law",
price: 2936,
rating: 4.3,
},
{
img: "https://images-eu.ssl-images-amazon.com/images/I/51PDqbyWFtL.jpg",
name: "Justice Delayed: Bottlenecks & Remedies",
details:
"In absence of enforceability of Law, liberty becomes obsolete. Therefore, speedy justice is the Foundation of rule of Law and it has been a concern for the citizenry, legislature, executive and judiciary. It will be a tragedy if the Law is so petrified as to be unable to respond to the unending challenges of evolutionary and Revolutionary changes. The Life of the Law has not been Logic. It has been experience. Any procedure to be efficient and effective has not only to answer the test of Logic and principles but also the experience of its actual working in the crucible of investigation, inquiry and trials",
category: "Law",
price: 1233,
rating: 4.1,
},
{
img: "https://images-eu.ssl-images-amazon.com/images/I/51tuKDCmCLL.jpg",
name: "Ashworth's Principles of Criminal Law",
details:
"Ashworth's Principles of Criminal Law, now in its ninth edition, takes a distinctive approach to the subject of criminal Law, whilst still covering all of the vital topics found on criminal Law courses. Uniquely theoretical, it seeks to enlighten the reader as to the underlying principles and theoretical foundations of the criminal Law, critically engaging readers by contextualizing and analysing the Law. This is essential reading for students seeking a sophisticated and critically engaging exploration of the subject. Online ResourcesThe text is accompanied by online resources housing a full bibliography as well as a selection of useful web links.",
category: "Law",
price: 4147,
rating: 4.8,
},
{
img: "https://images-eu.ssl-images-amazon.com/images/I/519j5W22fsL.jpg",
name: "Historicity of the Mahabharata: Evidence of Literature, Art and Archaeology",
details:
"Language: EnglishPages: 117 (Throughout Color and B/W Illustrations)About The BookTo the faithful, everyday mentioned in the Mahabharata is true to the very letter, whereas the skeptic holds that h e epic is nothing more than a mere figment of imagination. How , then, can one ascertain the truth? It is here that Archaeology comes to our rescue.IN 1951-52, Professor B.B. Lal excavated the key-site of Hastinapura, situated on the bank of the Ganga, in Merut district o f Uttar Pradesh. Over here he encountered in the lower Levels a settlement which was distinguished by a characteristic pottery called the painted Grey Ware, assignable to circa 1100-800 BCE. This PGW Culture has since been discovered at all the Mahabharata sites a feature which binds them together.Further, the excavation revealed that a heavy flood in the Ganga destroyed a considerable portion of the Painted Grey Ware settlement at Hastinapura. This archaeological evidence is duly corroborated by the vayu Purnan which states: “When the city of Hastinpura is carried away by the Ganga, Nichksu will abandon it and dwell in Kausambi.”The shifting of the capital from Hastinapura to Kausambi is, in turn, supported by the fact that in the lowest Levels of Kausambi has been encountered the same kind of degenerated Painted Grey Ware as had begun to appear at Hastinapura prior to its destruction by the flood.Thus, the combined evidence of Archaeology and Literature duly establishes that the Mahabharata is not a figment of imagination but has a basis in historical reality. At the same time, it is on record that the epic underwent eleven time inflation-from 8,800 to 1,00,000 verses- and hence it is difficult to separate the Wheat from the chaff. But let not the precious Wheat be thrown away with the chaf",
category: "Religion",
price: 673,
rating: 4.3,
},
{
img: "https://images-eu.ssl-images-amazon.com/images/I/41u6mq4BweL.jpg",
name: "Our Non-Christian Nation: How Atheists, Satanists, Pagans, and Others Are Demanding Their Rightful Place in Public Life",
details:
"Jay Wexler's Our Non-Christian Nation: How Atheists, Satanists, Pagans, and Others Are Demanding Their Rightful Place in Public Life",
category: "Religion",
price: 1156,
rating: 4.1,
},
{
img: "https://images-eu.ssl-images-amazon.com/images/I/51EowSesKkL.jpg",
name: "Gods of Eden",
details:
"Investigative historian Andrew Collins unlocks the secrets of the pyramids to discover who really built them, and how. Evidence shows that the actually date back at least 5000 years before the coming of the Pharaohs. So what was this mysterious lost civilization that erected these strange monuments, and what alien technology did they use? How does this link up with the stories in the Old Testament, which have previously been regarded purely as myths? What happened to this advanced civilization which existed before recorded history, and the extraordinary technology of the Elder Gods? Did remnant of their culture survive into the 20th century, in other remote parts of the world? And what great secrets await discovery in the Hall of Records beneath the Gaza plateau?",
category: "Religion",
price: 1623,
rating: 3.1,
},
{
img: "https://images-eu.ssl-images-amazon.com/images/I/51pvxecFLnL.jpg",
name: "Brotherhood in Saffron",
details:
"Tracing the growth of the Rashtriya Swayamsevak Sangh (RSS) since its formation in the mid-1920s, the authors examine its ideology and training system. As the first significant book on its internal workings, this book is the prequel to RSS: A View to the Inside. It was for the first time in this book that readers received a glimpse into the inner workings of the RSS. Three decades later, the RSS is one of the most significant cultural organizations in India, making this book a powerful and important read.",
category: "Religion",
price: 299,
rating: 4.3,
},
];
displayfunction(productArr);
function displayfunction(productArr) {
document.querySelector("#containerForBook").innerHTML = "";
productArr.forEach(function (el) {
let box = document.createElement("div");
let box11 = document.createElement("div");
box11.setAttribute("id", "box11");
let proImgDiv = document.createElement("div");
let proImg = document.createElement("img");
proImg.setAttribute("src", el.img);
proImgDiv.append(proImg);
let proNameDiv = document.createElement("div");
let proName = document.createElement("p");
proName.innerText = el.name;
proNameDiv.append(proName);
box11.append(proImgDiv, proNameDiv);
box11.addEventListener("click", function () {
localStorage.setItem("currentPageData", JSON.stringify(el));
location.href = "productPage.html";
});
let box12 = document.createElement("div");
box12.setAttribute("id", "box12");
let proCategory = document.createElement("div");
proCategory.innerText = "Category :" + " " + el.category;
let proRating = document.createElement("div");
proRating.innerText = el.rating + " " + "✡";
let proPrice = document.createElement("div");
proPrice.innerText = "₹" + el.price;
let buycart = document.createElement("div");
buycart.setAttribute("id", "buycart");
let proBuy = document.createElement("button");
proBuy.innerText = "Buy Now";
proBuy.addEventListener("click", function () {
let cartData = JSON.parse(localStorage.getItem("buyCartData")) || [];
if (cartDatapresent(cartData, el) === false) {
cartData.push(el);
localStorage.setItem("buyCartData", JSON.stringify(cartData));
} else {
alert("Item already in cart");
}
location.href = "cart.html"; // give cart page href
});
let proCart = document.createElement("button");
proCart.innerText = "Add to Cart";
proCart.addEventListener("click", function () {
let cartData = JSON.parse(localStorage.getItem("buyCartData")) || [];
if (cartDatapresent(cartData, el) === false) {
cartData.push(el);
localStorage.setItem("buyCartData", JSON.stringify(cartData));
alert("Item successfully added to cart");
} else {
alert("Item already in cart");
}
});
buycart.append(proBuy, proCart);
box12.append(proCategory, proRating, proPrice, buycart);
box.append(box11, box12);
document.querySelector("#containerForBook").append(box);
});
function cartDatapresent(cartData, el) {
for (let i = 0; i < cartData.length; i++) {
if (cartData[i].name === el.name) {
return true;
}
}
return false;
}
}
let crauserArr = [
"https://rukminim1.flixcart.com/flap/1800/1800/image/b6bc3ed0ef0b6fef.jpg?q=80",
"https://rukminim1.flixcart.com/flap/1800/1800/image/713578c84772af15.jpg?q=80",
"https://rukminim1.flixcart.com/flap/1800/1800/image/fe161b55d4ef38c2.jpg?q=80",
"https://rukminim1.flixcart.com/flap/1800/1800/image/942223db429808c8.jpg?q=80",
];
let imgCount = 0;
let img = document.querySelector("#crauser>img");
let buttons = document.querySelectorAll("#crauser>button");
buttons[0].addEventListener("click", function () {
if (imgCount == crauserArr.length - 1) {
imgCount = 0;
} else {
imgCount++;
}
img.setAttribute("src", crauserArr[imgCount]);
});
buttons[1].addEventListener("click", function () {
if (imgCount === 0) {
imgCount = crauserArr.length - 1;
} else {
imgCount--;
}
img.setAttribute("src", crauserArr[imgCount]);
});
img.addEventListener("click", function () {
if (imgCount == 0) {
location.href = "offerProductPage1.html";
} else if (imgCount == 1) {
location.href = "offerProductPage2.html";
} else if (imgCount == 2) {
location.href = "offerProductPage3.html";
} else if (imgCount == 3) {
location.href = "offerProductPage4.html";
}
});
document.querySelector("#nextPage").addEventListener("click", function () {
location.href = "page2.html"; //next page number 2 href
});
filterPrice.addEventListener("change", myPriceFilter);
function myPriceFilter() {
let filterByPrice = document.querySelector("#filterPrice").value;
if (filterByPrice == "SortbyPrice") {
window.location.reload();
} else if (filterByPrice == "LowToHigh") {
productArr.sort(function (a, b) {
return a.price - b.price;
});
displayfunction(productArr);
} else if (filterByPrice == "HighToLow") {
productArr.sort(function (a, b) {
return b.price - a.price;
});
displayfunction(productArr);
}
}
document
.querySelector("#filterRating")
.addEventListener("change", myfilterRating);
function myfilterRating() {
let filterByRating = document.querySelector("#filterRating").value;
if (filterByRating == "SortbyRating") {
window.location.reload();
} else if (filterByRating == "HighToLow") {
productArr.sort(function (a, b) {
return b.rating - a.rating;
});
displayfunction(productArr);
} else if (filterByRating == "LowToHigh") {
productArr.sort(function (a, b) {
return a.rating - b.rating;
});
displayfunction(productArr);
}
}
document
.querySelector("#check-box>form")
.addEventListener("submit", searchData);
function searchData(event) {
event.preventDefault();
let search = document.querySelector(".search").value;
let arr2 = productArr.filter(function (ele) {
if (ele.category == search) {
return ele;
}
});
console.log(arr2);
displayfunction(arr2);
}