-
Notifications
You must be signed in to change notification settings - Fork 0
/
slytherin.js
398 lines (335 loc) · 12.4 KB
/
slytherin.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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
/*Slideshow javascript*/
var slideIndex = 0;
showSlides();
function showSlides() {
var i;
var slides = document.getElementsByClassName("mySlides");
var dots = document.getElementsByClassName("dot");
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
slideIndex++;
if (slideIndex > slides.length) {slideIndex = 1}
for (i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" active", "");
}
slides[slideIndex-1].style.display = "block";
dots[slideIndex-1].className += " active";
setTimeout(showSlides, 5000); // Change image every 5 seconds
}
/*Payment address form javascript validation*/
function payAddName() {
var n = document.getElementById("pafullName").value;
if (n.length >= 4 && n.length <= 25) {
var i;
var flag = 0;
for (i = 0; i < n.length; i++) {
if (n.charAt(i) >= '0' && n.charAt(i) <= '9') {
flag++;
}
}
if (flag == 0) {
document.getElementById("paName").style.color = "green";
document.getElementById("paName").innerHTML = "Valid";
return true;
} else {
document.getElementById("paName").style.color = "red";
document.getElementById("paName").innerHTML = "Name should not contain digits";
return false;
}
} else {
document.getElementById("paName").style.color = "red";
document.getElementById("paName").innerHTML = "Please enter 4-25 characters";
return false;
}
}
function payAddPhone() {
var p = document.getElementById("paPhone").value;
if (p.length == 10) {
document.getElementById("paSphone").style.color = "green";
document.getElementById("paSphone").innerHTML = "Valid";
return true;
} else {
document.getElementById("paSphone").style.color = "red";
document.getElementById("paSphone").innerHTML = "Mobile Number should contain 10 digits";
return false;
}
}
function payAddPincode() {
var p = document.getElementById("pin").value;
if (p.length == 6) {
document.getElementById("spin").style.color = "green";
document.getElementById("spin").innerHTML = "Valid";
return true;
} else {
document.getElementById("spin").style.color = "red";
document.getElementById("spin").innerHTML = "Pincode contains 6 digits";
return false;
}
}
/*payment gateway form javascript validation*/
function payGateName()
{
var n = document.getElementById("pgName").value;
if(n.length >= 4 && n.length <= 25)
{
var i;
var flag = 0;
for(i = 0; i < n.length; i++)
{
if(n.charAt(i) >= '0' && n.charAt(i) <= '9')
flag++;
}
if(flag == 0)
{
document.getElementById("pgSname").style.color = "green";
document.getElementById("pgSname").innerHTML = "valid";
}
else
{
document.getElementById("pgSname").style.color = "red";
document.getElementById("pgSname").innerHTML = "*Name should not contain digits*";
}
}
else
{
document.getElementById("pgSname").style.color = "red";
document.getElementById("pgSname").innerHTML = "*Please enter 4-25 characters*";
}
}
function payGateCard()
{
var n = document.getElementById("card").value;
if(n.length == 16)
{
document.getElementById("scard").style.color = "green";
document.getElementById("scard").innerHTML = "valid";
}
else
{
document.getElementById("scard").style.color = "red";
document.getElementById("scard").innerHTML = "*Please enter 16 digit card number*";
}
}
/*Add to cart js*/
function addToCart()
{
alert("Item has been added to cart. :)");
}
/*Sign up form javascript validation*/
function signName() {
var n = document.getElementById("Suser").value;
if (n.length >= 4 && n.length <= 25) {
var i;
var flag = 0;
for (i = 0; i < n.length; i++) {
if (n.charAt(i) >= '0' && n.charAt(i) <= '9')
flag++;
}
if (flag == 0) {
document.getElementById("Susername").style.color = "green";
document.getElementById("Susername").innerHTML = "valid";
} else {
document.getElementById("Susername").style.color = "red";
document.getElementById("Susername").innerHTML = "Name should not contain digits";
}
} else {
document.getElementById("Susername").style.color = "red";
document.getElementById("Susername").innerHTML = "Please enter 4-25 characters";
}
}
function signPhone() {
var p = document.getElementById("mobileNumber").value;
if (p.length == 10) {
document.getElementById('mobileno').style.color = "green";
document.getElementById('mobileno').innerHTML = "Valid";
return true;
} else {
document.getElementById('mobileno').style.color = "red";
document.getElementById('mobileno').innerHTML = "Mobile Number should contain 10 digits";
return false;
}
}
function signEmail() {
var p = document.getElementById("emails").value;
if (p == "") {
document.getElementById('emailids').style.color = "red";
document.getElementById('emailids').innerHTML = "Please fill the email id field";
return false;
}
if (p.indexOf('@') <= 0) {
document.getElementById('emailids').style.color = "red";
document.getElementById('emailids').innerHTML = "'@' at Invalid Position";
return false;
}
if ((p.charAt(p.length - 4) != '.') && (p.charAt(p.length - 3) != '.')) {
document.getElementById('emailids').style.color = "red";
document.getElementById('emailids').innerHTML = " '.' at Invalid Position";
return false;
} else {
document.getElementById('emailids').style.color = "green";
document.getElementById('emailids').innerHTML = "Valid";
return true;
}
}
function signPass() {
var pass = document.getElementById("Spass").value;
if (pass == "") {
document.getElementById('passwords').style.color = "red";
document.getElementById('passwords').innerHTML = " ** Please fill the password field";
return false;
}
if ((pass.length < 5) || (pass.length > 20)) {
document.getElementById('passwords').style.color = "red";
document.getElementById('passwords').innerHTML = " ** Passwords lenght must be between 5 and 20";
return false;
} else {
document.getElementById('passwords').style.color = "green";
document.getElementById('passwords').innerHTML = "Valid";
return true;
}
}
function signConfirmPass() {
var confirmpass = document.getElementById("conpass").value;
var pass = document.getElementById("Spass").value;
if (confirmpass == "") {
document.getElementById('confrmpass').style.color = "red";
document.getElementById('confrmpass').innerHTML = " ** Please confirm your password **";
return false;
} else if (confirmpass == pass) {
document.getElementById('confrmpass').style.color = "green";
document.getElementById('confrmpass').innerHTML = "Valid";
return true;
} else {
document.getElementById('confrmpass').style.color = "red";
document.getElementById('confrmpass').innerHTML = "Password does not match";
return false;
}
}
/*Login form validation javascript*/
function Validate() {
var user = document.getElementById('user').value;
var pass = document.getElementById('pass').value;
if (user == "") {
document.getElementById('username').style.color = "red";
document.getElementById('username').innerHTML = "*Please Enter Username*";
return false;
} else {
document.getElementById('username').style.color = "green";
document.getElementById('username').innerHTML = "Valid";
}
if ((user.length < 4) || (user.length > 15)) {
document.getElementById('username').style.color = "red";
document.getElementById('username').innerHTML = "*Please Enter between 4 to 15 characters*";
return false;
} else if ((pass.length < 6) || (pass.length > 15)) {
document.getElementById('usep').style.color = "red";
document.getElementById('usep').innerHTML = "*Please Enter between 6 to 15 characters*";
return false;
} else {
document.getElementById('usep').style.color = "green";
document.getElementById('usep').innerHTML = "Valid";
return true;
}
}
/*book store alert function*/
function book()
{
alert("Check out our bookstore 'slytherinBooks' to order this . There you will get much more exciting offers 😃");
}
/*timer deals end*/
// Set the date we're counting down to
var countDownDate = new Date("Aug 20, 2020 23:59:00").getTime();
// Update the count down every 1 second
var x = setInterval(function() {
// Get today's date and time
var now = new Date().getTime();
// Find the distance between now and the count down date
var distance = countDownDate - now;
// Time calculations for days, hours, minutes and seconds
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
// Output the result in an element with id="demo"
document.getElementById("demo1").style.color = "green";
document.getElementById("demo1").innerHTML = "Ends in -> " + days + "d : " + hours + "h : "
+ minutes + "m : " + seconds + "s ";
// If the count down is over, write some text
if (distance < 0) {
clearInterval(x);
document.getElementById("demo1").style.color = "red";
document.getElementById("demo1").innerHTML = "Deals End";
}
}, 1000);
// Set the date we're counting down to
var countDownDate = new Date("Aug 20, 2020 23:59:00").getTime();
// Update the count down every 1 second
var x = setInterval(function() {
// Get today's date and time
var now = new Date().getTime();
// Find the distance between now and the count down date
var distance = countDownDate - now;
// Time calculations for days, hours, minutes and seconds
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
// Output the result in an element with id="demo"
document.getElementById("demo2").style.color = "green";
document.getElementById("demo2").innerHTML = "Ends in -> " + days + "d : " + hours + "h : "
+ minutes + "m : " + seconds + "s ";
// If the count down is over, write some text
if (distance < 0) {
clearInterval(x);
document.getElementById("demo2").style.color = "red";
document.getElementById("demo2").innerHTML = "Deals End";
}
}, 1000);
// Set the date we're counting down to
var countDownDate = new Date("Aug 20, 2020 23:59:00").getTime();
// Update the count down every 1 second
var x = setInterval(function() {
// Get today's date and time
var now = new Date().getTime();
// Find the distance between now and the count down date
var distance = countDownDate - now;
// Time calculations for days, hours, minutes and seconds
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
// Output the result in an element with id="demo"
document.getElementById("demo3").style.color = "green";
document.getElementById("demo3").innerHTML = "Ends in -> " + days + "d : " + hours + "h : "
+ minutes + "m : " + seconds + "s ";
// If the count down is over, write some text
if (distance < 0) {
clearInterval(x);
document.getElementById("demo3").style.color = "red";
document.getElementById("demo3").innerHTML = "Deals End";
}
}, 1000);
/*get location API*/
function fun()
{
var a = confirm("Do you want to allow location access of this device?");
if(a == true)
getLocation();
}
var x = document.getElementById("demo");
function getLocation()
{
if (navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(showPosition);
} else
{
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position)
{
x.innerHTML = "Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;
}