-
Notifications
You must be signed in to change notification settings - Fork 0
/
project.js
226 lines (149 loc) · 5.83 KB
/
project.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
// ______________________header movement __________________
window.onscroll = function() {
scrollFunction();
};
function scrollFunction() {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
document.getElementById("navbar").style.top = "0";
} else {
document.getElementById("navbar").style.top = "-50px";
}
};
// ______________________ products headline _________________________
$(document).ready(function(){
$("#para").click(function(){
$(".menue").slideToggle("slow");
});
});
// _________________________Rating Form ___________________________________
function submitForm() {
var form = document.getElementById("contact-form");
form.style.display = "none";
var successMessage = document.getElementById("success-message");
successMessage.style.display = "block";
};
const ratingForm = document.getElementById('ratingForm');
const messageBox = document.getElementById('messageBox');
ratingForm.addEventListener('submit', async (event) => {
event.preventDefault();
const formData = new FormData(ratingForm);
const rating = formData.get('rating');
// Display the submitted data under the form.
messageBox.style.display = 'block';
messageBox.innerHTML = `
<p>Rating: ${rating} stars</p>
`;
// Clear the form inputs.
ratingForm.reset();
});
// ________________SCROLLED PICTURES___________________
function changePicture(){
var arr=['airpods/3.jpg',
'smart watches/3.jpg',
'headphones/5.jpg','headphones/55.jpg',
'airpods/7.jpg','power banks/1.jpg', 'Camera/66.jpg',
'ccccc.jpg', 'ccc2.jpg'];
var scrollImage = document.getElementById('scrollImg');
var i=0;
setInterval(
function () {
if (i<arr.length){
scrollImage.src=arr[i];
i++;
}
else{
i=0;
}
},
3000
)};
// ___________________ comment in rating Form _________________________
function myFunction(val) {
if(val.value === ""){
alert("YOU HAVEN'T WRITE A COMMENT")
}
else{
alert(`thanks for the time that investing to rate us
` + val.value);
}
val.value = "";
};
// ___________________Color words on Products ________________________________
function mouseEnter(x) {
x.style.color="white";
};
function mouseLeave(y) {
y.style.color="gray";
};
// __________________contact Us Form (success msg)__________________________
function submitForm() {
var form = document.getElementById("contact-form");
form.style.display = "none";
var successMessage = document.getElementById("success-message");
successMessage.style.display = "block";
};
// _______________change background in header elements_______________________
var changeli = document.getElementsByClassName("li");
function change_Bg(f){
f.style.backgroundColor="#2aafb980";
}
function return_Bg(k){
k.style.backgroundColor="#192a48";
}
// ________________________scroll up Button ________________________________
let mybutton = document.getElementById("myBtn");
window.onscroll = function() {scrollFunction()};
function scrollFunction() {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
mybutton.style.display = "block";
} else {
mybutton.style.display = "none";
}
}
function topFunction() {
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
};
// _____________________local storage login data _____________________________
var storedEmail = localStorage.getItem("E-mail");
var storedPass = localStorage.getItem("password");
var email = document.getElementById("E-mail");
var pass = document.getElementById("password");
function getData(){
storedEmail = email.value;
storedPass = pass.value ;
}
function login(){
if(email.value != storedEmail || pass.value != storedPass ){
alert("please enter a valid e-mail or a password");
return false;
}
else{
regesterForm.action="index.html"; //the path of home page
}
};
var password =document.getElementById("password");
var confirmPass =document.getElementById("confpass");
var username = document.getElementById("username");
var email = document.getElementById("email");
function setData(){
if(password.value!=confirmPass.value){
alert('Passwords doesnot match');
return false;
}
else{
localStorage.setItem("username",username.value);
localStorage.setItem("email", email.value);
localStorage.setItem("password", password.value);
console.log(username.value + email.value + password.value);
formContainer.action="login.html";
}
};
// ______________add to card (cart count)_________________________
function addToCard(){
var num = document.querySelector('.increment');
var new_num =parseInt(num.innerHTML);
new_num++;
num.innerHTML=new_num
alert(new_num + " products added to the cart");
};