-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
134 lines (106 loc) · 3.86 KB
/
index.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
// Scrolling Js part
window.onscroll = function() {myFunction()};
var navbar = document.querySelector(".navbar");
var sticky = navbar.offsetTop;
function myFunction() {
if (window.pageYOffset >= sticky) {
navbar.classList.add("sticky")
} else {
navbar.classList.remove("sticky");
}
}
// Slide Show Part
//Parmeshwar Murmu
// profile">Contact</a>
// <a href="#" id="settings">Email</a>
// <a href="#" id="Logout"
let groceryUrl = "http://localhost:3000/"
let aboutUs = document.getElementById("aboutUs")
let profile = document.getElementById("profile");
let settings = document.getElementById("settings")
let logout = document.getElementById("Logout");
let loginSignup = document.querySelector(".loginSignup");
let cartLogo = document.querySelector("#cartLogo");
let userName = (localStorage.getItem("userName"))
if(userName!=null)
{
aboutUs.innerText = userName;
profile.innerText = "Profile";
settings.innerText = "Settings";
logout.innerText = "Logout";
loginSignup.style.display = "none";
}
let slide = document.getElementById("slideShow");
let imageSlideShowSection = document.getElementById("imageSlideShowSection");
// let btn = document.querySelector("button")
let searchButton = document.getElementById("searchButton")
let spanButton = document.getElementById("spanButton");
let searchProducts = document.getElementById("searchProducts");
let span = document.querySelector("#more");
let topOfferMainSection = document.querySelector("#BeautyandHugieneItemsMainSections");
// top offer
let BeautyandHugieneItemsMainSections = document.querySelector("#BeautyandHugieneItemsMainSections");
let imageArr = [
"https://www.bigbasket.com/media/uploads/banner_images/YXNP13035-1200X300-280223.jpg",
"https://www.bigbasket.com/media/uploads/banner_images/YXNP13038-1200X300-280223.jpg",
"https://www.bigbasket.com/media/uploads/banner_images/YXNP13041-1200X300-280223.jpg",
"https://www.bigbasket.com/media/uploads/banner_images/L1-YXNP12566-1200X300-16thFEB23.jpg",
"https://www.bigbasket.com/media/uploads/banner_images/L1-YXNP11805-1200X300-3rdJAN23.jpg",
"https://www.bigbasket.com/media/uploads/banner_images/YXNP14089-1200X300-16032023.jpg",
"https://www.bigbasket.com/media/uploads/banner_images/YXNP13032-1200X300-280223.jpg",
"https://www.bigbasket.com/media/uploads/banner_images/YXNP14092-1200X300-16thmar23.jpg"
]
window.addEventListener("load", function(){
slideShow();
})
// btn.addEventListener("click", function(){
// slideShow();
// })
let x;
function slideShow()
{
let img = document.createElement("img");
img.setAttribute("src", "https://www.bigbasket.com/media/uploads/banner_images/YXNP14089-1200X300-16032023.jpg");
let i=0;
x = setInterval(() => {
if(i==imageArr.length)
{
i=0;
}
img.src = imageArr[i++];
slide.append(img);
}, 2000);
}
// console.log(userName)
cartLogo.addEventListener("click", function(){
if(userName!=null)
{
// window.location.href = "cart.html";
cartLogo.setAttribute("href", "cart.html")
}
else{
alert("To access You CART Please Login");
// window.location.href = "login.html";
cartLogo.setAttribute("href", "login.html")
}
})
//offer slideshow
// let offer123= ["MIN. 24% OFF on Fruits","MIN.30% OFF on Vegetables", "10% OfF on Dairy Products","20% OFF on non-veg items","500/- OFF on Min 2000/- shopping"];
// let nu=0
// function slid(){
// if(nu==5){
// nu=0
// }
// let slideShowoffer=document.getElementById("slideShowoffer")
// for(let i=0;i<1;i++){
// slideShowoffer.innerText=offer123[nu]
// nu++
// }
// }
// setInterval(slid, 1000);
//Login Logout
logout.addEventListener("click", function(){
localStorage.removeItem("userName");
loginSignup.style.display = "block";
window.location.href = "index.html";
})