PageSourceSearch

http://www.renegadetravels.com/wp-content/themes/renegadetravels/js/searchbox-mask.js?ver=1.0.0

js renegadetravels.com collected 2026-10-04 20:05:29 UTC 4,297 bytes, 136 lines download raw bytes

1jQuery(function ($) {
2    var chkinInputIDName = '#agoda-arrive';
3    var nightsIDName = '#agoda-nights';
4    var searchInputIDName = '#agoda-city';
5
6    var searchVal = $(searchInputIDName).val();
7    var isSearchChanged = 0;
8
9    // Check ie
10    /**
11    * detect IE
12    * returns version of IE or false, if browser is not Internet Explorer
13    */
14    function detectIE() {
15        var ua = window.navigator.userAgent;
16
17        var msie = ua.indexOf('MSIE ');
18        if (msie > 0) {
19            // IE 10 or older => return version number
20            return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);
21        }
22
23        var trident = ua.indexOf('Trident/');
24        if (trident > 0) {
25            // IE 11 => return version number
26            var rv = ua.indexOf('rv:');
27            return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);
28        }
29
30        var edge = ua.indexOf('Edge/');
31        if (edge > 0) {
32            // IE 12 => return version number
33            return parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);
34        }
35
36        // other browser
37        return false;
38    }
39
40    // CLEARABLE INPUT
41    function tog(v) {
42        return v ? 'addClass' : 'removeClass';
43    }
44    $(document).on('input', '.clearable', function () {
45        if (!detectIE()) {
46            $(this)[tog(this.value)]('x');
47        }
48    }).on('mousemove', '.x', function (e) {
49        if (!detectIE()) {
50            $(this)[tog(this.offsetWidth - 24 < e.clientX - this.getBoundingClientRect().left)]('onX');
51        }
52    }).on('click', '.onX', function () {
53        if (!detectIE()) {
54            $(this).removeClass('x onX').val('').change();
55        }
56    }).on('click', '.clearable', function () {
57        if (!detectIE()) {
58            if ($(this).val != '') {
59                $(this)[tog(this.value)]('x');
60            }
61        }
62    });
63
64    // Check if value changed
65    $(searchInputIDName).focusout(function (e) {
66        var currentValue = $(this).val();
67        if (currentValue != searchVal) {
68            isSearchChanged = 1;
69        }
70    });
71
72    /* Calendar mask */
73    //$(".datepicker-mask").mask("99/99/9999", { placeholder: "dd/mm/yyyy" });
74    $( ".datepicker-mask" ).datepicker();
75
76    $(".agoda-arrive-item .fa.fa-calendar").click(function(){
77         $( ".datepicker-mask" ).datepicker('show')
78    });
79
80    // Press Enter
81    $.fn.onEnterKey =
82    function (closure) {
83        $(this).keypress(
84            function (event) {
85                var code = event.keyCode ? event.keyCode : event.which;
86
87                if (code == 13) {
88                    closure();
89                    return false;
90                }
91            });
92    }
93
94    function submitSearch() {
95        var _newWindow = jQuery("#newWindow").text();
96        var trafficUrl = jQuery("#trafficUrl").text();
97        var searchInput = jQuery("#agoda-city").val();
98        var checkinInput = jQuery(chkinInputIDName).val();
99        var nightsInput = jQuery(nightsIDName).val();
100
101       	var ckinDate = new Date(Date.parse(checkinInput));
102       	var ckoutDate = new Date(ckinDate.getTime() + nightsInput * 24*60*60*1000);
103       	var checkoutInput = formattedDate(ckoutDate );
104        checkinInput = formattedDate(ckinDate );
105       	
106        var landingUrl = trafficUrl + "&ad_searchText=" + encodeURI(searchInput) + "&ad_search_checkin_date=" + checkinInput
107                + "&ad_search_checkout_date=" + checkoutInput + "&ad_search_change_search=" + isSearchChanged;
108        if (_newWindow == "true") {
109            window.open(landingUrl);
110        }
111        else {
112            window.location = landingUrl;
113        }
114    }
115
116    $('.searchbox').onEnterKey(
117        function () {
118            submitSearch();
119        });
120
121    $("#agoda-search-button").click(function () {
122        submitSearch();
123    });
124
125    function formattedDate(date) {
126	    var d = new Date(date || Date.now()),
127	        month = '' + (d.getMonth() + 1),
128	        day = '' + d.getDate(),
129	        year = d.getFullYear();
130
131	    if (month.length < 2) month = '0' + month;
132	    if (day.length < 2) day = '0' + day;
133
134	    return [day, month , year].join('/');
135	}
136});

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.