-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlanding.html
671 lines (629 loc) · 43.1 KB
/
landing.html
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
<!DOCTYPE html ><html> <head><link href="css/index.57310f11.css" rel="stylesheet"/><meta name="viewport" content="width=device-width"/><link href="css/landing.5c1450f4.css" rel="stylesheet"/><script></script></head><body><div class="layout-header"><div class="header-logged-out"><div class="header-logged-out__container"><a class="logo" href="path-to-landing"><img class="logo__image logo__image_header" src="img/Logo.ac88cb0f.svg" alt=""></a><nav class="navbar"><ul class="list"><li class="list__item"> <a class="list__link" href="">О нас</a></li><ul class="list__item sublist"><a class="list__link list__icon" href="">Услуги</a><li class="sublist__item"></li><li class="sublist__item"></li><li class="sublist__item"></li><li class="sublist__item"></li><li class="sublist__item"></li></ul><li class="list__item"><a class="list__link" href="">Вакансии</a></li><li class="list__item"><a class="list__link" href="">Новости</a></li><ul class="list__item sublist"><a class="list__link list__icon" href="">Соглашения</a><li class="sublist__item"></li><li class="sublist__item"></li><li class="sublist__item"></li><li class="sublist__item"></li><li class="sublist__item"></li></ul></ul></nav><div class="auth"><button class="auth__button auth__button-register"><svg width="87" height="34" viewBox="0 0 87 34" fill="none" xmlns="http://www.w3.org/2000/svg">
<path id="Rectangle 2" d="M17 1H70C78.8365 1 86 8.16344 86 17C86 25.8366 78.8366 33 70 33H17C8.16345 33 1 25.8366 1 17C1 8.16344 8.16344 1 17 1Z" stroke="url(#paint0_linear_18370_50)" stroke-width="2"/>
<defs>
<linearGradient id="paint0_linear_18370_50" x1="43.5" y1="0" x2="43.5" y2="34" gradientUnits="userSpaceOnUse">
<stop stop-color="#BC9CFF"/>
<stop offset="1" stop-color="#8BA4F9"/>
</linearGradient>
</defs>
<text x="20" y="21" font-family="Montserrat" font-weight="bold" text-transform="uppercase" y="14" font-size="12" margin="auto" fill="#BB9BFF">
ВОЙТИ
</text>
</svg>
</button><button class="auth__button auth__button-sign-in" type="button"> <svg width="196" height="34" viewBox="0 0 196 34" fill="none" xmlns="http://www.w3.org/2000/svg">
<path id="Rectangle 2" d="M0 17C0 7.61116 7.61116 0 17 0H179C188.389 0 196 7.61116 196 17C196 26.3888 188.389 34 179 34H17C7.61116 34 0 26.3888 0 17Z" fill="url(#paint0_linear_18370_47)"/>
<defs>
<linearGradient id="paint0_linear_18370_47" x1="98" y1="0" x2="98" y2="34" gradientUnits="userSpaceOnUse">
<stop stop-color="#BC9CFF"/>
<stop offset="1" stop-color="#8BA4F9"/>
</linearGradient>
</defs>
<text x="20" y="21" font-family="Montserrat" font-weight="bold" text-transform="uppercase" y="14" font-size="12" fill="#FFFFFF">
ЗАРЕГИСТРИРОВАТЬСЯ
</text>
</svg>
</button></div><a class="header-logged-out__menu_inactive"><div class="header-logged-out__mobile header-logged-out__mobile_inactive"></div></a><div class="header-logged-out__mobile-menu header-logged-out__mobile-menu_inactive"><div class="mobile_hidden"><div class="mobile__inner"><div class="mobile__container"><ul class="mobile__list_hidden"><li class="mobile__list-item">О нас</li><li class="mobile__list-item mobile__sublist">Услуги</li><li class="mobile__list-item">Вакансии</li><li class="mobile__list-item">Новости</li><li class="mobile__list-item mobile__sublist">Соглашения</li></ul></div><div class="mobile__container"></div></div></div></div></div></div></div><div class="landing"><div class="landing__inner"><div class="landing__column"><div class="landing__column-container landing__column-container_first"><div class="room-finder"><div class="room-finder__main-container"><div class="room-finder__ui-container"><h1 class="room-finder__ui-text">Найдём номера под ваши пожелания</h1></div><div class="room-finder__date-container"> <div class="date-dropdown"><div class="date-dropdown_s"><div class="date-dropdown__ui"><div class="ui"><h3 class="form-paragraph__first">Прибытие</h3><p class="form-paragraph__second"></p></div></div><form class="date-dropdown__form_s"><p class="date-dropdown__input_s">ДД.ММ.ГГГГ</p><div class="date-dropdown__expand" isExpanded></div></form></div><div class="date-dropdown_s"><div class="date-dropdown__ui"><div class="ui"><h3 class="form-paragraph__first">Выезд</h3><p class="form-paragraph__second"></p></div></div><form class="date-dropdown__form_s"><p class="date-dropdown__input_s">ДД.ММ.ГГГГ</p><div class="date-dropdown__expand" isExpanded></div></form></div><div class="factual-dd_closed"><div class="factual-dd__container"><div class="factual-dd__top"><div class="factual-dd__arrow-left"></div><div class="factual-dd__date"> <p class="factual-dd__day-value_active" value="Август 2019">Август 2019</p><p class="factual-dd__month-value" value="Август 2019">2019 </p><p class="factual-dd__year-value" value="Август 2019">year range </p></div><div class="factual-dd__arrow-right"></div><div class="factual-dd__weekdays_active"></div></div><div class="factual-dd__middle"><div class="factual-dd__years"><div class="factual-dd__year">2009</div><div class="factual-dd__year">2010</div><div class="factual-dd__year">2011</div><div class="factual-dd__year">2012</div><div class="factual-dd__year">2013</div><div class="factual-dd__year">2014</div><div class="factual-dd__year">2015</div><div class="factual-dd__year">2016</div><div class="factual-dd__year">2017</div><div class="factual-dd__year">2018</div><div class="factual-dd__year">2019</div><div class="factual-dd__year">2020</div></div><div class="factual-dd__months"><div class="factual-dd__month">Янв</div><div class="factual-dd__month">Фев</div><div class="factual-dd__month">Мар</div><div class="factual-dd__month">Апр</div><div class="factual-dd__month">Май</div><div class="factual-dd__month">Июн</div><div class="factual-dd__month">Июл</div><div class="factual-dd__month">Авг</div><div class="factual-dd__month">Сен</div><div class="factual-dd__month">Окт</div><div class="factual-dd__month">Ноя</div><div class="factual-dd__month">Дек</div></div><div class="factual-dd__days_active"></div></div><div class="factual-dd__bottom"><div class="factual-dd__buttons"><div class="factual-dd__clear-container"><p class="factual-dd__clear">ОЧИСТИТЬ</p></div><div class="factual-dd__accept-container"><p class="factual-dd__accept">ПРИМЕНИТЬ</p></div></div></div></div></div></div><div class="test2" data="small,ui,Прибытие,,ui,Выезд,,ДД.ММ.ГГГГ,ДД.ММ.ГГГГ"></div></div><div class="room-finder__dropdown-container"><div class="dropdown dropdown_big"><div class="dropdown__ui-container_big"><div class="dropdown__ui"><div class="ui"><h3 class="form-paragraph__first">Гости</h3><p class="form-paragraph__second"></p></div></div></div><div class="dropdown__container"><div class="dropdown__input"><p class="dropdown__input-text" value="test">Сколько гостей</p><div class="dropdown__expand"></div></div><div class="dropdown__select_big"><div class="dropdown-list"><h3 class="dropdown-list__text">Взрослые</h3><div class="dropdown-list__options"><img class="dropdown-list__minus" src="img/minus.5e97e4df.svg" alt=""><div class="dropdown-list__quantity-container"><h3 class="dropdown-list__quantity" count="0">0</h3></div><img class="dropdown-list__plus" src="img/plus.c293966b.svg" alt=""></div></div><div class="dropdown-list"><h3 class="dropdown-list__text">Дети</h3><div class="dropdown-list__options"><img class="dropdown-list__minus" src="img/minus.5e97e4df.svg" alt=""><div class="dropdown-list__quantity-container"><h3 class="dropdown-list__quantity" count="0">0</h3></div><img class="dropdown-list__plus" src="img/plus.c293966b.svg" alt=""></div></div><div class="dropdown-list"><h3 class="dropdown-list__text">Младенцы</h3><div class="dropdown-list__options"><img class="dropdown-list__minus" src="img/minus.5e97e4df.svg" alt=""><div class="dropdown-list__quantity-container"><h3 class="dropdown-list__quantity" count="0">0</h3></div><img class="dropdown-list__plus" src="img/plus.c293966b.svg" alt=""></div></div><h3 class="dropdown__accept">Применить</h3></div></div></div></div><div class="room-finder__button"> <div class="button-container"><button class="button button_b button_default"><span class="button__text button__text_default">Подобрать номер</span></button></div><div class="test4" data="default,big,Подобрать номер"></div></div></div></div></div></div><div class="landing__column"><div class="landing__column-container landing__column-container_second"><p class="landing__text">Лучшие номера для вашей работы, отдыха и просто вдохновения</p></div></div></div></div><div class="layout-footer"> <div class="footer"> <div class="footer__wrapper"><div class="footer__container footer__container_first"><a class="logo" href="path-to-landing"><img class="logo__image" src="img/Logo.ac88cb0f.svg" alt=""></a><p class="footer__text">Бронирование номеров в лучшем отеле 2019 года по версии ассоциации «Отельные взгляды»</p></div><div class="footer__container footer__container_second"><ul class="footer__list"><li class="footer__list-item"><h3 class="footer__list-link">Навигация</h3></li><li class="footer__list-item"><a class="footer__list-link">О нас</a></li><li class="footer__list-item"><a class="footer__list-link">Новости</a></li><li class="footer__list-item"><a class="footer__list-link">Служба поддержки</a></li><li class="footer__list-item"><a class="footer__list-link">Услуги</a></li></ul></div><div class="footer__container footer__container_third"><ul class="footer__list"><li class="footer__list-item"><h3 class="footer__list-link">О нас</h3></li><li class="footer__list-item"><a class="footer__list-link">О сервисе</a></li><li class="footer__list-item"><a class="footer__list-link">Наша команда</a></li><li class="footer__list-item"><a class="footer__list-link">Вакансии</a></li><li class="footer__list-item"><a class="footer__list-link">Инвесторы</a></li></ul></div><div class="footer__container footer__container_fourth"><ul class="footer__list"><li class="footer__list-item"><h3 class="footer__list-link">Служба поддержки</h3></li><li class="footer__list-item"><a class="footer__list-link">Соглашения</a></li><li class="footer__list-item"><a class="footer__list-link">Сообщества</a></li><li class="footer__list-item"><a class="footer__list-link">Связь с нами</a></li></ul></div><div class="footer__container footer__container_fifth"><ul class="footer__list"><li class="footer__list-item"><h3 class="footer__list-link">Подписка</h3></li><li class="footer__list-item"><a class="footer__list-link">Получайте специальные предложения и новости сервиса</a></li></ul><div class="footer__text-field"><div class="substext"><div class="substext__ui"></div><form class="substext__form" action="#" method="get"><input class="substext__input" type="text" value="Email"><div class="substext__send"></div></form></div></div></div></div><div class="footer__copy-wrapper"><div class="footer__copy-container"><div class="footer__copy-text-container"><p class="footer__copy-text">Copyright © 2018 Toxin отель. Все права защищены.</p></div><div class="footer__copy-blank"> </div><div class="footer__copy-socials"><div class="socials"><img class="socials__svg" src="img/x.86f1a0de.svg" alt="image"><img class="socials__svg socials__svg_second" src="img/facebook.c5e8f56e.svg" alt="image"><img class="socials__svg socials__svg_third" src="img/instagram.db3a197a.svg" alt="image"></div></div></div></div></div><div class="footer-mobile"><div class="footer-mobile__container"><div class="footer-mobile__logo-container"><a class="logo" href="path-to-landing"><img class="logo__image" src="img/Logo.ac88cb0f.svg" alt=""></a></div><div class="footer-mobile__text-container"><p>Copyright © 2018 Toxin отель. Все права защищены.</p></div><div class="footer-mobile__socials-container"><div class="socials"><img class="socials__svg" src="img/x.86f1a0de.svg" alt="image"><img class="socials__svg socials__svg_second" src="img/facebook.c5e8f56e.svg" alt="image"><img class="socials__svg socials__svg_third" src="img/instagram.db3a197a.svg" alt="image"></div></div></div></div></div><script> (function(){
class Mobile{
constructor(){
this.button = document.getElementsByClassName("header-logged-out__menu_inactive").item(0);
this.active = false;
this.menu = document.getElementsByClassName("header-logged-out__mobile-menu").item(0);
this.submenu = document.getElementsByClassName("mobile_hidden").item(0);
this.list = document.getElementsByClassName("mobile__list_hidden").item(0);
this.button.addEventListener("click", this.menuHandler.bind(this));
}
menuHandler(){
console.log("done");
if (this.active == false){
this.menu.classList.replace("header-logged-out__mobile-menu_inactive", "header-logged-out__mobile-menu_active");
this.submenu.classList.replace("mobile_hidden","mobile");
this.list.classList.replace("mobile__list_hidden","mobile__list");
this.active = true;
console.log("false");
}
else{
this.menu.classList.replace("header-logged-out__mobile-menu_active","header-logged-out__mobile-menu_inactive");
this.submenu.classList.replace("mobile","mobile_hidden");
this.list.classList.replace("mobile__list","mobile__list_hidden");
this.active = false;
console.log("true");
}
}
}
let menu = new Mobile();
})();
//13 05 паспорт</script><script>(function(){
const buttons = document.getElementsByClassName("date-dropdown__expand");
const dropdown = document.getElementsByClassName("factual-dd__container");
class DropdownToggler{
constructor(numberButtons, numberDd){
this.button = buttons.item(numberButtons);
this.dropdown = dropdown.item(numberDd).parentElement;
this.button.addEventListener("click", this.clickHandler.bind(this));
}
clickHandler(){
console.log("yeeee");
this.dropdown.classList.toggle("factual-dd");
this.dropdown.classList.toggle("factual-dd_closed");
}
}
class Calendar{
constructor(ui = false, node, daysActive){
this.node = node;
this.isUi = ui;
this.weekdays = ["Пн","Вт","Ср","Чт","Пт","Сб","Вс"];
if (ui == true){
this.date = new Date(2019, 8, 0);
}
else{
this.date = new Date(2019, 1, 0);
}
this.numberdayweek = [6,0,1,2,3,4,5];
this.titleMonths = ["Январь","Февраль","Март","Апрель","Май","Июнь","Июль","Август","Сентябрь","Октябрь","Ноябрь","Декабрь"];
this.months = document.getElementsByClassName("factual-dd__months").item(node).childNodes;
this.firstChosen = null;
this.secondChosen = null;
this.listenerAssigned = false;
for (let i = 0; i < 12; i++){
this.months.item(i).setAttribute(`month-number`, i);
this.months.item(i).addEventListener("click", this.chooseMonth.bind(this));
this.months.item(i).addEventListener("click", this.showDays.bind(this));
};
this.years = document.getElementsByClassName("factual-dd__years").item(node).childNodes;
this.defaultYear = 2009;
for (let i = 0; i < 12; i++){
this.years.item(i).setAttribute(`year-number`, this.defaultYear);
this.years.item(i).addEventListener("click", this.showChosenYear.bind(this));
this.years.item(i).addEventListener("click", this.chooseMonth.bind(this));
this.years.item(i).addEventListener("click", this.showMonths.bind(this));
this.defaultYear++;
};
this.defaultYear = 2009;
this.weekdaysNode = document.getElementsByClassName("factual-dd__weekdays_active").item(node);
console.log(document.getElementsByClassName("factual-dd__weekdays_active"));
console.log(daysActive);
this.daysNode = document.getElementsByClassName("factual-dd__days_active").item(daysActive);
console.log(document.getElementsByClassName("factual-dd__days_active"));
this.dayValueNode = document.getElementsByClassName("factual-dd__day-value_active").item(node);
this.monthsNode = document.getElementsByClassName("factual-dd__months").item(node);
this.monthValueNode = document.getElementsByClassName("factual-dd__month-value").item(node);
this.yearValueNode = document.getElementsByClassName("factual-dd__year-value").item(node);
this.yearNode = document.getElementsByClassName("factual-dd__years").item(node);
this.acceptButton = document.getElementsByClassName("factual-dd__accept").item(node);
this.clearButton = document.getElementsByClassName("factual-dd__clear").item(node);
this.nextMonth = document.getElementsByClassName("factual-dd__arrow-right").item(node);
this.nextMonth.setAttribute("type", "month-changer");
this.previousMonth = document.getElementsByClassName("factual-dd__arrow-left").item(node);
this.previousMonth.setAttribute("type", "month-changer");
this.nextMonth.addEventListener("click", this.showNextMonth.bind(this));
this.previousMonth.addEventListener("click", this.showPreviousMonth.bind(this));
this.dayValueNode.addEventListener("click", this.showMonths.bind(this));
this.monthValueNode.addEventListener("click", this.showYears.bind(this));
this.yearValueNode.addEventListener("click", this.showDays.bind(this));
console.log(`calendar ${this.node} created`);
}
initDays(){
let cells = document.getElementsByClassName("factual-dd__months").item(this.node).nextElementSibling.childNodes;
console.log(this.node);
console.log(cells);
console.log(cells[0]);
for (let i = 0; i < 7; i++){ //initialising weekdays
let newDiv = document.createElement("div");
newDiv.className = "factual-dd__days_active";
let newContent = document.createTextNode(this.weekdays[i]);
console.log(newContent);
newDiv.appendChild(newContent);
this.weekdaysNode.appendChild(newDiv);
}
if (this.isUi == true){
cells[10].classList.add("factual-dd__cell_current");
cells[21].classList.add("factual-dd__chosen_first");
cells[22].classList.add("factual-dd__cell_highlighted");
cells[23].classList.add("factual-dd__cell_highlighted");
cells[24].classList.add("factual-dd__cell_highlighted");
cells[25].classList.add("factual-dd__chosen_last");
}
console.log(`calendar ${this.node} initDays done`);
}
countSkippedDays(exists = false, firstDayOfTheMonth, manual = false){//finding the first day of the month corresponding it to the day of the week
let dayPointer = 0;
let skippedDays = 0;
let maxDate = this.date.getDate();
this.date.setDate(1);
let currDay = this.date.getDay();
this.date.setDate(maxDate);
if (!exists){
var firstDayOfTheMonth = currDay;
}
for (let i = 0; i < 12; i++){
this.months.item(i).className = "factual-dd__month";
if(this.date.getMonth() == Number(this.months.item(i).getAttribute("month-number"))){
this.months.item(i).classList.add("factual-dd__month_selected");
}
if (this.date.getFullYear() == Number(this.years.item(i).getAttribute("year-number"))){
this.years.item(i).classList.add("factual-dd__year_selected");
}
}
currDay = this.numberdayweek[firstDayOfTheMonth];
let extended = false;
const factualDD = document.getElementsByClassName("factual-dd__container").item(this.node);
while (currDay !== dayPointer){
dayPointer++;
skippedDays++;
}
let requiredDays = this.date.getDate() + skippedDays;
if (requiredDays > 35){
factualDD.parentElement.className = "factual-dd_extended";
this.initEmptyCells(42, skippedDays, exists, manual);
extended = true;
}
else{
if (exists){
factualDD.parentElement.className = "factual-dd";
extended = false;
this.initEmptyCells(35, skippedDays, exists, manual);
}
this.initEmptyCells(35, skippedDays, exists, manual);
}
}
initEmptyCells(amount, skippedDays, exists = false, manual = false){
if (exists || manual){
while(document.getElementsByClassName("factual-dd__cell").length > 0){
document.getElementsByClassName("factual-dd__cell")[0].remove();
}
}
for (let i = 1; i <= amount; i++){ //initialising empty dates
let newDiv = document.createElement("div");
newDiv.className = "factual-dd__cell";
let newContent = document.createTextNode("");
newDiv.appendChild(newContent);
this.daysNode.appendChild(newDiv);
newDiv.setAttribute("day-number", i);
newDiv.addEventListener("click", this.markChosenDay.bind(this));
}
console.log(`empty cells calendar ${this.node} initialised`)
this.fillCurrentMonth(skippedDays);
}
fillCurrentMonth(skippedDays){
let dayPointer = skippedDays;
let nextDate = 0;
let wholeMonthArr = Array.prototype.slice.call(this.daysNode.childNodes);
for (let i = 1; i <= this.date.getDate(); i++){
wholeMonthArr[dayPointer].innerHTML = i;
dayPointer++;
nextDate = i + skippedDays;
}
this.fillLeftMonth(nextDate, wholeMonthArr, skippedDays);
}
fillLeftMonth(nextDate, wholeMonthArr, skippedDays){
let dayIterator = 1;
while(nextDate < wholeMonthArr.length){//filling the left out space with the next month
wholeMonthArr[nextDate].innerHTML = dayIterator;
dayIterator++;
nextDate++;
}
this.fillLastMonth(wholeMonthArr, skippedDays)
}
fillLastMonth(wholeMonthArr, skippedDays){
let lastDate = new Date(this.date.getFullYear(), this.date.getMonth(), 0).getDate();
skippedDays--;
while(skippedDays >= 0){
wholeMonthArr[skippedDays].innerHTML = lastDate;
skippedDays--;
lastDate--;
}
this.changeDateTitle();
}
changeDateTitle(){
this.dayValueNode.innerHTML = this.titleMonths[this.date.getMonth()] + " " + this.date.getFullYear();
this.monthValueNode.innerHTML = this.date.getFullYear();
this.yearValueNode.innerHTML = this.years.item(0).getAttribute("year-number") + " - " + this.years.item(11).getAttribute("year-number");
}
chooseMonth(e){
this.date.setDate(1);
this.date.setMonth(e.target.getAttribute("month-number"));
this.date.setDate(1);
let firstDayOfTheMonth = this.date.getDay();
this.date.setMonth(this.date.getMonth() + 1);
this.date.setDate(0);
this.countSkippedDays(true, firstDayOfTheMonth, true);
}
initYearRange(direction){
let yearMin = Number(this.years.item(0).getAttribute("year-number"));
yearMin = yearMin - 12;
let yearMax = Number(this.years.item(11).getAttribute("year-number"));
let negativeIterator = yearMin - 12;
while(document.getElementsByClassName("factual-dd__year").length > 0){
document.getElementsByClassName("factual-dd__year")[0].remove();
}
for (let i = 0; i < 12; i++){
let newDiv = document.createElement("div");
newDiv.className = "factual-dd__year";
let newContent = document.createTextNode("");
newDiv.appendChild(newContent);
this.yearNode.appendChild(newDiv);
this.years.item(i).addEventListener("click", this.showChosenYear.bind(this));
this.years.item(i).addEventListener("click", this.chooseMonth.bind(this));
this.years.item(i).addEventListener("click", this.showMonths.bind(this));
if (direction == false){
let result = yearMin + i;
this.years.item(i).innerHTML = result;
this.years.item(i).setAttribute(`year-number`, result);
this.defaultYear--;
}
else{
this.years.item(i).innerHTML = yearMax;
this.years.item(i).setAttribute(`year-number`, yearMax);
this.defaultYear++;
yearMax++;
}
}
}
showNextMonth(){
if (this.nextMonth.getAttribute("type") == "month-changer"){
this.date.setDate(1);
this.date.setMonth(this.date.getMonth() + 1);
let firstDayOfTheMonth = this.date.getDay();
this.date.setMonth(this.date.getMonth() + 1);
this.date.setDate(0);
let exists = true;
this.countSkippedDays(exists, firstDayOfTheMonth);
if (this.years.item(11) == this.date.getFullYear()){
this.initYearRange(true);
}
}
if (this.nextMonth.getAttribute("type") == "year-changer"){
this.date.setFullYear(this.date.getFullYear() + 1);
this.monthValueNode.innerHTML = this.date.getFullYear();
}
if (this.nextMonth.getAttribute("type") == "year-period-changer"){
this.initYearRange(true);
this.changeDateTitle();
}
}
showPreviousMonth(){
if (this.previousMonth.getAttribute("type") == "month-changer"){
let oldYear = this.date.getFullYear();
this.date.setDate(1);
this.date.setMonth(this.date.getMonth() - 1);
let firstDayOfTheMonth = this.date.getDay();
this.date.setMonth(this.date.getMonth() + 1);
this.date.setDate(0);
let exists = true;
this.countSkippedDays(exists, firstDayOfTheMonth);
if (oldYear != this.date.getFullYear()){
this.initYearRange(true);
}
}
if (this.previousMonth.getAttribute("type") == "year-changer"){
this.date.setFullYear(this.date.getFullYear() - 1);
this.monthValueNode.innerHTML = this.date.getFullYear();
}
if (this.previousMonth.getAttribute("type") == "year-period-changer"){
this.initYearRange(false);
this.changeDateTitle();
}
}
markChosenDay(e){
let cells = document.getElementsByClassName("factual-dd__months").item(this.node).nextElementSibling.childNodes;
let firstChanged = false;
if (this.firstChosen != undefined && this.secondChosen != undefined){
for (let i = 0; i < cells.length; i++){
cells.item(i).classList.remove("factual-dd__chosen");
}
this.firstChosen = undefined;
this.secondChosen = undefined;
this.removeHighlightedCells();
}
if (this.firstChosen == undefined || this.secondChosen != undefined){
this.removeChosen();
this.firstChosen = e.target;
e.target.classList.add("factual-dd__chosen");
firstChanged = true;
}
if (this.firstChosen != undefined && firstChanged == false){
this.secondChosen = e.target;
e.target.classList.add("factual-dd__chosen");
}
let str = "test"
if (this.listenerAssigned == false){
for (let i = 0; i < cells.length; i++){
cells.item(i).addEventListener("mouseover", highlightCells.bind(this));
this.listenerAssigned = true;
}
}
function highlightCells(f){
let cells = document.getElementsByClassName("factual-dd__months").item(this.node).nextElementSibling.childNodes;
if (this.secondChosen != null){
f.target.removeEventListener("mouseover", highlightCells);
this.listenerAssigned = false;
}
else {
this.removeHighlightedCells();
if(Number(e.target.getAttribute("day-number")) > Number(f.target.getAttribute("day-number"))){
this.removeChosen();
e.target.classList.add("factual-dd__chosen_first-reverse");
e.target.classList.add("factual-dd__chosen");
f.target.classList.add("factual-dd__chosen_last-reverse");
for (let i = Number(f.target.getAttribute("day-number")); i < Number(e.target.getAttribute("day-number")) - 1; i++){
cells.item(i).classList.add("factual-dd__cell_highlighted");
}
}
else {
this.removeChosen();
e.target.classList.add("factual-dd__chosen_first");
e.target.classList.add("factual-dd__chosen");
f.target.classList.add("factual-dd__chosen_last");
for (let i = Number(e.target.getAttribute("day-number")); i < Number(f.target.getAttribute("day-number")) - 1; i++){
cells.item(i).classList.add("factual-dd__cell_highlighted");
}
}
}
}
}
removeHighlightedCells(){
let cells = document.getElementsByClassName("factual-dd__cell");
for (let i = 0; i < document.getElementsByClassName("factual-dd__cell").length; i++){
cells.item(i).classList.remove("factual-dd__cell_highlighted");
}
}
removeChosen(){
let cells = document.getElementsByClassName("factual-dd__cell");
for (let i = 0; i < cells.length; i++){
cells.item(i).classList.remove("factual-dd__chosen");
cells.item(i).classList.remove("factual-dd__chosen_first");
cells.item(i).classList.remove("factual-dd__chosen_last");
cells.item(i).classList.remove("factual-dd__chosen_first-reverse");
cells.item(i).classList.remove("factual-dd__chosen_last-reverse");
cells.item(i).classList.remove("factual-dd__cell_current");
}
}
showChosenYear(e){
this.date.setFullYear(Number(e.target.getAttribute("year-number")));
}
showMonths(){
this.daysNode.classList.replace("factual-dd__days_active","factual-dd__days");
this.weekdaysNode.classList.replace("factual-dd__weekdays_active","factual-dd__weekdays");
this.dayValueNode.classList.replace("factual-dd__day-value_active","factual-dd__day-value");
this.monthValueNode.classList.replace("factual-dd__month-value","factual-dd__month-value_active");
this.monthsNode.classList.replace("factual-dd__months","factual-dd__months_active");
this.yearNode.classList.replace("factual-dd__years_active","factual-dd__years");
this.yearValueNode.classList.replace("factual-dd__year-value_active","factual-dd__year-value");
this.acceptButton.classList.replace("factual-dd__accept","factual-dd__accept_hidden");
this.clearButton.classList.replace("factual-dd__clear","factual-dd__clear_hidden");
this.nextMonth.setAttribute("type", "year-changer");
this.previousMonth.setAttribute("type", "year-changer");
}
showYears(){
this.monthValueNode.classList.replace("factual-dd__month-value_active","factual-dd__month-value");
this.yearValueNode.classList.replace("factual-dd__year-value","factual-dd__year-value_active");
this.yearValueNode.classList.replace("factual-dd__year-value","factual-dd__year-value_active");
this.monthsNode.classList.replace("factual-dd__months_active","factual-dd__months");
this.yearNode.classList.replace("factual-dd__years", "factual-dd__years_active");
this.nextMonth.setAttribute("type", "year-period-changer");
this.previousMonth.setAttribute("type", "year-period-changer");
}
showDays(){
this.yearValueNode.classList.replace("factual-dd__year-value_active","factual-dd__year-value");
this.monthValueNode.classList.replace("factual-dd__month-value_active","factual-dd__month-value");
this.monthsNode.classList.replace("factual-dd__months_active","factual-dd__months");
this.dayValueNode.classList.replace("factual-dd__day-value","factual-dd__day-value_active");
this.daysNode.classList.replace("factual-dd__days","factual-dd__days_active");
this.weekdaysNode.classList.replace("factual-dd__weekdays","factual-dd__weekdays_active");
this.yearNode.classList.replace("factual-dd__years_active","factual-dd__years");
this.acceptButton.classList.replace("factual-dd__accept_hidden","factual-dd__accept");
this.clearButton.classList.replace("factual-dd__clear_hidden","factual-dd__clear");
this.nextMonth.setAttribute("type", "month-changer");
this.previousMonth.setAttribute("type", "month-changer");
}
}
let buttonArr = [];
let dropdownArr = [];
let y = 0;
let daysActive = 0;
let firstSkip = false;
for (let i = 0; i < buttons.length; i++){
if(i % 2 == 0 && firstSkip){
y++;
}
buttonArr[i] = new DropdownToggler(i, y);
firstSkip = true;
}
y = 0;
for (let i = 0; i < dropdown.length; i++){
dropdownArr[i] = new Calendar(true, i, daysActive);
dropdownArr[i].countSkippedDays();
dropdownArr[i].initDays();
daysActive = daysActive + 8;
}
/*let button1 = new DropdownToggler(0, 0);
let button2 = new DropdownToggler(1, 0);
let button3 = new DropdownToggler(2, 1);
let button4 = new DropdownToggler(3, 1);
let calendar = new Calendar(true, 0);
let calendar1 = new Calendar(true, 1);*/
/*calendar.countSkippedDays();
calendar.initDays();
calendar1.countSkippedDays();
calendar1.initDays();*/
})();(function(){
const entityAmount = document.getElementsByClassName("dropdown");
const entitySelect = document.getElementsByClassName("dropdown__input");
const entityArr = [];
entityArr.length = entityAmount.length;
class Dropdown{
constructor(index){
this.expand = entityAmount.item(index).lastElementChild.firstElementChild.lastElementChild;
this.select = entityAmount.item(index).lastElementChild.lastElementChild;
this.selectNodes = entityAmount.item(index).lastChild.lastChild.childNodes;
this.options = entitySelect.item(index).nextElementSibling;
this.text = entitySelect.item(index).firstElementChild;
this.textSubArr1 = null;
this.textSubArr2 = null;
this.textSubArr3 = null;
this.accomodation = null;
this.ddtest = entitySelect.item(index).nextElementSibling.firstElementChild.firstElementChild;
if (this.ddtest.innerHTML == "Взрослые"){
this.accomodation = false;
}
else{
this.accomodation = true;
this.textSubArr1 = ["Спальня","Спальни","Спален"];
this.textSubArr2 = ["Кровать","Кровати","Кроватей"];
this.textSubArr3 = "";
this.textArr = [this.textSubArr1, this.textSubArr2, this.textSubArr3];
}
this.template = function(arr, textArray, acc){
return {
plus: entitySelect.item(index).nextElementSibling.childNodes[arr].lastElementChild.lastElementChild,
minus: entitySelect.item(index).nextElementSibling.childNodes[arr].lastElementChild.firstElementChild,
counter: entitySelect.item(index).nextElementSibling.childNodes[arr].lastElementChild.childNodes[1].firstElementChild,
textArr: textArray,
accomodation: acc,
accomodationValue: "",
get counterValue(){
return this.counter.innerHTML
},
set counterValue(value){
this.counter.innerHTML = value;
},
get subArray(){
return this.textArr;
},
get accValue(){
return this.accomodationValue;
},
assignListeners(){
this.plus.addEventListener("click", this.plusHandler.bind(this));
this.minus.addEventListener("click", this.minusHandler.bind(this));
},
plusHandler(e){
this.counterValue = parseInt(this.counterValue) + 1;
if (this.accomodation == true){
switch(parseInt(this.counterValue)){
case 0:
this.accomodationValue = ""
break;
case 1:
this.accomodationValue = this.subArray[arr][0]
break;
case 2: case 3: case 4:
this.accomodationValue = this.subArray[arr][1]
break;
default:
this.accomodationValue = this.subArray[arr][2]
}
}
},
minusHandler(e){
if (this.counterValue > 0){
this.counterValue = parseInt(this.counterValue) - 1;
if (this.accomodation == true){
switch(parseInt(this.counterValue)){
case 0:
this.accomodationValue = ""
break;
case 1:
this.accomodationValue = this.subArray[arr][0]
break;
case 2: case 3: case 4:
this.accomodationValue = this.subArray[arr][1]
break;
default:
this.accomodationValue = this.subArray[arr][2]
}
}
}
},
}
}
this.first = this.template(0, this.textArr, this.accomodation);
this.first.assignListeners();
this.second = this.template(1, this.textArr, this.accomodation);
this.second.assignListeners();
this.third = this.template(2, this.textArr, this.accomodation);
this.third.assignListeners();
this.minusArr = entityAmount.item(index).lastChild.lastChild;
this.counterArr = entityAmount.item(index).lastChild.lastChild;
this.expand.addEventListener("click", this.expandHandler.bind(this))
}
expandHandler(e){
switch(this.select.className){
case 'dropdown__select':
this.select.className = "dropdown__select_expanded"
break;
case 'dropdown__select_expanded':
this.select.className = "dropdown__select";
break;
case 'dropdown__select_big':
this.select.className = "dropdown__select_big-expanded"
break;
case 'dropdown__select_big-expanded':
this.select.className = "dropdown__select_big"
break;
}
}
assignListeners(e){
this.options.addEventListener("click",this.updateText.bind(this))
}
updateText(){
if (this.accomodation == false){
let value = parseInt(this.first.counterValue) + parseInt(this.second.counterValue) + parseInt(this.third.counterValue);
switch(value){
case 0:
this.text.innerHTML = "Сколько гостей"
break;
case 1:
this.text.innerHTML = value + " гость"
break;
case 2: case 3 :case 4:
this.text.innerHTML = value + " гостя"
break;
default:
this.text.innerHTML = value + " гостей"
break;
}
}
else{
let firstValue = this.first.counterValue + " " + this.first.accomodationValue;
let secondValue = this.second.counterValue + " " + this.second.accomodationValue;
if(this.first.counterValue == 0){
firstValue = "";
}
if(this.second.counterValue == 0){
secondValue = "";
}
let value = firstValue + " " + secondValue;
this.text.innerHTML = value;
}
}
}
function initEntities(){
for(let i = 0; i < entityAmount.length; i++){
entityArr[i] = new Dropdown(i);
entityArr[i].assignListeners();
}
}
initEntities();
})();
</script></body></html>