Skip to content

Commit

Permalink
full features added
Browse files Browse the repository at this point in the history
  • Loading branch information
souvik666 committed Aug 25, 2021
1 parent ac6accb commit 52afe85
Show file tree
Hide file tree
Showing 7 changed files with 274 additions and 43 deletions.
47 changes: 46 additions & 1 deletion pages/prodcutdetails.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
<!-- navbar section -->

<body>

<!-- cart popup
-->


<div id="conttoshowproduct">
<p id="brand">brand</p>
<p id="productname">24" iMac® with Retina 4.5K display - Apple M1 - 8GB Memory - 256GB SSD (Latest Model) - Blue
Expand Down Expand Up @@ -143,9 +148,48 @@
<p id="learnmore">learn more</p>
</div>
<div id="getit">Get it today nearby</div>
<div id="pickup">
<div> <i class="fa fa-location-arrow" aria-hidden="true"></i> <span> <strong>Pickup:</strong> Order now for
pickup on
Mon, Sep 6 at Aiea

Available today at a location 6 miles away

See all pickup locations</span>
</div>
</div>
<br>
<div id="del">

<i class="fa fa-car" aria-hidden="true"></i> <span> <strong>Shipping</strong>: Unavailable in your area

This item is only available in certain markets.

<a href="#">Estimates for 96939</a>
</span>
</div>
<button id="addtocart">🛒 Add to Cart</i>

</button>

</div>
<div id="suggestedproduct">
<div id="suggestion">People ultimately bought </div>
<div id="probopx">

</div>
</div>
</div>
</body>
<br>
<footer>
<div id="footer">
<p>Get the latest deals and more.</p>
<input type="text"> <button>Sign up</button>
<div></div>
<div>Best Buy App</div>
</div>
</footer>
<script>
let tmp = document.getElementById(`productimgs`).getElementsByTagName(`img`)
for (let i = 0; i < tmp.length; i++) {
Expand All @@ -160,4 +204,5 @@
trgt.src = el
}
</script>
<script src="/scprit/handlproductdetails.js"></script>
<script src="/scprit/handlproductdetails.js"></script>
<script src="/scprit/addtocart.js"></script>
25 changes: 25 additions & 0 deletions scprit/addtocart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
let cartbtn = document.getElementById(`addtocart`);
cartbtn.addEventListener("click", function () {
let data = JSON.parse(localStorage.getItem("productdetails"));
cartfun(data);
});

function cartfun(el) {
let status = JSON.parse(localStorage.getItem("logedin"));
if (status === false) {
alert(`please login`);
setTimeout(function () {
window.location.href = "login.html";
},2000);
} else if (status === true) {
let arr;
arr = localStorage.getItem("cart");
if (arr === null) {
arr = [];
} else {
arr = JSON.parse(localStorage.getItem("cart"));
}
arr.push(el);
localStorage.setItem("cart", JSON.stringify(arr));
}
}
13 changes: 11 additions & 2 deletions scprit/dealforyou.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ function appener() {
let data = JSON.parse(localStorage.getItem("Products"));
let div = document.createElement("div");
div.setAttribute("id", "imgbox");
div.addEventListener("click", function () {
let addme = JSON.parse(localStorage.getItem(`Products`));

localStorage.setItem(
`productdetails`,
JSON.stringify(addme[addme.length - 3])
);
window.location.href = "/pages/prodcutdetails.html";
});
let trgt = data[data.length - 3];
let img = document.createElement("img");
img.src = trgt.img[0];
Expand All @@ -38,8 +47,8 @@ function appener() {
price.textContent = trgt.price;

let discount = document.createElement("p");
discount.textContent = (trgt.price.split("$").map(Number).splice(1)+100) ;
discount.setAttribute("class", "discountprice")
discount.textContent = trgt.price.split("$").map(Number).splice(1) + 100;
discount.setAttribute("class", "discountprice");

div.append(img, pname, rating, price, discount);
maindiv.append(div);
Expand Down
46 changes: 46 additions & 0 deletions scprit/handlproductdetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ function appendproductdetails() {
for (let i = 0; i < showcaseimg.length; i++) {
showcaseimg[i].src = dataset.img[i];
}
//product price
let priceofproduct = document.getElementById(`productprice`);
priceofproduct.innerHTML = dataset.price;

//emi
let emaicost = document.getElementById(`emaicost`);
let numprice = Number(dataset.price.split("").splice(1, dataset.price.length).join(""));
emaicost.innerText = "$"+(numprice/12 | 0)+`/mo.*`;
}
appendproductdetails();

Expand All @@ -37,3 +45,41 @@ document.getElementById(`chkbx`).addEventListener(`click`, function () {
function prtotectionmoney() {
console.log("hi");
}

function suggestprodtyc() {
let suggestion = [];
let data = JSON.parse(localStorage.getItem(`Products`));
let trgt = JSON.parse(localStorage.getItem(`productdetails`));
for (let i = 0; i < data.length; i++) {
if (
data[i].brand === trgt.brand &&
data[i].name !==
`Apple - 10.9-Inch iPad Air - Latest Model - (4th Generation) with Wi-Fi - 64GB - Sky Blue` &&
data[i].name !==
`Apple Watch Series 6 (GPS) 44mm Space Gray Aluminum Case with Black Sport Band - Space Gray`
) {
suggestion.push(data[i]);
}
}
localStorage.setItem("suggestion", JSON.stringify(suggestion));
}

suggestprodtyc();
function appendsuggestion(d) {
let data = d;
let maindiv = document.getElementById(`probopx`);
data.forEach(function (el) {
let div = document.createElement(`div`);
div.setAttribute("class", "proimg");
let pname = document.createElement(`p`);
pname.innerHTML = el.name;
let img = document.createElement(`img`);
img.src = el.img[1];
let price = document.createElement("p");
price.innerHTML = el.price;
price.setAttribute(`id`, "priceodsug");
div.append(img, pname, price);
maindiv.append(div);
});
}
appendsuggestion(JSON.parse(localStorage.getItem("suggestion")));
4 changes: 4 additions & 0 deletions scprit/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ function secondsliderinhomephae() {
let data = JSON.parse(localStorage.getItem("Products"));
data.forEach(function (el) {
let div = document.createElement("div");
div.addEventListener("click", function () {
localStorage.setItem("productdetails", JSON.stringify(el));
window.location.href = "prodcutdetails.html";
});
let pnme = document.createElement("p");
pnme.innerHTML = el.name.split(" ").slice(0, 4);
pnme.setAttribute("class", "fepname");
Expand Down
88 changes: 49 additions & 39 deletions scprit/offersdatabase.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ function appendreleted(d) {
let maindiv = document.getElementById(`relatedpro`);
data.forEach(function (el) {
let div = document.createElement("div");
div.addEventListener("click", function () {
localStorage.setItem("productdetails", JSON.stringify(el));
window.location.href = "prodcutdetails.html";
});
let pname = document.createElement(`p`);
pname.innerHTML = el.name.split(" ").slice(0, 7);
let img = document.createElement("img");
Expand All @@ -115,47 +119,53 @@ function appendreleted(d) {
appendreleted(JSON.parse(localStorage.getItem(`Products`)));

function appendlikedd(d) {
let data = d;
let maindiv = document.getElementById(`likedalso`);
data.forEach(function (el) {
let div = document.createElement("div");
let pname = document.createElement(`p`);
pname.innerHTML = el.name.split(" ").slice(0, 7);
let img = document.createElement("img");
img.src = el.img[0];
/* let rating = document.createElement("img");
let data = d;
let maindiv = document.getElementById(`likedalso`);
data.forEach(function (el) {
let div = document.createElement("div");
div.addEventListener("click", function () {
localStorage.setItem("productdetails", JSON.stringify(el));
window.location.href = "prodcutdetails.html";
});
let pname = document.createElement(`p`);
pname.innerHTML = el.name.split(" ").slice(0, 7);
let img = document.createElement("img");
img.src = el.img[0];
/* let rating = document.createElement("img");
rating.src = `https://image.shutterstock.com/image-vector/stars-rating-icon-four-golden-260nw-1729995094.jpg`;
rating.setAttribute("class", "reerating") */ let price = document.createElement(
"p"
);
price.setAttribute("id", "relatedpro");
price.innerHTML = el.price;
div.append(img, pname, price);
maindiv.append(div);
});
}
appendlikedd(JSON.parse(localStorage.getItem(`Products`)))


"p"
);
price.setAttribute("id", "relatedpro");
price.innerHTML = el.price;
div.append(img, pname, price);
maindiv.append(div);
});
}
appendlikedd(JSON.parse(localStorage.getItem(`Products`)));

function appendFeatured(d) {
let data = d;
let maindiv = document.getElementById(`Featuredss`);
data.forEach(function (el) {
let div = document.createElement("div");
let pname = document.createElement(`p`);
pname.innerHTML = el.name.split(" ").slice(0, 7);
let img = document.createElement("img");
img.src = el.img[0];
/* let rating = document.createElement("img");
function appendFeatured(d) {
let data = d;
let maindiv = document.getElementById(`Featuredss`);
data.forEach(function (el) {
let div = document.createElement("div");
div.addEventListener("click", function () {
localStorage.setItem("productdetails", JSON.stringify(el));
window.location.href = "prodcutdetails.html";
});
let pname = document.createElement(`p`);
pname.innerHTML = el.name.split(" ").slice(0, 7);
let img = document.createElement("img");
img.src = el.img[0];
/* let rating = document.createElement("img");
rating.src = `https://image.shutterstock.com/image-vector/stars-rating-icon-four-golden-260nw-1729995094.jpg`;
rating.setAttribute("class", "reerating") */ let price = document.createElement(
"p"
);
price.setAttribute("id", "relatedpro");
price.innerHTML = el.price;
div.append(img, pname, price);
maindiv.append(div);
});
}
appendFeatured(JSON.parse(localStorage.getItem('Products')))
"p"
);
price.setAttribute("id", "relatedpro");
price.innerHTML = el.price;
div.append(img, pname, price);
maindiv.append(div);
});
}
appendFeatured(JSON.parse(localStorage.getItem("Products")));
Loading

0 comments on commit 52afe85

Please sign in to comment.