-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
142 lines (119 loc) · 4.74 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
135
136
137
138
139
140
141
142
function onClickMenu() {
document.getElementById("menu").classList.toggle("icon");
document.getElementById("nav").classList.toggle("change");
}
// search functionality
document.querySelector(".btn1").addEventListener("click", (e) => {
funsearch(e);
});
function funsearch(e) {
e.preventDefault();
console.log('clicked')
var key = document.getElementById("search").value;
key = key.toUpperCase();
if (key.includes("BEAUTY")) {
window.open("./Categories_1/MakeUp.html", "_self");
document.querySelector("#search").value = "";
} else if (key.includes("CLOTH")) {
window.open("./Categories_1/womenCloths.html", "_self");
document.querySelector("#search").value = "";
} else if (key.includes("HOME")) {
window.open("./Categories_1/HomePro.html", "_self");
document.querySelector("#search").value = "";
} else if (key.includes("JWELLERY")) {
window.open("./Categories_1/jwellery.html", "_self");
document.querySelector("#search").value = "";
} else if (key.includes("KIDS")) {
window.open("./Categories_1/Kids.html", "_self");
document.querySelector("#search").value = "";
} else if (key.includes("PET")) {
window.open("./Categories_1/Pet.html", "_self");
document.querySelector("#search").value = "";
} else if (key.includes("SHOES")) {
window.open("./Categories_1/WomenShoes.html", "_self");
document.querySelector("#search").value = "";
} else if (key.includes("SPORTS")) {
window.open("./Categories_1/MenShoes.html", "_self");
document.querySelector("#search").value = "";
}
}
// cart logo ***
var count = localStorage.getItem("cartcount") || 0;
document.querySelector(".cart-count").innerText = count;
//scroll
let mybutton = document.getElementById("myBtn");
// When the user scrolls down 20px from the top of the document, show the button
window.onscroll = function () {
scrollFunction();
};
function scrollFunction() {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
mybutton.style.display = "block";
} else {
mybutton.style.display = "none";
}
}
// When the user clicks on the button, scroll to the top of the document
function topFunction() {
document.body.scrollTop = 0; // For Safari
document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera
}
var cartArr = JSON.parse(localStorage.getItem("cart")) || [];
// console.log(document.querySelector(".cart-count"));
// cart logo count-----------------------------
var count = localStorage.getItem("cartcount") || 0;
document.querySelector(".cart-count").innerText = count;
// search functionality
document.querySelector("#NamesSorting").addEventListener("change", changesearch);
function changesearch() {
console.log('changed')
var key = document.querySelector("#NamesSorting").value;
key = key.toUpperCase();
if (key.includes("BEAUTY")) {
window.open("./Categories_1/MakeUp.html", "_self");
document.querySelector("#search").value = "";
} else if (key.includes("CLOTH")) {
window.open("./Categories_1/womenCloths.html", "_self");
document.querySelector("#search").value = "";
} else if (key.includes("HOME")) {
window.open("./Categories_1/HomePro.html", "_self");
document.querySelector("#search").value = "";
} else if (key.includes("JWELLERY")) {
window.open("./Categories_1/jwellery.html", "_self");
document.querySelector("#search").value = "";
} else if (key.includes("KIDS")) {
window.open("./Categories_1/Kids.html", "_self");
document.querySelector("#search").value = "";
} else if (key.includes("PET")) {
window.open("./Categories_1/Pet.html", "_self");
document.querySelector("#search").value = "";
} else if (key.includes("SHOES")) {
window.open("./Categories_1/WomenShoes.html", "_self");
document.querySelector("#search").value = "";
} else if (key.includes("SPORTS")) {
window.open("./Categories_1/MenShoes.html", "_self");
document.querySelector("#search").value = "";
}
}
// cart logo
var count = localStorage.getItem("") || 0;
document.querySelector(".cart-count").innerText = count;
//function image
document.querySelector("#poster").addEventListener("click", function () {
window.open("clothe.html", "_self");
});
//username
document.querySelector("#user-name1").textContent =
JSON.parse(localStorage.getItem("userName")) || "Sign In";
// microphone
const button = document.querySelector("#mic");
const textInput = document.querySelector("#search");
button.addEventListener("click", () => {
const recognition = new webkitSpeechRecognition();
recognition.onresult = (event) => {
textInput.value = event.results[0][0].transcript;
};
recognition.start();
});
var cartdata = JSON.parse(localStorage.getItem("cart")) || [];
document.querySelector('.cart-count').innerText = cartdata.length;