-
Notifications
You must be signed in to change notification settings - Fork 3
/
ride_booking.js
1537 lines (1447 loc) · 53.6 KB
/
ride_booking.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
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// function slideshow() {
// let div = document.getElementById("header_slideshow");
// let img = document.createElement("img");
// var arr = [
// "https://www.onnbikes.com/img/[email protected]",
// "https://www.onnbikes.com/img/[email protected]",
// "https://www.onnbikes.com/img/R2o-desktopbanner.jpg",
// ];
// img.src = arr[0];
// let i = 0;
// div.append(img);
// setInterval(function() {
// img.src = arr[i];
// i++;
// if (i == arr.length) {
// i = 0;
// }
// // div.append(img);
// }, 2000);
// }
// slideshow();
var hr = 1;
function showSignup() {
let login = document.getElementById("login_form");
let signup = document.getElementById("signup_form");
let heading = document.getElementsByClassName("heading")[0];
let loginHeading = heading.children[0];
let signupHeading = heading.children[1];
login.classList.toggle("hide");
signup.classList.toggle("hide");
loginHeading.classList.toggle("currForm");
signupHeading.classList.toggle("currForm");
}
function dayrating() {
function diff_hours(dt2, dt1) {
var diff = (dt2.getTime() - dt1.getTime()) / 1000;
diff /= 60 * 60;
return Math.abs(Math.round(diff));
}
let calender = [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec",
];
let d1 = JSON.parse(localStorage.getItem("startingDateObject"));
let d2 = JSON.parse(localStorage.getItem("endingDateObject"));
if (d2 == null) {
d2 = {
date: d1.date,
month: d1.month,
time: d1.time,
weekDay: d1.weekDay,
year: d1.year,
};
let x = calender.indexOf(d1.month) + 1;
if (x == calender.length) {
x = 0;
d2.month = calender[x];
} else {
d2.month = calender[x];
}
localStorage.setItem("30daysdate", JSON.stringify(d2));
}
dt1 = new Date(`${d1.month} ${d1.date}, ${d1.year} ${d1.time}`);
dt2 = new Date(`${d2.month} ${d2.date}, ${d2.year} ${d2.time}`);
hr = diff_hours(dt1, dt2);
if (hr % 720 == 0) {
hr = Math.round(hr / 3);
} else if (hr % 360 == 0) {
hr = Math.round(hr / 5);
} else if (hr % 240 == 0) {
hr = Math.round(hr / 7);
} else if (hr % 24 == 0) {
hr = Math.round(hr / 6);
}
bikesobject();
}
dayrating();
const arrofLocation = [{
city: "BENGALURU",
location: "Silk Board SRCM",
timing: "7 AM - 9 PM",
reference: "Scrum Heartfulness Meditation Centre",
address: "28, Hosur Road, Madiwala, Balaji Nagar, BTM Layout 1, Central Silk Board Colony, Stage 2, BTM Layout, BENGALURU, Karnataka 560068",
},
{
city: "BENGALURU",
location: "Yelahanka",
timing: "7 AM - 8 PM",
reference: "Green Trends Salon",
address: "200/1, KV SR Layout, Kattigenahalli, Bagalur Main Road, Next to Reliance Fresh, BENGALURU - 560063",
},
{
city: "BENGALURU",
location: "Electronic City",
timing: "7 AM - 8 PM",
reference: "Next to paradise Biryani",
address: "#634/472, Doddathogur, Velankani Gate, Electronic City Phase 1, Electronics City Phase,BENGALURU 560100",
},
{
city: "BENGALURU",
location: "Kundalahalli",
timing: "7 AM - 8 PM",
reference: "Kundalahalli gate signal",
address: "Munni Reddy Complex, Varthur Main Road, Opposite Nadhini Wines, Silver Springs Layout, Kundalahalli, BENGALURU - 560066",
},
{
city: "BENGALURU",
location: "Koramangala",
timing: "9 AM - 8 PM",
reference: "Opp Big Bazaar, Next to Raja",
address: "No 150/1 and 2, Hosur Main Road, Opposite Big Bazaar, Next to Raja Honda, Koramangala, BENGALURU - 560095",
},
{
city: "HYDERABAD",
location: "Madhapur",
timing: "9 AM - 7 PM",
reference: "Below Vijaya Lakshmi supermark",
address: "Plot No.539, Ayyappa Society, 100ft Road, Madhapur, Hyderabad",
},
{
city: "HYDERABAD",
location: "RAIDURGAM POLICE COMMISSIONARATE",
timing: "9 AM - 7 PM",
reference: "OYO 3607 Apartment",
address: "OYO 3607 Apartment Gachibowli under Stilt parking. Plot No 33 & 34, Udaya Elite, Beside Care Hospital lane, Besides Cyberabad Police commissionerate,Gachibowli, Hyderabad, Telangana 500032",
},
{
city: "HYDERABAD",
location: "Gachibowli",
timing: "9 AM - 7 PM",
reference: "Opp. to Maruti True Value",
address: "OYO 3607 Apartment Gachibowli under Stilt parking. Plot No 33 & 34, Udaya Elite, Beside Care Hospital lane, Besides Cyberabad Police commissionerate,Gachibowli, Hyderabad, Telangana 500032",
},
{
city: "HYDERABAD",
location: "Secunderabad",
timing: "9 AM - 7 PM",
reference: "Opposite to Yashoda Hospital",
address: "Opposite to Yeshoda Hospital Parking Alexander Rd, Kummari Guda, Shivaji Nagar, Secunderabad, Telangana 500003.",
},
{
city: "HYDERABAD",
location: "Dilsukhnagar",
timing: "9 AM - 7 PM",
reference: "Beside Income Tax Office",
address: "16-2-741/29 & 37, Anushka Towers, Bank colony, New malakpet, Dilsukhnagar. LandMark:- Beside DTDC Courier & Oasis Reproductive Hospital.",
},
{
city: "HYDERABAD",
location: "Ameerpet",
timing: "9 AM - 7 PM",
reference: "Aditya Trade center",
address: "Swati Manor, Beside Aditya Trade center, Kumar Basti, Ameerpet, Hyderabad, Telangana 500082",
},
{
city: "HYDERABAD",
location: "Chanda Nagar",
timing: "9 AM - 7 PM",
reference: "Fitness Secret Gym",
address: "Akshita Spaces, Second Floor, Plot # 194p, Rajendar Reddy Nagar Colony, Ameenpur Road, Chanda Nagar, Hyd -500050.",
},
{
city: "JAIPUR",
location: "New Aatish Market Metro station",
timing: "8 AM - 5 PM",
reference: "Parking of New Aatish Market",
address: "New Aatish Market Metro station, Gurjar ki Thadi Underpass, Sultan Nagar, Shanthi Nagar,Near Metro Station, Mansarovar, Jaipur, Rajasthan 302020",
},
{
city: "JAIPUR",
location: "GT-Gaurav Tower",
timing: "8 AM - 5 PM",
reference: "Gaurav Tower",
address: "Gold Souk Grand Mall (Near Hotel Lalit, Basement 2 Parking), Jaipur, Rajasthan 302001",
},
{
city: "JAIPUR",
location: "Gold Souk Grand Mall",
timing: "8 AM - 5 PM",
reference: "Near Jawahar Circle",
address: "Gold Souk Grand Mall (Near Hotel Lalit, Basement 2 Parking), Jaipur, Rajasthan 302001",
},
{
city: "JAIPUR",
location: "C Scheme",
timing: "8 AM - 5 PM",
reference: "Man Upasana",
address: "Man Upasana C-44 Sardar Patel Marg Panch Batti, C Scheme, Ashok Nagar Jaipur, Rajasthan 302001",
},
{
city: "JAIPUR",
location: "Mansarovar- Shipra Path",
timing: "8 AM - 5 PM",
reference: "Opposite Reil house, Mansarova",
address: "34/17, Shipra path,Opposite Reil house, Mansarovar, Jaipur-302020",
},
{
city: "GURUGRAM",
location: "Bike Surgeon",
timing: "9 AM - 9 PM",
reference: "Gurucharan palace, district court road, Near Rajiv Chowk",
address: "51/19, Bhim nagar, New Railway Rd, Gurugram, HR-122001",
},
{
city: "MYSURU",
location: "Jaganmohan Palace",
timing: "9 AM - 9 PM",
reference: "Near Mysore Palace",
address: "425 - 426, Deshika Road, Opp. Jaganmohan Palace, Subbarayanakere, Chamrajpura, Mysuru, Karnataka 570024",
},
{
city: "UDAIPUR",
location: "Udaipole",
timing: "8 AM - 5 PM",
reference: "Near Hotel Shree Narayana",
address: "Shop NO-6, Arihant Plaza ,Opposite ICICI Bank Udaipole ,Udaipur-313001",
},
{
city: "AHMEDABAD",
location: "Vijay Cross Road",
timing: "9 AM - 7 PM",
reference: "Visitor Parking of the complex",
address: "The Link, Nr. Vijay Cross Road, Navrangpura, Ahmedabad 380009",
},
];
localStorage.setItem("rideslocations", JSON.stringify(arrofLocation));
function bikesobject() {
const arrOfBikes = [{
name: "Royal Enfield 350 Thunderbird",
free: 11 * hr,
excess: 3,
price: 35 * hr,
manufacturer: "Royal Enfield",
model: "350 Thunderbird",
type: "Motorcycle",
imgLink: "https://get.onn.app/wp-content/uploads/2020/05/Thunderbird-350.jpg",
},
{
name: "Bajaj Pulsar 180",
free: 9 * hr,
excess: 2,
price: 19 * hr,
manufacturer: "Bajaj",
model: "Pulsar",
type: "Motorcycle",
imgLink: "https://get.onn.app/wp-content/uploads/2020/05/Pulsar-180.jpg",
},
{
name: "Bajaj Pulsar NS 160",
free: 3 * hr,
excess: 2,
price: 6 * hr,
manufacturer: "Bajaj",
model: "Pulsar",
type: "Motorcycle",
imgLink: "https://get.onn.app/wp-content/uploads/2020/05/Pulsar-NS-160.jpg",
},
{
name: "Bajaj Pulsar NS 200",
free: 3 * hr,
excess: 2,
price: 6 * hr,
manufacturer: "Bajaj",
model: "Pulsar",
type: "Motorcycle",
imgLink: "https://get.onn.app/wp-content/uploads/2020/05/Pulsar-NS-200.jpg",
},
{
name: "Bajaj Pulsar 135 LS",
free: 3 * hr,
excess: 2,
price: 6 * hr,
manufacturer: "Bajaj",
model: "Pulsar",
type: "Motorcycle",
imgLink: "https://get.onn.app/wp-content/uploads/2020/05/Pulsar-135-LS.jpg",
},
{
name: "Bajaj CT 100",
free: 10 * hr,
excess: 2,
price: 8 * hr,
manufacturer: "Bajaj",
model: "CT 100",
type: "Motorcycle",
imgLink: "https://get.onn.app/wp-content/uploads/2020/05/CT100.jpg",
},
{
name: "Bajaj Dominar 400 ABS",
free: 13 * hr,
excess: 4,
price: 42 * hr,
manufacturer: "Bajaj",
model: "Dominar 400 ABS",
type: "Motorcycle",
imgLink: "https://get.onn.app/wp-content/uploads/2020/05/Dominar-400.jpg",
},
{
name: "KTM Duke 250",
free: 11 * hr,
excess: 4,
price: 46 * hr,
manufacturer: "KTM",
model: "Duke 250",
type: "Motorcycle",
imgLink: "https://get.onn.app/wp-content/uploads/2020/05/Duke-250.jpg",
},
{
name: "Yamaha FZ",
free: 12 * hr,
excess: 2,
price: 23 * hr,
manufacturer: "Yamaha",
model: "FZ",
type: "Motorcycle",
imgLink: "https://get.onn.app/wp-content/uploads/2020/05/FZ-v2.jpg'",
},
{
name: "Honda Navi",
free: 9 * hr,
excess: 2,
price: 8 * hr,
manufacturer: "Honda",
model: "Navi",
type: "Scooter",
imgLink: "https://get.onn.app/wp-content/uploads/2020/05/Navi.jpg",
},
{
name: "Honda DREAM NEO",
free: 9 * hr,
excess: 2,
price: 8 * hr,
manufacturer: "Honda",
model: "Dream Neo",
type: "Motorcycle",
imgLink: "https://get.onn.app/wp-content/uploads/2020/05/Dream-Neo.jpg",
},
{
name: "Honda Hornet",
free: 12 * hr,
excess: 2,
price: 25 * hr,
manufacturer: "Honda",
model: "Hornet",
type: "Motorcycle",
imgLink: "https://get.onn.app/wp-content/uploads/2020/05/Hornet.jpg",
},
{
name: "Honda Activa",
free: 9 * hr,
excess: 2,
price: 10 * hr,
manufacturer: "Honda",
model: "Activa",
type: "Scooter",
imgLink: "https://get.onn.app/wp-content/uploads/2020/05/Activa.jpg",
},
{
name: "Honda Dio",
free: 9 * hr,
excess: 2,
price: 12 * hr,
manufacturer: "Honda",
model: "Dio",
type: "Scooter",
imgLink: "https://get.onn.app/wp-content/uploads/2020/05/Dio.jpg",
},
{
name: "Honda Livo",
free: 9 * hr,
excess: 2,
price: 12 * hr,
manufacturer: "Honda",
model: "Livo",
type: "Motorcycle",
imgLink: "https://get.onn.app/wp-content/uploads/2020/05/Livo.jpg",
},
{
name: "Bajaj Pulsar 150",
free: 8 * hr,
excess: 2,
price: 17 * hr,
manufacturer: "Bajaj",
model: "Pulsar",
type: "Motorcycle",
imgLink: "https://get.onn.app/wp-content/uploads/2020/05/Pulsar-150.jpg",
},
{
name: "Bajaj Avenger 220 Cruise",
free: 12 * hr,
excess: 2.5,
price: 23 * hr,
manufacturer: "Bajaj",
model: "Avenger 220 Cruise",
type: "Motorcycle",
imgLink: "https://get.onn.app/wp-content/uploads/2020/05/Avenger-220-Cruise.jpg",
},
{
name: "Bajaj Avenger 220 Street",
free: 12 * hr,
excess: 2.5,
price: 23 * hr,
manufacturer: "Bajaj",
model: "Avenger 220 Street",
type: "Motorcycle",
imgLink: "https://get.onn.app/wp-content/uploads/2020/05/Avenger-220-Street.jpg",
},
{
name: "Royal Enfield 350 Classic",
free: 11 * hr,
excess: 3,
price: 33 * hr,
manufacturer: "Royal Enfield",
model: "350 Classic",
type: "Motorcycle",
imgLink: "https://get.onn.app/wp-content/uploads/2020/05/Classic-350.jpg",
},
];
localStorage.setItem("bikes", JSON.stringify(arrOfBikes));
}
function bikes() {
let arr = JSON.parse(localStorage.getItem("bikes"));
let parent = document.querySelector(".bike-showcase");
parent.innerHTML = "";
arr.forEach((e) => {
let parent = document.querySelector(".bike-showcase");
let noclassdiv = document.createElement("div");
let bikeimgdiv = document.createElement("div");
let freenexcessdiv = document.createElement("div");
let pricenbooknowdiv = document.createElement("div");
let image = document.createElement("img");
let pname = document.createElement("p");
let pkilometer = document.createElement("p");
let pexcess = document.createElement("p");
let pprice = document.createElement("p");
let btn = document.createElement("button");
image.src = e.imgLink;
bikeimgdiv.append(image);
bikeimgdiv.setAttribute("class", "bike-img-cont");
pname.innerHTML = e.name;
pname.setAttribute("class", "bike-name");
pkilometer.innerHTML = `Free ${e.free} Kms`;
pkilometer.setAttribute("class", "free-kilometers");
pexcess.innerHTML = `Excess ₹${e.excess}/km`;
pexcess.setAttribute("class", "excess");
freenexcessdiv.setAttribute("class", "free-N-excess");
freenexcessdiv.append(pkilometer, pexcess);
pprice.innerHTML = `₹${e.price}`;
pprice.setAttribute("class", "price");
btn.innerHTML = "BOOK NOW";
btn.onclick = function() {
fav(e);
};
pricenbooknowdiv.setAttribute("class", "price-N-bookNow");
pricenbooknowdiv.append(pprice, btn);
noclassdiv.append(bikeimgdiv, pname, freenexcessdiv, pricenbooknowdiv);
parent.append(noclassdiv);
});
}
bikes();
function fav(e) {
const currLoggedIn = JSON.parse(localStorage.getItem("currLoggedIn"));
if (currLoggedIn.length < 1) {
showLoginSignupPopup();
} else {
showSelectPickupOverlay();
let selectedbike = {
name: e.name,
free: e.free,
excess: e.excess,
price: e.price,
manufacturer: e.manufacturer,
model: e.model,
type: e.type,
imgLink: e.imgLink,
};
let bookedbike = localStorage.getItem("selectedbike");
if (bookedbike == null) {
bookedbike = [];
} else {
localStorage.removeItem("selectedbike");
bookedbike = [];
}
bookedbike.push(selectedbike);
localStorage.setItem("selectedbike", JSON.stringify(selectedbike));
pickup(e);
}
}
function showSelectPickupOverlay() {
let selectPickupOverlay = document.querySelector(".selectPickupOverlay");
selectPickupOverlay.classList.remove("hide");
}
function pickup() {
let arr = JSON.parse(localStorage.getItem("rideslocations"));
let parent = document.getElementById("expand");
let currentlocation = document.getElementById("currentlocation").innerText;
parent.innerHTML = "";
arr.forEach((e) => {
if (currentlocation == e.city) {
let parent = document.getElementById("expand");
let div = document.createElement("div");
let plocation = document.createElement("p");
let ptiming = document.createElement("p");
let preference = document.createElement("p");
plocation.innerHTML = e.location;
ptiming.innerHTML = `START TIMING: ${e.timing}`;
preference.innerHTML = e.reference;
let bottomOfLocationsDiv = document.createElement("div");
let p = document.createElement("p");
p.innerHTML = "5 Available";
bottomOfLocationsDiv.classList.add("bike_available");
let arrowIcon = document.createElement("i");
arrowIcon.classList.add("fas", "fa-arrow-right");
bottomOfLocationsDiv.append(p, arrowIcon);
div.onclick = function() {
decidedlocation(e);
};
plocation.classList.add("plocation");
ptiming.classList.add("ptiming");
preference.classList.add("preference");
div.append(plocation, ptiming, preference, bottomOfLocationsDiv);
div.setAttribute("class", "new");
div.style.cursor = "pointer";
parent.append(div);
}
});
}
function decidedlocation(e) {
let decidedlocation = JSON.parse(localStorage.getItem("selectedbike"));
decidedlocation.city = e.city;
decidedlocation.location = e.location;
decidedlocation.timing = e.timing;
decidedlocation.reference = e.reference;
decidedlocation.address = e.address;
let finallocation = localStorage.getItem("finalBookedBike");
if (finallocation == null) {
finallocation = [];
} else {
localStorage.removeItem("finalBookedBike");
finallocation = [];
}
finallocation.push(decidedlocation, decidedlocation.address);
localStorage.setItem("finalBookedBike", JSON.stringify(finallocation));
window.open("checkout.html", "_parent");
}
function manufacturer() {
let abc = document.getElementById("vehicle");
var checkboxes = abc.querySelectorAll("input");
let j = 0;
for (var i = 0, n = checkboxes.length; i < n; i++) {
if (checkboxes[i].checked == true) {
j++;
}
}
if (j == 1) {
vehicle();
return;
}
let model = document.getElementById("model");
var checkboxes = model.querySelectorAll("input");
let y = 0;
for (var i = 0, n = checkboxes.length; i < n; i++) {
if (checkboxes[i].checked == true) y++;
}
if (y != 0) {
return;
}
let manufacturer = document.getElementById("manufacturer");
var checkboxes = manufacturer.querySelectorAll("input");
let x = 0;
for (var i = 0, n = checkboxes.length; i < n; i++) {
if (checkboxes[i].checked == true) x++;
}
if (x > 0) {
let parent = document.querySelector(".bike-showcase");
parent.innerHTML = "";
for (var i = 0, n = checkboxes.length; i < n; i++) {
if (checkboxes[i].checked == true) {
let arr = JSON.parse(localStorage.getItem("bikes"));
arr.forEach((e) => {
if (checkboxes[i].name === e.manufacturer) {
let parent = document.querySelector(".bike-showcase");
let noclassdiv = document.createElement("div");
let bikeimgdiv = document.createElement("div");
let freenexcessdiv = document.createElement("div");
let pricenbooknowdiv = document.createElement("div");
let image = document.createElement("img");
let pname = document.createElement("p");
let pkilometer = document.createElement("p");
let pexcess = document.createElement("p");
let pprice = document.createElement("p");
let btn = document.createElement("button");
image.src = e.imgLink;
bikeimgdiv.append(image);
bikeimgdiv.setAttribute("class", "bike-img-cont");
pname.innerHTML = e.name;
pname.setAttribute("class", "bike-name");
pkilometer.innerHTML = `Free ${e.free} Kms`;
pkilometer.setAttribute("class", "free-kilometers");
pexcess.innerHTML = `Excess ₹${e.excess}/km`;
pexcess.setAttribute("class", "excess");
freenexcessdiv.setAttribute("class", "free-N-excess");
freenexcessdiv.append(pkilometer, pexcess);
pprice.innerHTML = `₹${e.price}`;
pprice.setAttribute("class", "price");
btn.innerHTML = "BOOK NOW";
btn.onclick = function() {
fav(e);
};
pricenbooknowdiv.setAttribute("class", "price-N-bookNow");
pricenbooknowdiv.append(pprice, btn);
noclassdiv.append(
bikeimgdiv,
pname,
freenexcessdiv,
pricenbooknowdiv
);
parent.append(noclassdiv);
}
});
}
}
} else {
bikes();
}
}
function vehicle(id) {
let model = document.getElementById("model");
var checkboxes = model.querySelectorAll("input");
let y = 0;
for (var i = 0, n = checkboxes.length; i < n; i++) {
if (checkboxes[i].checked == true) y++;
}
if (y != 0) {
return;
}
let parent = document.querySelector(".bike-showcase");
parent.innerHTML = "";
let vehicletype = document.getElementById(id);
let vehicle = document.getElementById("vehicle");
var checkboxes = vehicle.querySelectorAll("input");
let x = 0;
for (var i = 0, n = checkboxes.length; i < n; i++) {
if (checkboxes[i].checked == true) {
x++;
var category = checkboxes[i].name;
}
}
if (x == 1) {
let vehicle = document.getElementById("manufacturer");
var checkboxes = vehicle.querySelectorAll("input");
let parent = document.querySelector(".bike-showcase");
parent.innerHTML = "";
let x = 0;
for (var i = 0, n = checkboxes.length; i < n; i++) {
if (checkboxes[i].checked == true) {
x++;
}
}
if (x == 0) {
let arr = JSON.parse(localStorage.getItem("bikes"));
let parent = document.querySelector(".bike-showcase");
arr.forEach((e) => {
if (e.type === category) {
let parent = document.querySelector(".bike-showcase");
let noclassdiv = document.createElement("div");
let bikeimgdiv = document.createElement("div");
let freenexcessdiv = document.createElement("div");
let pricenbooknowdiv = document.createElement("div");
let image = document.createElement("img");
let pname = document.createElement("p");
let pkilometer = document.createElement("p");
let pexcess = document.createElement("p");
let pprice = document.createElement("p");
let btn = document.createElement("button");
image.src = e.imgLink;
bikeimgdiv.append(image);
bikeimgdiv.setAttribute("class", "bike-img-cont");
pname.innerHTML = e.name;
pname.setAttribute("class", "bike-name");
pkilometer.innerHTML = `Free ${e.free} Kms`;
pkilometer.setAttribute("class", "free-kilometers");
pexcess.innerHTML = `Excess ₹${e.excess}/km`;
pexcess.setAttribute("class", "excess");
freenexcessdiv.setAttribute("class", "free-N-excess");
freenexcessdiv.append(pkilometer, pexcess);
pprice.innerHTML = `₹${e.price}`;
pprice.setAttribute("class", "price");
btn.innerHTML = "BOOK NOW";
btn.onclick = function() {
fav(e);
};
pricenbooknowdiv.setAttribute("class", "price-N-bookNow");
pricenbooknowdiv.append(pprice, btn);
noclassdiv.append(
bikeimgdiv,
pname,
freenexcessdiv,
pricenbooknowdiv
);
parent.append(noclassdiv);
}
});
return;
}
for (var i = 0, n = checkboxes.length; i < n; i++) {
if (checkboxes[i].checked == true) {
let arr = JSON.parse(localStorage.getItem("bikes"));
arr.forEach((e) => {
if (checkboxes[i].name === e.manufacturer && e.type === category) {
let parent = document.querySelector(".bike-showcase");
let noclassdiv = document.createElement("div");
let bikeimgdiv = document.createElement("div");
let freenexcessdiv = document.createElement("div");
let pricenbooknowdiv = document.createElement("div");
let image = document.createElement("img");
let pname = document.createElement("p");
let pkilometer = document.createElement("p");
let pexcess = document.createElement("p");
let pprice = document.createElement("p");
let btn = document.createElement("button");
image.src = e.imgLink;
bikeimgdiv.append(image);
bikeimgdiv.setAttribute("class", "bike-img-cont");
pname.innerHTML = e.name;
pname.setAttribute("class", "bike-name");
pkilometer.innerHTML = `Free ${e.free} Kms`;
pkilometer.setAttribute("class", "free-kilometers");
pexcess.innerHTML = `Excess ₹${e.excess}/km`;
pexcess.setAttribute("class", "excess");
freenexcessdiv.setAttribute("class", "free-N-excess");
freenexcessdiv.append(pkilometer, pexcess);
pprice.innerHTML = `₹${e.price}`;
pprice.setAttribute("class", "price");
btn.innerHTML = "BOOK NOW";
btn.onclick = function() {
fav(e);
};
pricenbooknowdiv.setAttribute("class", "price-N-bookNow");
pricenbooknowdiv.append(pprice, btn);
noclassdiv.append(
bikeimgdiv,
pname,
freenexcessdiv,
pricenbooknowdiv
);
parent.append(noclassdiv);
}
});
}
}
} else {
manufacturer();
}
}
function model() {
let model = document.getElementById("model");
var checkboxes = model.querySelectorAll("input");
let x = 0;
for (var i = 0, n = checkboxes.length; i < n; i++) {
if (checkboxes[i].checked == true) x++;
}
if (x > 0) {
let parent = document.querySelector(".bike-showcase");
parent.innerHTML = "";
for (var i = 0, n = checkboxes.length; i < n; i++) {
if (checkboxes[i].checked == true) {
let arr = JSON.parse(localStorage.getItem("bikes"));
arr.forEach((e) => {
if (checkboxes[i].name === e.model) {
let parent = document.querySelector(".bike-showcase");
let noclassdiv = document.createElement("div");
let bikeimgdiv = document.createElement("div");
let freenexcessdiv = document.createElement("div");
let pricenbooknowdiv = document.createElement("div");
let image = document.createElement("img");
let pname = document.createElement("p");
let pkilometer = document.createElement("p");
let pexcess = document.createElement("p");
let pprice = document.createElement("p");
let btn = document.createElement("button");
image.src = e.imgLink;
bikeimgdiv.append(image);
bikeimgdiv.setAttribute("class", "bike-img-cont");
pname.innerHTML = e.name;
pname.setAttribute("class", "bike-name");
pkilometer.innerHTML = `Free ${e.free} Kms`;
pkilometer.setAttribute("class", "free-kilometers");
pexcess.innerHTML = `Excess ₹${e.excess}/km`;
pexcess.setAttribute("class", "excess");
freenexcessdiv.setAttribute("class", "free-N-excess");
freenexcessdiv.append(pkilometer, pexcess);
pprice.innerHTML = `₹${e.price}`;
pprice.setAttribute("class", "price");
btn.innerHTML = "BOOK NOW";
btn.onclick = function() {
fav(e);
};
pricenbooknowdiv.setAttribute("class", "price-N-bookNow");
pricenbooknowdiv.append(pprice, btn);
noclassdiv.append(
bikeimgdiv,
pname,
freenexcessdiv,
pricenbooknowdiv
);
parent.append(noclassdiv);
}
});
}
}
} else {
vehicle();
}
}
function clearall() {
var checkboxes = document.querySelectorAll("input");
for (var i = 0, n = checkboxes.length; i < n; i++) {
checkboxes[i].checked = false;
}
bikes();
}
function showCollapseContentFilter() {
document
.getElementsByClassName("filter-bar")[0]
.classList.toggle("showFilter");
}
function showMobileNavBar() {
let navBar = document.getElementsByClassName("mobileNavBar")[0];
navBar.classList.toggle("active");
}
function changeCollapseBtnValue(collapse_btn_type, value) {
let collapse_btn = document.getElementsByClassName(collapse_btn_type)[0];
collapse_btn.innerHTML = value;
collapse_btn.classList.remove("active");
if (value == "30 DAYS BOOKING") {
document.getElementsByClassName("endDateSelector")[0].style.display =
"none";
} else {
document.getElementsByClassName("endDateSelector")[0].style.display =
"block";
}
localStorage.removeItem("endingDateObject");
}
function removePopUp(name) {
let popUpCont = document.getElementsByClassName(name)[0];
popUpCont.classList.add("hide");
if (popUpCont.classList.contains("active"))
popUpCont.classList.remove("active");
document.body.style.overflow = "visible";
}
function showSelectCity() {
let selectCityCont = document.getElementsByClassName("selectCity-overlay")[0];
console.log(selectCityCont);
selectCityCont.classList.toggle("hide");
selectCityCont.classList.add("active");
document.body.style.overflow = "hidden";
}
function addEventToCityArea() {
let cityArea = document.querySelectorAll(".cityArea .cityCont");
cityArea.forEach((cityCont) => {
cityCont.addEventListener("click", function() {
changeRideNowCityValue(this);
});
});
}
addEventToCityArea();
function changeRideNowCityValue(elem) {
let city = elem.children[0].children[1].innerHTML;
document.getElementsByClassName("rideNow-city-name")[0].innerHTML = city;
removePopUp("selectCity-overlay");
}
function showCalender(para) {
let calender = document.querySelector(`.${para} > .calender`);
let calender_timing = document.querySelector(`.${para} > .calender_timing`);
if (!calender_timing.classList.contains("hide")) {
calender_timing.classList.add("hide");
}
calender.classList.toggle("hide");
missionCalender(para);
}
function showSignup() {
let login = document.getElementById("login_form");
let signup = document.getElementById("signup_form");
let heading = document.getElementsByClassName("heading")[0];
let loginHeading = heading.children[0];
let signupHeading = heading.children[1];
login.classList.toggle("hide");
signup.classList.toggle("hide");
loginHeading.classList.toggle("currForm");
signupHeading.classList.toggle("currForm");
}
function showLoginSignupPopup() {
let loginDiv = document.getElementsByClassName("loginPopupOverlay")[0];
loginDiv.classList.toggle("hide");
document.body.style.overflow = "hidden";
}
function showContactPopup() {
let contactPopup = document.getElementsByClassName(
"contactUsForm-helpPopup-cont"
)[0];
contactPopup.classList.toggle("active");
}
function showrideNowCollapse() {
localStorage.removeItem("endingDateObject");
let btn = document.getElementsByClassName("collapse-btn-rideNow")[0];
btn.classList.toggle("active");
}
function signupUser(e) {
e.preventDefault();
const form = document.getElementById("signup_form");
let first_name = form.first_name.value;
let last_name = form.last_name.value;
let email = form.email.value;
let mobile = form.mobile.value;
let password = form.password.value;
let bool = true;
Array.from(form).forEach((input) => {
if (
input.value == "" &&
input.name != "last_name" &&
input.tagName != "BUTTON"
) {
bool = false;
document.querySelector(`#${input.id} ~ .required_field`).style.display =
"block";
}
});
if (bool) {
createUserAccount(first_name, last_name, email, mobile, password);
form.first_name.value = "";
form.last_name.value = "";
form.email.value = "";
form.mobile.value = "";
form.password.value = "";
}
}
function addInputEvent() {
const inputs = document.querySelectorAll(".input-event");
inputs.forEach((input) => {
input.addEventListener("input", function() {
validateInput(this);