PageSourceSearch

https://innatbayfortune.com/wp-content/plugins/swa-hotel/assets/js/swh-search.js

js innatbayfortune.com collected 2026-09-26 00:34:31 UTC 63,234 bytes, 1,282 lines download raw bytes

1/**
2 * @team: FsFlex Team
3 * @since: 1.0.0
4 * @author: KP
5 */
6(function ($) {
7    var extra_service = {};
8    var order_price = {};
9    var _edit_order = false;
10    var _edit_btn_sm = 2;
11    var _data = {
12            action: 'swh_filter',
13        },
14        form_data = {},
15        _avai = true;
16    var _g = $('.swh-checking-form').attr('data-g-m');
17    var _swh_search = {
18        init: function () {
19            var _thisss = this;
20            this.handles.select2Define();
21            $(document).ready(function () {
22                _thisss.handles.dateRange(false);
23                $(document).on('click', '.swh-btn-trig-priplan', function (e) {
24                    e.preventDefault();
25                    $('.cms-bootstrap-tabs a[href="#room-tab-pricing"]').trigger('click');
26                });
27                if (typeof extra_service_checkout !== 'undefined') {
28                    extra_service = extra_service_checkout;
29                }
30                if (typeof order_price_checkout !== 'undefined') {
31                    order_price = order_price_checkout;
32                }
33            });
34            this.events.submitFilter();
35            this.events.bookingSubmit();
36            this.events.upDownGuests();
37            this.events.priceRange();
38            this.events.otherClickEvents();
39            this.events.checkOutButtonHandle();
40            this.events.dashboardUpdatePass();
41            this.events.updateProfile();
42            this.events.changeExtraServiceOrder();
43            this.handles.submitBookingHanle();
44            this.events.saveActiveTabCookie();
45        },
46        events: {
47            otherClickEvents: function () {
48                $(document).on('change','.sort_by',function (e) {
49                    e.preventDefault();
50                    console.log('123');
51                    _swh_search.handles.ajaxFilter($('.swh-search-layout-4'));
52                });
53
54                $(document).on('click', '.btn-change-pass', function (e) {
55                    e.preventDefault();
56                    var _p = $(this).parent().parent().next();
57                    if (_p.css('display') === 'block') {
58                        _p.slideToggle("fast", function () {
59                        });
60                        _p.removeClass('is-active');
61                    } else {
62                        _p.slideToggle("fast", function () {
63                            _p.css('display', 'block');
64                        });
65                        _p.addClass('is-active');
66                    }
67                });
68                $(document).on('click', '.swh-ep.is-active', function (e) {
69                    e.preventDefault();
70                    return false;
71                });
72
73                $(document).on('click', '.swh-btn-cancel', function (e) {
74                    e.preventDefault();
75                    $(document).find('.swh-popup-edit-order').addClass('o-hidden');
76                    setTimeout(function () {
77                        $(document).find('.swh-popup-edit-order').remove();
78                    }, 1001);
79                });
80
81                $(document).on('click', '.swh-popup-edit-order', function (e) {
82                    // e.preventDefault();
83                    if ($(e.target)[0] === $(this)[0]) {
84                        $(document).find('.swh-popup-edit-order').addClass('o-hidden');
85                        setTimeout(function () {
86                            $(document).find('.swh-popup-edit-order').remove();
87                        }, 1001);
88                    }
89                });
90
91                $(document).on('click', '.swh-order-delete', function (e) {
92                    e.preventDefault();
93                    var _this = $(this),
94                        _oid = _this.attr('data-oid');
95                    var _cf = confirm(search_obj.confirm_delete_order);
96                    if (_cf === true) {
97                        $.ajax({
98                            url: search_obj.ajax_url,
99                            type: 'POST',
100                            beforeSend: function () {
101                                _this.parents('.item-inner').before('<div class="swh-dashboard-loading" style="display: block;">\n' +
102                                    '        <span class="fa fa-spinner fa-spin"></span>\n' +
103                                    '    </div>');
104                                $('.swh-dashboard-loading').css('display', 'block');
105                            },
106                            data: {
107                                action: 'dashboard_delete_order',
108                                _o_id: _oid
109                            }
110                        })
111                            .done(function (data) {
112                                if (data.stt === 'error') {
113                                    var x_cl = 'swh-' + (Math.floor((Math.random() * 1000) + 1) + Math.floor((Math.random() * 1000) + 1));
114                                    $('body').prepend('<div class="' + x_cl + '">' + data.msg + '</div>');
115                                    setTimeout(function () {
116                                        $('.' + x_cl).remove();
117                                    }, 4000);
118                                    return true;
119                                }
120                                if (data.stt === 'success') {
121                                    var x_cl = 'swh-' + (Math.floor((Math.random() * 1000) + 1) + Math.floor((Math.random() * 1000) + 1));
122                                    $('body').prepend('<div class="' + x_cl + '">' + data.msg + '</div>');
123                                    setTimeout(function () {
124                                        $('.' + x_cl).remove();
125                                        window.location.reload();
126                                    }, 2000);
127                                    return true;
128                                }
129                            })
130                            .fail(function () {
131                                return false;
132                            })
133                            .always(function () {
134                                $('.swh-dashboard-loading').remove();
135                                return false;
136                            });
137                    }
138                    return false;
139                });
140                $(document).on('click', '.swh-order-edit', function (e) {
141                    e.preventDefault();
142                    var _this = $(this),
143                        _oid = _this.attr('data-oid');
144                    $.ajax({
145                        url: search_obj.ajax_url,
146                        type: 'POST',
147                        beforeSend: function () {
148                            _this.parents('.item-inner').before('<div class="swh-dashboard-loading" style="display: block;">\n' +
149                                '        <span class="fa fa-spinner fa-spin"></span>\n' +
150                                '    </div>');
151                            $('.swh-dashboard-loading').css('display', 'block');
152                        },
153                        data: {
154                            action: 'dashboard_edit_order_layout',
155                            _o_id: _oid
156                        }
157                    })
158                        .done(function (data) {
159                            if (data.stt === 'error') {
160                                var x_cl = 'swh-' + (Math.floor((Math.random() * 1000) + 1) + Math.floor((Math.random() * 1000) + 1));
161                                $('body').prepend('<div class="' + x_cl + '">' + data.msg + '</div>');
162                                setTimeout(function () {
163                                    $('.' + x_cl).remove();
164                                }, 4000);
165                                return true;
166                            }
167                            if (data.stt === 'success') {
168                                extra_service = data.ex;
169                                order_price = data.order_price;
170                                _edit_order = true;
171                                _this.parents('body').prepend('<div class="swh-popup-edit-order o-hidden">' + data.layout + '</div>');
172                                setTimeout(function () {
173                                    $(document).find('.swh-popup-edit-order').removeClass('o-hidden');
174                                    _swh_search.handles.dateRange(true);
175                                }, 100);
176                                return true;
177                            }
178                        })
179                        .fail(function () {
180                            return false;
181                        })
182                        .always(function () {
183                            $('.swh-dashboard-loading').remove();
184                            return false;
185                        });
186                    return false;
187                });
188
189                $(document).on('click', '.swh-btn-update', function (e) {
190                    e.preventDefault();
191                    var _this = $(this);
192                    if (_edit_btn_sm !== 1) {
193                        return false;
194                    }
195                    var _sv_l_d = [];
196                    $(document).find('input.swh-ex-sv:checked').each(function () {
197                        var _this_s = $(this);
198                        _sv_l_d.push(parseInt(_this_s.val()));
199                    });
200                    var _ex_s = _sv_l_d.join();
201                    $.ajax({
202                        url: search_obj.ajax_url,
203                        type: 'POST',
204                        beforeSend: function () {
205                            _this.parents('.container').before('<div class="swh-dashboard-loading" style="display: block;">\n' +
206                                '        <span class="fa fa-spinner fa-spin"></span>\n' +
207                                '    </div>');
208                            $('.swh-dashboard-loading').css('display', 'block');
209                        },
210                        data: {
211                            action: 'dashboard_update_order',
212                            _o_id: _this.attr('data-oid'),
213                            _st_date: $("#swh-room-check-in").val(),
214                            _en_date: $("#swh-room-check-out").val(),
215                            _guest: $('#check-number-guests').val(),
216                            _ex_s: _ex_s
217
218                        }
219                    })
220                        .done(function (data) {
221                            if (data.stt === 'error') {
222                                var x_cl = 'swh-' + (Math.floor((Math.random() * 1000) + 1) + Math.floor((Math.random() * 1000) + 1));
223                                $('body').prepend('<div class="' + x_cl + '">' + data.msg + '</div>');
224                                setTimeout(function () {
225                                    $('.' + x_cl).remove();
226                                }, 4000);
227                                return true;
228                            }
229                            if (data.stt === 'successfully') {
230                                var x_cl = 'swh-' + (Math.floor((Math.random() * 1000) + 1) + Math.floor((Math.random() * 1000) + 1));
231                                $('body').prepend('<div class="' + x_cl + '">' + data.msg + '</div>');
232                                setTimeout(function () {
233                                    $('.' + x_cl).remove();
234                                    window.location.reload();
235                                }, 2000);
236                                return true;
237                            }
238                        })
239                        .fail(function () {
240                            return false;
241                        })
242                        .always(function () {
243                            $('.swh-dashboard-loading').remove();
244                            return false;
245                        });
246
247                });
248
249                $(document).on('change', 'input[type=radio][name=swh-follow]', function (e) {
250                    e.preventDefault();
251                    var _this = $(this);
252                    $.ajax({
253                        url: search_obj.ajax_url,
254                        type: 'POST',
255                        beforeSend: function () {
256                        },
257                        data: {
258                            action: 'swh_user_change_follow',
259                            _new_val: _this.val()
260                        }
261                    })
262                        .done(function (data) {
263                            if (data.stt === 'error') {
264                                var x_cl = 'swh-' + (Math.floor((Math.random() * 1000) + 1) + Math.floor((Math.random() * 1000) + 1));
265                                $('body').prepend('<div class="' + x_cl + '">' + data.msg + '</div>');
266                                setTimeout(function () {
267                                    $('.' + x_cl).remove();
268                                }, 4000);
269                                return true;
270                            }
271                            if (data.stt === 'success') {
272                                var x_cl = 'swh-' + (Math.floor((Math.random() * 1000) + 1) + Math.floor((Math.random() * 1000) + 1));
273                                $('body').prepend('<div class="' + x_cl + '">' + data.msg + '</div>');
274                                setTimeout(function () {
275                                    $('.' + x_cl).remove();
276                                }, 4000);
277                                return true;
278                            }
279                        })
280                        .fail(function () {
281                            return false;
282                        })
283                        .always(function () {
284                            return false;
285                        });
286                });
287                $(document).on('change', 'input[type=checkbox]#swh-receive-email', function (e) {
288                    e.preventDefault();
289                    var _this = $(this);
290                    var _val = _this.is(":checked");
291                    $.ajax({
292                        url: search_obj.ajax_url,
293                        type: 'POST',
294                        beforeSend: function () {
295                        },
296                        data: {
297                            action: 'swh_user_change_receive_notice',
298                            _new_val: _val,
299                            _type: 'swh-receive-email'
300                        }
301                    })
302                        .done(function (data) {
303                            if (data.stt === 'error') {
304                                var x_cl = 'swh-' + (Math.floor((Math.random() * 1000) + 1) + Math.floor((Math.random() * 1000) + 1));
305                                $('body').prepend('<div class="' + x_cl + '">' + data.msg + '</div>');
306                                setTimeout(function () {
307                                    $('.' + x_cl).remove();
308                                }, 4000);
309                                return true;
310                            }
311                            if (data.stt === 'success') {
312                                var x_cl = 'swh-' + (Math.floor((Math.random() * 1000) + 1) + Math.floor((Math.random() * 1000) + 1));
313                                $('body').prepend('<div class="' + x_cl + '">' + data.msg + '</div>');
314                                setTimeout(function () {
315                                    $('.' + x_cl).remove();
316                                }, 4000);
317                                return true;
318                            }
319                        })
320                        .fail(function () {
321                            return false;
322                        })
323                        .always(function () {
324                            return false;
325                        });
326                });
327                $(document).on('change', 'input[type=checkbox]#swh-receive-booking', function (e) {
328                    e.preventDefault();
329                    var _this = $(this);
330                    var _val = _this.is(":checked");
331                    $.ajax({
332                        url: search_obj.ajax_url,
333                        type: 'POST',
334                        beforeSend: function () {
335                        },
336                        data: {
337                            action: 'swh_user_change_receive_notice',
338                            _new_val: _val,
339                            _type: 'swh-receive-booking'
340                        }
341                    })
342                        .done(function (data) {
343                            if (data.stt === 'error') {
344                                var x_cl = 'swh-' + (Math.floor((Math.random() * 1000) + 1) + Math.floor((Math.random() * 1000) + 1));
345                                $('body').prepend('<div class="' + x_cl + '">' + data.msg + '</div>');
346                                setTimeout(function () {
347                                    $('.' + x_cl).remove();
348                                }, 4000);
349                                return true;
350                            }
351                            if (data.stt === 'success') {
352                                var x_cl = 'swh-' + (Math.floor((Math.random() * 1000) + 1) + Math.floor((Math.random() * 1000) + 1));
353                                $('body').prepend('<div class="' + x_cl + '">' + data.msg + '</div>');
354                                setTimeout(function () {
355                                    $('.' + x_cl).remove();
356                                }, 4000);
357                                return true;
358                            }
359                        })
360                        .fail(function () {
361                            return false;
362                        })
363                        .always(function () {
364                            return false;
365                        });
366                });
367            },
368            dashboardUpdatePass: function () {
369                $(document).on('click', '.swh-change-pass', function (e) {
370                    e.preventDefault();
371                    var _this = $(this),
372                        _this_form = _this.parents('.infor-change-popup'),
373                        _current_pass = _this_form.find('#current_password'),
374                        _pass1 = _this_form.find('#new_password'),
375                        _pass2 = _this_form.find('#new_password_re');
376                    _current_pass.removeClass('swh-error');
377                    _pass1.removeClass('swh-error');
378                    _pass2.removeClass('swh-error');
379                    $(document).find('.swh-notice-f').remove();
380                    if (_current_pass.val() === "") {
381                        _current_pass.addClass('swh-error');
382                        return;
383                    }
384                    if (_pass1.val() === "") {
385                        _pass1.addClass('swh-error');
386                        return;
387                    }
388                    if (_pass2.val() === "") {
389                        _pass2.addClass('swh-error');
390                        return;
391                    }
392                    if (_pass1.val() !== _pass2.val()) {
393                        _pass1.addClass('swh-error');
394                        _pass2.addClass('swh-error');
395                        _this.before('<p class="swh-notice-f swh-field-error">' + swh_notice_msg.pass_confirm + '</p>');
396                        return false;
397                    }
398                    $.ajax({
399                        url: search_obj.ajax_url,
400                        type: 'POST',
401                        beforeSend: function () {
402                            $('.swh-dashboard-loading').css('display', 'block');
403                        },
404                        data: {
405                            action: 'dashboard_change_pass',
406                            old_pass: _current_pass.val(),
407                            new_pass: _pass1.val(),
408                        }
409                    })
410                        .done(function (data) {
411                            if (data.status === 'error') {
412                                _this.before('<p class="swh-notice-f swh-field-error">' + data.msg + '</p>');
413                                return true;
414                            }
415                            if (data.status === 'success') {
416                                _this.before('<p class="swh-notice-f swh-field-success">' + data.msg + '</p>');
417                                return true;
418                            }
419                        })
420                        .fail(function () {
421                            return false;
422                        })
423                        .always(function () {
424                            $('.swh-dashboard-loading').css('display', 'none');
425                            return false;
426                        });
427                });
428            },
429            updateProfile: function () {
430                $(document).on('click', '.swh-save-profile-info', function (e) {
431                    e.preventDefault();
432                    var _this = $(this),
433                        _check = true,
434                        _this_form = _this.parents('form'),
435                        _top_f = _this.parents('.col-user-content'),
436                        _l_name = _this_form.find('#l_name'),
437                        _surname = _this_form.find('#surname'),
438                        _email = _this_form.find('#email'),
439                        _phone = _this_form.find('#phone'),
440                        _address = _this_form.find('#address'),
441                        _city = _this_form.find('#city');
442                    var _fields = [_l_name, _surname, _phone, _address, _city];
443                    _fields.forEach(function (item, index) {
444                        item.removeClass('swh-error');
445                        if (item[0].hasAttribute('required') && item.val() === "") {
446                            item.addClass('swh-error');
447                            _top_f[0].scrollIntoView({
448                                behavior: 'smooth',
449                                block: "start",
450                                inline: "start"
451                            });
452                            _check = false;
453                            return false;
454                        }
455                    });
456                    if (_email.length > 0) {
457                        var atpos = _email.val().indexOf("@");
458                        var dotpos = _email.val().lastIndexOf(".");
459                        if (atpos < 1 || dotpos < atpos + 2 || dotpos + 2 >= _email.val().length) {
460                            _email.addClass('swh-error');
461                            _top_f[0].scrollIntoView({
462                                behavior: 'smooth',
463                                block: "start",
464                                inline: "start"
465                            });
466                            return false;
467                        }
468                    } else {
469                        _email.addClass('swh-error');
470                        _top_f[0].scrollIntoView({
471                            behavior: 'smooth',
472                            block: "start",
473                            inline: "start"
474                        });
475                        return false;
476                    }
477                    if (!_check) return;
478                    $.ajax({
479                        url: search_obj.ajax_url,
480                        type: 'POST',
481                        beforeSend: function () {
482                            $('.swh-dashboard-loading').css('display', 'block');
483                        },
484                        data: {
485                            action: 'dashboard_save_profile',
486                            _l_name: _l_name.val(),
487                            _surname: _surname.val(),
488                            _email: _email.val(),
489                            _phone: _phone.val(),
490                            _address: _address.val(),
491                            _city: _city.val(),
492                        }
493                    })
494                        .done(function (data) {
495                            if (data.status === 'error') {
496                                var x_cl = 'swh-' + (Math.floor((Math.random() * 1000) + 1) + Math.floor((Math.random() * 1000) + 1));
497                                $('body').prepend('<div class="' + x_cl + '">' + data.msg + '</div>');
498                                setTimeout(function () {
499                                    $('.' + x_cl).remove();
500                                }, 4000);
501                                return true;
502                            }
503                            if (data.stt === 'success') {
504                                var x_cl = 'swh-' + (Math.floor((Math.random() * 1000) + 1) + Math.floor((Math.random() * 1000) + 1));
505                                $('body').prepend('<div class="' + x_cl + '">' + data.msg + '</div>');
506                                setTimeout(function () {
507                                    $('.' + x_cl).remove();
508                                    window.location.reload();
509                                }, 5000);
510                                return true;
511                            }
512                        })
513                        .fail(function () {
514                            return false;
515                        })
516                        .always(function () {
517                            $('.swh-dashboard-loading').css('display', 'none');
518                            return false;
519                        });
520                });
521            },
522            upDownGuests: function () {
523                $(document).on('click', '.swh-plus-guest', function (e) {
524                    e.preventDefault();
525                    var _parent = $(this).parents('.swh-search-guests'),
526                        _input_val = _parent.find('input[name=number-guests]'),
527                        _val = 1;
528                    if (_input_val.length > 0 && _input_val.val() !== "") {
529                        _val = _input_val.val();
530                    }
531                    if (parseInt(_val) > 0) {
532                        var new_val = parseInt(_val) + 1;
533                        _input_val.val(new_val);
534                        _parent.find('.guest-layout span').html(new_val);
535                    } else {
536                        return false;
537                    }
538                });
539                $(document).on('click', '.swh-minus-guest', function (e) {
540                    e.preventDefault();
541                    var _parent = $(this).parents('.swh-search-guests'),
542                        _input_val = _parent.find('input[name=number-guests]'),
543                        _val = 1;
544                    if (_input_val.length > 0 && _input_val.val() !== "") {
545                        _val = _input_val.val();
546                    }
547                    if (parseInt(_val) > 1) {
548                        var new_val = parseInt(_val) - 1;
549                        _input_val.val(new_val);
550                        _parent.find('.guest-layout span').html(new_val);
551                    } else {
552                        return false;
553                    }
554                });
555                $(document).on('click', '.swh-check-plus-guest', function (e) {
556                    e.preventDefault();
557                    var _parent = $(this).parents('.swh-checking-form');
558                    if (_edit_order) {
559                        _parent = $(this).parents('.swh-checking-form2');
560                    }
561                    var _input_val = _parent.find('#check-number-guests'),
562                        _val = 1;
563                    if (_input_val.length > 0 && _input_val.val() !== "") {
564                        _val = _input_val.val();
565                    }
566                    _g = _parent.attr('data-g-m');
567                    if (parseInt(_val) > 0 && parseInt(_val) < _g) {
568                        var new_val = parseInt(_val) + 1;
569                        _input_val.val(new_val);
570                        _parent.find('.check-guest-layout span').html(new_val);
571                        if (_edit_order) {
572                            _swh_search.handles.updateLayoutForm($("#swh-room-check-in"), true);
573                        }
574                    } else {
575                        return false;
576                    }
577                });
578                $(document).on('click', '.swh-check-minus-guest', function (e) {
579                    e.preventDefault();
580                    var _parent = $(this).parents('.swh-checking-form');
581                    if (_edit_order) {
582                        _parent = $(this).parents('.swh-checking-form2');
583                    }
584                    var _input_val = _parent.find('#check-number-guests'),
585                        _val = 1;
586                    if (_input_val.length > 0 && _input_val.val() !== "") {
587                        _val = _input_val.val();
588                    }
589                    if (parseInt(_val) > 1) {
590                        var new_val = parseInt(_val) - 1;
591                        _input_val.val(new_val);
592                        _parent.find('.check-guest-layout span').html(new_val);
593                        if (_edit_order) {
594                            _swh_search.handles.updateLayoutForm($("#swh-room-check-in"), true);
595                        }
596                    } else {
597                        return false;
598                    }
599                });
600            },
601            submitFilter: function () {
602                $(document).on('click', '.swh-filter-sm', function (e) {
603                    e.preventDefault();
604                    var _this_sm = $(this),
605                        _parent_form = _this_sm.parents('form');
606                    if (!_avai) {
607                        return;
608                    }
609                    _avai = false;
610                    var _check = true;
611                    if (typeof search_obj === 'undefined' || !search_obj.is_swh_archive) {
612                        _parent_form.submit();
613                    } else {
614                        _swh_search.handles.ajaxFilter(_parent_form);
615                    }
616                });
617                $(document).on('click', '.page-numbers', function (e) {
618                    if (typeof search_obj !== 'undefined' && search_obj.is_swh_archive) {
619                        e.preventDefault();
620                        var _this_p = $(this);
621                        var __page = 0;
622                        if (_this_p.parent().find('.prev').length > 0) {
623                            __page = _this_p.index();
624                        } else {
625                            __page = _this_p.index() + 1;
626                        }
627                        if (_this_p.hasClass('current')) {
628                            return;
629                        }
630                        if (_this_p.hasClass('prev')) {
631                            __page = _this_p.parent().find('.current').index() - 1;
632                        }
633                        if (_this_p.hasClass('next')) {
634                            if (_this_p.parent().find('.prev').length > 0) {
635                                __page = _this_p.parent().find('.current').index() + 1;
636                            } else {
637                                __page = _this_p.parent().find('.current').index() + 2;
638                            }
639                        }
640                        document.getElementById("content").scrollIntoView({
641                            behavior: 'smooth',
642                            block: "start",
643                            inline: "start"
644                        });
645                        var new_data = _data;
646                        new_data['swh_page'] = __page;
647                        $.ajax({
648                            url: search_obj.ajax_url,
649                            type: 'POST',
650                            beforeSend: function () {
651                                $('#swh-rooms').removeClass('swh-effect');
652                                $('#swh-rooms').removeClass('active');
653                                $('#swh-rooms').addClass('swh-effect');
654                            },
655                            data: new_data
656                        })
657                            .done(function (data) {
658                                if (data.status === 'done') {
659                                    $('#swh-rooms').html(data.layout);
660                                    $('#swh-rooms').addClass('active');
661                                }
662                            })
663                            .fail(function () {
664                                return false;
665                            })
666                            .always(function () {
667                                return false;
668                            });
669                    }
670                });
671            },
672            bookingSubmit: function () {
673                $(document).on('focus', '.swh-form-check-count input', function (e) {
674                    $(this).removeClass('swh-f-error');
675                });
676                $(document).on('click', 'a.swh-btn-done-order', function (e) {
677                    e.preventDefault();
678                    var f_name = $('input[name="your-name"]'),
679                        _surname = $('input[name="your-surname"]'),
680                        _email = $('input[name="your-email"]'),
681                        _phone = $('input[name="text-phone"]'),
682                        _address = $('input[name="your-address"]'),
683                        _zipcode = $('input[name="text-zip"]'),
684                        _msg = $('textarea[name="your-message"]'),
685                        _payment = $('input[name="swh-payment-method"]:checked'),
686                        _terms = $('input[name="swh-terms"]:checked'),
687                        _checkout_check = true;
688                    f_name.removeClass('swh-f-error');
689                    _surname.removeClass('swh-f-error');
690                    _email.removeClass('swh-f-error');
691                    _phone.removeClass('swh-f-error');
692                    _address.removeClass('swh-f-error');
693
694                    if (f_name.val() === "") {
695                        f_name.addClass('swh-f-error');
696                        _checkout_check = false;
697                    }
698                    if (_surname.val() === "") {
699                        _surname.addClass('swh-f-error');
700                        _checkout_check = false;
701                    }
702                    if (_email.val() === "") {
703                        _email.addClass('swh-f-error');
704                        _checkout_check = false;
705                    }
706                    if (_phone.val() === "") {
707                        _phone.addClass('swh-f-error');
708                        _checkout_check = false;
709                    }
710                    if (_address.val() === "") {
711                        _address.addClass('swh-f-error');
712                        _checkout_check = false;
713                    }
714                    var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
715                    if (_email.val() === "" || re.test(_email.val()) === false) {
716                        _email.addClass('swh-f-error');
717                        _checkout_check = false;
718                    }
719                    if (_payment.val() === "" || (_payment.val() !== "paypal" && _payment.val() !== "offline" && _payment.val() !== "bank")) {
720                        _checkout_check = false;
721                    }
722                    if (_terms.length < 1) {
723                        var x_cl = 'swh-' + (Math.floor((Math.random() * 1000) + 1) + Math.floor((Math.random() * 1000) + 1));
724                        $('body').prepend('<div class="' + x_cl + '">' + swh_order_data['terms_error'] + '</div>');
725                        setTimeout(function () {
726                            $('.' + x_cl).remove();
727                        }, 5000);
728                        _checkout_check = false;
729                    }
730                    if (_checkout_check) {
731                        var _new_data = {};
732                        _new_data['_name'] = f_name.val();
733                        _new_data['_surname'] = _surname.val();
734                        _new_data['_email'] = _email.val();
735                        _new_data['_phone'] = _phone.val();
736                        _new_data['_address'] = _address.val();
737                        _new_data['_zipcode'] = _zipcode.val();
738                        _new_data['_payment'] = _payment.val();
739                        _new_data['_msg'] = _msg.val();
740                        $.ajax({
741                            url: search_obj.ajax_url,
742                            type: 'POST',
743                            beforeSend: function () {
744                                $('.swh-order-loading').css('display', 'block');
745                            },
746                            data: {
747                                action: 'swh_checkout_handles',
748                                form_data: _new_data
749                            }
750                        })
751                            .done(function (data) {
752                                if (data.status === 'error') {
753                                    var x_cl = 'swh-' + (Math.floor((Math.random() * 1000) + 1) + Math.floor((Math.random() * 1000) + 1));
754                                    $('body').prepend('<div class="' + x_cl + '">' + data.message + '</div>');
755                                    setTimeout(function () {
756                                        $('.' + x_cl).remove();
757                                    }, 5000);
758                                } else {
759                                    if (data.status === 'success' && data.url !== false) {
760                                        window.location.href = data.url;
761                                    } else {
762                                        $('.swh-order-loading').after(data.message);
763                                        setTimeout(function () {
764                                            $('.swh-order-notification').addClass('open');
765                                        }, 100);
766                                    }
767                                }
768                            })
769                            .fail(function () {
770                                return false;
771                            })
772                            .always(function () {
773                                $('.swh-order-loading').css('display', 'none');
774                                return false;
775                            });
776                    }
777                    else {
778                        $('.tab-reservation-room')[0].scrollIntoView({
779                            behavior: "smooth",
780                            block: "start",
781                            inline: "start"
782                        });
783                    }
784                });
785                $(document).on('click', '.swh-noti-close', function (e) {
786                    e.preventDefault();
787                    var _this = $(this);
788                    _this.parents('.swh-order-notification').removeClass('open');
789                    setTimeout(function () {
790                        _this.parents('.swh-order-notification').remove();
791                        window.location.href = search_obj.room_page;
792                    }, 300);
793                });
794            },
795            priceRange: function () {
796                var _price_range = $(".swh-price-filter");
797                _price_range.slider({
798                    range: "min",
799                    min: 1,
800                    max: parseInt(_price_range.attr('data-max')),
801                    value: parseInt(_price_range.attr('data-max')),
802                    slide: function (event, ui) {
803                        var _p = _price_range.attr('data-price-format').replace('111', ui.value);
804                        _price_range.parent().find('.swh-p-filter').html(_p);
805                    },
806                    change: function (event, ui) {
807                        _price_range.parent().find('.swh-price-ft-val').val(ui.value);
808                        _swh_search.handles.ajaxFilter($('.swh-search-layout-4'));
809                    }
810                });
811            },
812            changeExtraServiceOrder: function () {
813                $(document).on('change', 'input.swh-ex-sv', function () {
814                    var _rs = _swh_search.handles.calcOrderPrice();
815                    $(document).find('.swh-value').html(_rs);
816                });
817                $(document).on('change', 'input[name="swh_select_extra_sv"]', function () {
818                    var _check = $(this);
819                    if (_check.val() === 'select_all') {
820                        $(document).find('input.swh-ex-sv').each(function () {
821                            $(this).prop('checked', true);
822                        });
823                        var _rs = _swh_search.handles.calcOrderPrice();
824                        $(document).find('.swh-value').html(_rs);
825                        return;
826                    }
827                    if (_check.val() === 'deselect_all') {
828                        $(document).find('input.swh-ex-sv').each(function () {
829                            $(this).prop('checked', false);
830                        });
831                        var _rs = _swh_search.handles.calcOrderPrice();
832                        $(document).find('.swh-value').html(_rs);
833                        return;
834                    }
835                });
836            },
837            checkOutButtonHandle: function () {
838                $(document).on('click', '.swh-btn-reser', function (e) {
839                    e.preventDefault();
840                    $(this).parents('.cms-bootstrap-tabs-checkout').find('a[href="#tab-rome-reservation"]').trigger('click');
841                });
842
843            },
844            saveActiveTabCookie: function () {
845                $(document).on('click', 'a[href="#tab-rome-reservation"]', function (e) {
846                    if ($(this).parent().hasClass('active')) return;
847                    _swh_search.handles.saveActiveTabCheckout('t_2');
848                });
849                $(document).on('click', 'a[href="#tab-rome-rate"]', function (e) {
850                    if ($(this).parent().hasClass('active')) return;
851                    _swh_search.handles.saveActiveTabCheckout('');
852                });
853            }
854        },
855        handles: {
856            ajaxFilter: function (_parent_form) {
857                $.ajax({
858                    url: search_obj.ajax_url,
859                    type: 'POST',
860                    beforeSend: function () {
861                        $('#swh-rooms').removeClass('swh-effect');
862                        $('#swh-rooms').removeClass('active');
863                        $('#swh-rooms').addClass('swh-effect');
864                    },
865                    data: {
866                        action: 'swh_filter',
867                        swh_type: _parent_form.find('select[name=room-type]').val(),
868                        date_start: _parent_form.find('#swh-ft-check-in').val(),
869                        date_end: _parent_form.find('#swh-ft-check-out').val(),
870                        number_guests: _parent_form.find('select[name=number-guests]').val(),
871                        max_price: $(document).find('.swh-price-ft-val').val(),
872                        sort_by: $(document).find('.sort_by').val(),
873                    }
874                })
875                    .done(function (data) {
876                        if (data.status === 'done') {
877                            $('#swh-rooms').html(data.layout);
878                            _data = {
879                                action: 'swh_filter',
880                                swh_type: _parent_form.find('select[name=room-type]').val(),
881                                date_start: _parent_form.find('#swh-ft-check-in').val(),
882                                date_end: _parent_form.find('#swh-ft-check-out').val(),
883                                number_guests: _parent_form.find('select[name=number-guests]').val(),
884                                sort_by: $(document).find('.sort_by').val()
885                            };
886                            $('#swh-rooms').addClass('active');
887                        }
888                    })
889                    .fail(function () {
890                        return false;
891                    })
892                    .always(function () {
893                        _avai = true;
894                        return false;
895                    });
896            },
897            select2Define: function () {
898                var swh_type_select = $('#swh-fl-type');
899                swh_type_select.select2({
900                    placeholder: swh_type_select.attr('data-place'),
901                    allowClear: true
902                });
903                $('#swh-type').select2({
904                    placeholder: $('#swh-type').attr('data-place'),
905                    allowClear: true
906                });
907                $(document).on('click', '.swh-alert-close', function (e) {
908                    e.preventDefault();
909                    $(this).parents('.swh-alert').remove();
910                });
911            },
912            dateRange: function (_edit) {
913                var _now = new Date();
914                var dateFormat = "mm/dd/yy";
915
916                /**
917                 * Single Room filter price order
918                 */
919                var date_from_r = $("#swh-room-check-in"),
920                    date_to_r = $("#swh-room-check-out");
921                var dateValFormat = "yy-mm-dd",
922                    from_r = date_from_r
923                        .datepicker({
924                            changeMonth: true,
925                            numberOfMonths: 1,
926                            dateFormat: dateFormat,
927                            minDate: new Date(),
928                            onSelect: function () {
929                                var date = getDate(this);
930                                var date_val = getDate(this);
931                                if (date) {
932                                    date.setDate(date.getDate() + 1);
933                                }
934                                to_r.datepicker("option", "minDate", date);
935                                _swh_search.handles.updateLayoutForm($(this), _edit);
936                                setTimeout(function () {
937                                    to_r.datepicker("show");
938                                }, 300);
939                            }
940                        }),
941                    to_r = date_to_r.datepicker({
942                        changeMonth: true,
943                        numberOfMonths: 1,
944                        dateFormat: dateFormat,
945                        minDate: (_now.getDate + 1),
946                        onSelect: function () {
947                            var date = getDate(this);
948                            var date_val = getDate(this);
949                            if (date) {
950                                date.setDate(date.getDate() - 1);
951                            }
952                            _swh_search.handles.updateLayoutForm($(this), _edit);
953                            from_r.datepicker("option", "maxDate", date);
954                        }
955                    });
956
957                /**
958                 * Date range search
959                 */
960                $(document).on('click', '.date-checkin-layout', function (e) {
961                    e.preventDefault();
962                    $(this).parent().find('input[name=check-in]').trigger('focus');
963                });
964                $(document).on('click', '.date-checkout-layout', function (e) {
965                    e.preventDefault();
966                    $(this).parent().find('input[name=check-out]').trigger('focus');
967                });
968                $("#swh-book-date").datepicker({
969                    changeMonth: true,
970                    numberOfMonths: 1,
971                    dateFormat: dateFormat,
972                    minDate: new Date()
973                });
974                var date_froms = $(".swh-ft-check-in"),
975                    date_tos = $(".swh-ft-check-out");
976                date_froms.each(function () {
977                    var date_from = $(this);
978                    var date_to = $(this).parents('form').find('.swh-ft-check-out');
979                    var from = date_from
980                            .datepicker({
981                                changeMonth: true,
982                                numberOfMonths: 1,
983                                dateFormat: dateFormat,
984                                minDate: new Date(),
985                                onSelect: function () {
986                                    var date = getDate(this);
987                                    var date_val = getDate(this);
988                                    if (date) {
989                                        date.setDate(date.getDate() + 1);
990                                    }
991                                    $(this).parent().find('.date').html(date_val.getDate());
992                                    $(this).parent().find('.month').html(_swh_search.handles.swhGetMonth(date_val));
993                                    to.datepicker("option", "minDate", date);
994                                    setTimeout(function () {
995                                        to.datepicker("show");
996                                    }, 300);
997                                }
998                            }),
999                        to = date_to.datepicker({
1000                            changeMonth: true,
1001                            numberOfMonths: 1,
1002                            dateFormat: dateFormat,
1003                            minDate: (_now.getDate + 1),
1004                            onSelect: function () {
1005                                var date = getDate(this);
1006                                var date_val = getDate(this);
1007                                if (date) {
1008                                    date.setDate(date.getDate() - 1);
1009                                }
1010
1011                                $(this).parent().find('.date').html(date_val.getDate());
1012                                $(this).parent().find('.month').html(_swh_search.handles.swhGetMonth(date_val));
1013                                from.datepicker("option", "maxDate", date);
1014                            }
1015                        });
1016                });
1017                function getDate(element) {
1018                    var date;
1019                    try {
1020                        date = $.datepicker.parseDate(dateFormat, element.value);
1021                    } catch (error) {
1022                        date = null;
1023                    }
1024
1025                    return date;
1026                }
1027
1028
1029                function convertDate(date_old) {
1030                    var month = date_old.getMonth() + 1,
1031                        day = date_old.getDate();
1032                    month = month.toString().length === 1 ? '0' + month : month;
1033                    day = day.toString().length === 1 ? '0' + day : day;
1034
1035                    var date = date_old.getFullYear() + '-' + (month) + '-' + day;
1036                    return date;
1037                }
1038
1039
1040            },
1041            swhGetMonth: function (date) {
1042                var _mths = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
1043                return _mths[date.getMonth()];
1044            },
1045            getDayOfWeek: function (date) {
1046                var _w = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
1047                return _w[date.getDay()];
1048            },
1049            updateLayoutForm: function (_this, _edit) {
1050                var _parents = _this.parents('.swh-checking-form');
1051                if (_edit) {
1052                    _parents = _this.parents('.swh-checking-form2');
1053                    $.ajax({
1054                        url: search_obj.ajax_url,
1055                        type: 'POST',
1056                        beforeSend: function () {
1057                            _edit_btn_sm = 2;
1058                            $(document).find('.swh-btn-update').css('opacity', '0.4');
1059                            $(document).find('.swh-btn-update').css('cursor', 'context-menu');
1060                        },
1061                        data: {
1062                            action: 'swh_refresh_order_price',
1063                            _o_id: _parents.attr('data-oid'),
1064                            _st_date: $("#swh-room-check-in").val(),
1065                            _en_date: $("#swh-room-check-out").val(),
1066                            _guest: $('#check-number-guests').val()
1067                        }
1068                    })
1069                        .done(function (data) {
1070                            if (data.stt === 'error') {
1071                                _edit_btn_sm = 0;
1072                                $(document).find('.swh-btn-update').css('opacity', '0.4');
1073                                $(document).find('.swh-btn-update').css('cursor', 'context-menu');
1074                                var x_cl = 'swh-' + (Math.floor((Math.random() * 1000) + 1) + Math.floor((Math.random() * 1000) + 1));
1075                                $('body').prepend('<div class="' + x_cl + '">' + data.msg + '</div>');
1076                                setTimeout(function () {
1077                                    $('.' + x_cl).remove();
1078                                }, 5000);
1079                            }
1080                            if (data.stt === 'success') {
1081                                _edit_btn_sm = 1;
1082                                $(document).find('.swh-btn-update').css('opacity', '1');
1083                                $(document).find('.swh-btn-update').css('cursor', 'pointer');
1084                                extra_service = data.ex;
1085                                order_price = data.order_price;
1086                                var _rs = _swh_search.handles.calcOrderPrice();
1087                                $(document).find('.swh-value').html(_rs);
1088                            }
1089                        })
1090                        .fail(function () {
1091                            return false;
1092                        })
1093                        .always(function () {
1094                            return false;
1095                        });
1096                }
1097                var _from_val = new Date(_parents.find('#swh-room-check-in').val()),
1098                    _to_val = new Date(_parents.find('#swh-room-check-out').val());
1099                _parents.find('.swh-check-in').find('.date-label').html(_from_val.getDate());
1100                _parents.find('.swh-check-in').find('.detail-date-label').html(_swh_search.handles.swhGetMonth(_from_val) + ', ' + _from_val.getFullYear() + ' - ' + _swh_search.handles.getDayOfWeek(_from_val));
1101
1102                _parents.find('.swh-check-out').find('.date-label').html(_to_val.getDate());
1103                _parents.find('.swh-check-out').find('.detail-date-label').html(_swh_search.handles.swhGetMonth(_to_val) + ', ' + _to_val.getFullYear() + ' - ' + _swh_search.handles.getDayOfWeek(_to_val));
1104
1105                var days = Math.floor(_to_val.getTime() - _from_val.getTime()) / (1000 * 60 * 60 * 24);
1106                days = parseInt(days) >= 1 || days === "" ? days : 0;
1107                $(document).find('.check-night-layout span').html(days);
1108            },
1109
1110            checkDateAvailable: function (from_date, to_date) {
1111                form_data.st_date = from_date;
1112                form_data.en_date = to_date;
1113                $('.acm-book-date').removeAttr('style');
1114                $('.acm-book-checkin').removeAttr('style');
1115                $('.acm-book-checkout').removeAttr('style');
1116                $('.acm-notification').remove();
1117                $.ajax({
1118                    url: booking_form_data.ajax_url,
1119                    type: 'POST',
1120                    beforeSend: function () {
1121                        $('.acm-loading').css('display', 'block');
1122                    },
1123                    data: {
1124                        action: 'check_available_date_booking',
1125                        acm_id: booking_form_data.acm_id,
1126                        date_start: from_date,
1127                        date_end: to_date
1128                    }
1129                })
1130                    .done(function (data) {
1131                        if (data.status === 'error') {
1132                            $('.acm-order-submit').after('<p class="acm-notification">' + data.message + '</p>');
1133                            var style_error = 'border-color:red';
1134                            $('.acm-book-date').attr('style', style_error);
1135                            $('.acm-book-checkin').attr('style', style_error);
1136                            $('.acm-book-checkout').attr('style', style_error);
1137                            _check = false;
1138                        } else {
1139                            _check = true;
1140                        }
1141                    })
1142                    .fail(function () {
1143                        return false;
1144                    })
1145                    .always(function () {
1146                        $('.acm-loading').css('display', 'none');
1147                        return false;
1148                    });
1149            },
1150            submitBookingHanle: function () {
1151                var _check_b = true;
1152                form_data = {};
1153                $(document).on('click', '.swh-book', function (e) {
1154                    e.preventDefault();
1155                    if (typeof swh_single === 'undefined' || !_check_b) {
1156                        return;
1157                    }
1158                    $('.swh-alert').remove();
1159                    _check_b = false;
1160
1161                    form_data.st_date = $('#swh-room-check-in').val();
1162                    form_data.en_date = $('#swh-room-check-out').val();
1163                    form_data.guest = $('#check-number-guests').val();
1164
1165                    $.ajax({
1166                        url: search_obj.ajax_url,
1167                        type: 'POST',
1168                        beforeSend: function () {
1169                        },
1170                        data: {
1171                            action: 'swh_order_handles',
1172                            swh_id: swh_single.id,
1173                            form_data: form_data
1174                        }
1175                    })
1176                        .done(function (data) {
1177                            if (data.status === 'error') {
1178                                var x_cl = 'swh-' + (Math.floor((Math.random() * 1000) + 1) + Math.floor((Math.random() * 1000) + 1));
1179                                $('body').prepend('<div class="' + x_cl + '">' + data.message + '</div>');
1180                                setTimeout(function () {
1181                                    $('.' + x_cl).remove();
1182                                }, 5000);
1183                            } else {
1184                                if (data.status === 'done' && data.url !== false) {
1185                                    window.location.href = data.url;
1186                                } else {
1187                                    $('.swh-book').after('<p class="swh-notification">' + data.message + '</p>');
1188                                }
1189                            }
1190                        })
1191                        .fail(function () {
1192                            return false;
1193                        })
1194                        .always(function () {
1195                            _check_b = true;
1196                            return false;
1197                        });
1198                });
1199            },
1200            calcOrderPrice: function () {
1201                if (typeof extra_service === 'undefined' || typeof order_price === 'undefined') {
1202                    return;
1203                }
1204                var _ex_s = 0;
1205                var _sv_l = [];
1206                $(document).find('input.swh-ex-sv:checked').each(function () {
1207                    var _this_s = $(this);
1208                    _sv_l.push(parseInt(_this_s.val()));
1209                    _ex_s += parseInt(extra_service[parseInt(_this_s.val())]);
1210                });
1211                if (!_edit_order) {
1212                    _swh_search.handles.saveCookieExtraServices(_sv_l.join());
1213                }
1214                var or_p = _ex_s + parseInt(order_price['price']);
1215                var or_p_with_vat = (or_p + (or_p * parseInt(order_price['vat']) / 100)).toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
1216                var _rs_p = '',
1217                    _symbol = order_price['symbol'];
1218                switch (order_price['position']) {
1219                    case 'right':
1220                        _rs_p = or_p_with_vat + _symbol;
1221                        break;
1222                    case 'right_space':
1223                        _rs_p = or_p_with_vat + ' ' + _symbol;
1224                        break;
1225                    case 'left_space':
1226                        _rs_p = _symbol + ' ' + or_p_with_vat;
1227                        break;
1228                    default:
1229                        _rs_p = _symbol + or_p_with_vat;
1230                        break;
1231                }
1232                if (_edit_btn_sm === 2) {
1233                    _edit_btn_sm = 1;
1234                    $(document).find('.swh-btn-update').css('opacity', '1');
1235                    $(document).find('.swh-btn-update').css('cursor', 'pointer');
1236                }
1237                return _rs_p;
1238            },
1239            saveCookieExtraServices: function (list) {
1240                $.ajax({
1241                    url: search_obj.ajax_url,
1242                    type: 'POST',
1243                    beforeSend: function () {
1244                    },
1245                    data: {
1246                        action: 'swh_change_service_cookie',
1247                        sv: list
1248                    }
1249                })
1250                    .done(function (data) {
1251                    })
1252                    .fail(function () {
1253                        return false;
1254                    })
1255                    .always(function () {
1256                        return false;
1257                    });
1258            },
1259            saveActiveTabCheckout: function (event) {
1260                $.ajax({
1261                    url: search_obj.ajax_url,
1262                    type: 'POST',
1263                    beforeSend: function () {
1264                    },
1265                    data: {
1266                        action: 'swh_change_active_tab_cookie',
1267                        swh_tab_act: event
1268                    }
1269                })
1270                    .done(function (data) {
1271                    })
1272                    .fail(function () {
1273                        return false;
1274                    })
1275                    .always(function () {
1276                        return false;
1277                    });
1278            }
1279        }
1280    };
1281    _swh_search.init();
1282})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.