From 15a12121b5288959214b4a10632d9cf46a6bab73 Mon Sep 17 00:00:00 2001
From: csathnere <58299457+csathnere@users.noreply.github.com>
Date: Fri, 7 Jun 2024 18:23:10 +0530
Subject: [PATCH 1/7] Update searchIndexProducts
---
js/searchIndexProducts.js | 127 ++++++++++++++++++++------------------
1 file changed, 66 insertions(+), 61 deletions(-)
diff --git a/js/searchIndexProducts.js b/js/searchIndexProducts.js
index b27fc33d..bbaa1141 100644
--- a/js/searchIndexProducts.js
+++ b/js/searchIndexProducts.js
@@ -1,61 +1,66 @@
-document.addEventListener("DOMContentLoaded", () => {
- const components = [
- { id: "footer-searchtab", url: "../footer/footer.html" },
- { id: "header-searchtab", url: "../header/header.html" },
- ];
-
- components.forEach((component) => {
- fetch(component.url)
- .then((response) => response.text())
- .then((data) => {
- document.getElementById(component.id).innerHTML = data;
- })
- .catch((error) =>
- console.error(`Error loading ${component.url}:`, error)
- );
- });
-});
-
-
-
-// Function to get query parameter
-function getQueryParameter(name) {
- const urlParams = new URLSearchParams(window.location.search);
- return urlParams.get(name);
-}
-
-// Function to create product card
-function createSearchProductCard(product) {
- return `
-
-
-
-
-
-
${product.name}
-
${product.rating}  
-
Price: ₹${product.price}
-
-
- `;
-}
-
-// Function to display search results
-function searchFetch(products) {
- const searchList = document.getElementById('results');
- searchList.innerHTML = products.map(product => createSearchProductCard(product)).join('');
-}
-
-// Fetch data from the JSON file and filter products based on the query
-fetch('../json-api/product.json')
- .then(response => response.json())
- .then(data => {
- const query = getQueryParameter('query');
- const filteredProducts = data.filter(product => product.category.toLowerCase().includes(query.toLowerCase()) || product.name.toLowerCase().includes(query));
- searchFetch(filteredProducts);
- })
- .catch(error => console.error('Error fetching data:', error));
-
-
-
-
\ No newline at end of file
+document.addEventListener("DOMContentLoaded", () => {
+ const components = [
+ { id: "footer-searchtab", url: "../footer/footer.html" },
+ { id: "header-searchtab", url: "../header/header.html" },
+ ];
+
+ components.forEach((component) => {
+ fetch(component.url)
+ .then((response) => response.text())
+ .then((data) => {
+ document.getElementById(component.id).innerHTML = data;
+ })
+ .catch((error) =>
+ console.error(`Error loading ${component.url}:`, error)
+ );
+ });
+});
+
+
+
+// Function to get query parameter
+function getQueryParameter(name) {
+ const urlParams = new URLSearchParams(window.location.search);
+ return urlParams.get(name);
+}
+
+// Function to create product card
+function createSearchProductCard(product) {
+ return `
+
+
+
+
+
+
${product.name}
+
${product.rating}  
+
Price: ₹${product.price}
+
+
+ `;
+}
+
+// Function to display search results
+function searchFetch(products) {
+ const searchList = document.getElementById('results');
+ searchList.innerHTML = products.map(product => createSearchProductCard(product)).join('');
+}
+
+// Fetch data from the JSON file and filter products based on the query
+fetch('../json-api/product.json')
+ .then(response => response.json())
+ .then(data => {
+ const query = getQueryParameter('query');
+ if(query=="men"){
+ const filteredProducts = data.filter(product => product.category.toLowerCase().includes(query.toLowerCase()) && !product.category.toLowerCase().includes("women")|| product.name.toLowerCase().includes(query) && !product.name.toLowerCase().includes('women'));
+ searchFetch(filteredProducts);
+ }else{
+ const filteredProducts = data.filter(product => product.category.toLowerCase().includes(query.toLowerCase()) || product.name.toLowerCase().includes(query));
+ searchFetch(filteredProducts);
+ }
+ })
+ .catch(error => console.error('Error fetching data:', error));
+
+
+
+
From 7ab24481e7d3922dbfb5977ce2eb3c20d6041f1d Mon Sep 17 00:00:00 2001
From: csathnere <58299457+csathnere@users.noreply.github.com>
Date: Fri, 7 Jun 2024 18:34:29 +0530
Subject: [PATCH 2/7] Update searchIndexProducts.js
---
js/searchIndexProducts.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/js/searchIndexProducts.js b/js/searchIndexProducts.js
index bbaa1141..4037e94d 100644
--- a/js/searchIndexProducts.js
+++ b/js/searchIndexProducts.js
@@ -49,7 +49,7 @@ function searchFetch(products) {
// Fetch data from the JSON file and filter products based on the query
fetch('../json-api/product.json')
.then(response => response.json())
- .then(data => {
+ .then(data =>{
const query = getQueryParameter('query');
if(query=="men"){
const filteredProducts = data.filter(product => product.category.toLowerCase().includes(query.toLowerCase()) && !product.category.toLowerCase().includes("women")|| product.name.toLowerCase().includes(query) && !product.name.toLowerCase().includes('women'));
@@ -63,4 +63,4 @@ fetch('../json-api/product.json')
-
+
From dc5f0a5c8c75285023824524ff008acd7e9dc3eb Mon Sep 17 00:00:00 2001
From: csathnere <58299457+csathnere@users.noreply.github.com>
Date: Mon, 10 Jun 2024 14:57:11 +0530
Subject: [PATCH 3/7] Update
---
index.html | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/index.html b/index.html
index af8a160c..9abf953a 100644
--- a/index.html
+++ b/index.html
@@ -446,8 +446,9 @@