PageSourceSearch

https://www.atlanticvacationhomes.com/wp-content/themes/altitude-pro/vrp/js/vrp.unit.js?ver=7.0.5.1790412455

js atlanticvacationhomes.com collected 2026-09-26 08:48:43 UTC 15,068 bytes, 431 lines download raw bytes

1/**
2 * Unit Availability Check & Pricing Request/Breakdown
3 */
4var disabledDays, unitDataSource;
5
6jQuery(document).ready(function () {
7
8    /**
9     * JavaScript applied to the unit.php VRPConnector theme file
10     */
11    unitDataSource = jQuery("#unit-data");
12
13    /**
14     * Determine if Unit Page Views module is enabled & log the page view if it is.
15     */
16    var displayPageViews = unitDataSource.data('display-pageviews');
17    var unitId = unitDataSource.data('unit-id');
18
19    if (displayPageViews == "true") {
20        jQuery.get(url_paths.site_url, {vrpjax: true, act: "saveUnitPageView", par: unitId, cache: Math.random()});
21    }
22
23    jQuery("#checkbutton").click(function () {
24        if (arrivalDateForm.val() == "" || departureDateForm.val() == "") {
25            showCustomError('Please enter an arrival date and a departure date.');
26        } else {
27            checkAvailability();
28        }
29    });
30
31    jQuery('select[name="obj[Adults]"]').change(checkAvailability);
32    jQuery('select[name="obj[Pets]"]').change(checkAvailability);
33
34    var arrivalDateForm = jQuery("#check-availability-arrival-date");
35    var departureDateForm = jQuery("#check-availability-departure-date");
36
37    if (arrivalDateForm.length
38      && arrivalDateForm.val() != ""
39      && departureDateForm.length
40      && departureDateForm.val() != "") {
41        checkAvailability();
42    }
43
44    var unitSlug = unitDataSource.data('unit-slug');
45    jQuery.get(url_paths.site_url + "/?vrpjax=1&act=getUnitBookedDates&par=" + unitSlug, function (data) {
46        disabledDays = jQuery.parseJSON(data);
47    });
48
49    var checkAvailArrival, checkAvailDeparture;
50
51    if (jQuery("#check-availability-arrival-date").length > 0)
52    {
53        checkAvailArrival = jQuery("#check-availability-arrival-date").datepicker({
54            minDate: 0,
55            onSelect: function () {
56                var minimumDepartureDate = checkAvailArrival.datepicker('getDate');
57                minimumDepartureDate.setDate(minimumDepartureDate.getDate() + getMinLOS(minimumDepartureDate));
58                checkAvailDeparture.datepicker('setDate', minimumDepartureDate);
59                checkAvailDeparture.datepicker('option', 'minDate', minimumDepartureDate);
60            },
61            beforeShowDay: noCheckinOrBookedDates
62        });
63
64        checkAvailDeparture = jQuery("#check-availability-departure-date").datepicker({
65            onSelect: function () {
66           var arrivalDate=jQuery("#check-availability-arrival-date").datepicker("getDate");
67            var departureDate=jQuery("#check-availability-departure-date").datepicker("getDate");
68            var oneDay = 1000*60*60*24;
69            var difference = Math.ceil((arrivalDate.getTime() - departureDate.getTime()) / oneDay);
70            difference=-difference;
71
72            jQuery("#nights").val(difference);
73            jQuery("#tn").val(difference);
74
75            if(difference >1) {
76                checkAvailability();
77            }
78            },
79            beforeShowDay: noBookedDates
80        })
81    }
82
83    /* payment selector */
84    var paymentTypeSelector = jQuery('#payment-type-selector');
85    paymentTypeSelector.change(function () {
86        if (this.value == 'ach') {
87            jQuery('#payment-cc').hide();
88            jQuery('#payment-ach').show();
89        } else {
90            jQuery('#payment-cc').show();
91            jQuery('#payment-ach').hide();
92            jQuery('#bankRoutingNumber').val('');
93        }
94    });
95});
96
97function pad(n)
98{
99    return n < 10 ? '0' + n : n
100}
101
102function noCheckinOrBookedDates(date) {
103    var m = date.getMonth(), d = date.getDate(), y = date.getFullYear();
104    var today = new Date();
105    var m2 = today.getMonth(), d2 = today.getDate(), y2 = today.getFullYear();
106    var compare1 = y.toString() + pad(m.toString()) + pad(d.toString());
107    var compare2 = y2.toString() + pad(m2.toString()) + pad(d2.toString());
108    // console.log(compare2, compare1);
109
110    for (var k = 0; k < disabledDays.noCheckin.length; k++) {
111        if (jQuery.inArray((m + 1) + '-' + d + '-' + y, disabledDays.noCheckin) != -1 || compare2 > compare1) {
112            //console.log('bad:  ' + (m + 1) + '-' + d + '-' + y + ' / ' + disabledDays[i]);
113            return [false];
114        }
115    }
116
117    return noBookedDates(date);
118}
119
120function noBookedDates(date) {
121    var m = date.getMonth(), d = date.getDate(), y = date.getFullYear();
122    var today = new Date();
123    var m2 = today.getMonth(), d2 = today.getDate(), y2 = today.getFullYear();
124    var compare1 = y.toString() + pad(m.toString()) + pad(d.toString());
125    var compare2 = y2.toString() + pad(m2.toString()) + pad(d2.toString());
126    // console.log('Checking (raw): ' + m + '-' + d + '-' + y);
127    // console.log(compare2, compare1);
128
129    for (var i = 0; i < disabledDays.bookedDates.length; i++) {
130        if (jQuery.inArray((m + 1) + '-' + d + '-' + y, disabledDays.bookedDates) != -1 || compare2 > compare1) {
131            // console.log('bad:  ' + (m + 1) + '-' + d + '-' + y + ' / ' + disabledDays[i]);
132            return [false];
133        }
134    }
135
136    //console.log('good:  ' + (m + 1) + '-' + d + '-' + y);
137    return [true];
138}
139
140function getMinLOS(arrival)
141{
142    for (i in disabledDays.minNights) {
143        var minNight = disabledDays.minNights[i];
144        var start = new Date(minNight.start);
145        var end = new Date(minNight.end);
146
147        if (arrival >= start && arrival <= end) {
148            return minNight.minLOS;
149        }
150    }
151
152    return disabledDays.minLOS;
153}
154
155function checkAvailability() {
156    jQuery("#errormsg").hide();
157    jQuery("#booklink").hide();
158    jQuery("#ratebreakdown").hide();
159    jQuery("#loadingicons").hide();
160    jQuery("#ratebreakdown").empty();
161    //jQuery.get(url_paths.site_url + "/?vrpjax=1&act=checkavailability&par=1", jQuery("#bookingform").serialize(), function (data) {
162    var serializedData = jQuery("#bookingform").serialize();
163    // Ensure v2 flag is present for V2 check availability
164    if (serializedData.indexOf("obj%5Bv2%5D=") === -1 && serializedData.indexOf("obj[v2]=") === -1) {
165        serializedData += (serializedData ? "&" : "") + "obj[v2]=1";
166    }
167
168    jQuery.get(url_paths.site_url + "/?vrpjax=1&act=checkavailability&par=1", seri
168alizedData, function (data) {
169        var obj = jQuery.parseJSON(data);
170
171        if (!obj.Error) {
172            jQuery(".ratebreakdown").css("display", "block");
173            jQuery("#abe-quote-activator").show();
174            jQuery("#alertmsg").hide();
175            jQuery("#thetotal,#booklink").fadeIn();
176            ratebreakdown(obj);
177            jQuery("#checkbutton").fadeTo(500, 0.5);
178            jQuery(".unitsearch").change(function () {
179                //jQuery("#booklink").hide();
180                jQuery("#errormsg").html('').hide();
181                jQuery("#checkbutton").fadeTo(500, 1);
182            });
183            jQuery("#ratebreakdown").show();
184        } else {
185            jQuery("#abe-quote-activator").hide();
186            jQuery("#errormsg").html('')
187            var theerror = '<div class="alert alert-error">' + obj.Error + '</div>';
188            jQuery("#errormsg").html(theerror).show();
189
190        }
191    });
192}
193function showCustomError(error){
194    jQuery("#errormsg").html('');
195    jQuery("#abe-quote-activator").hide();
196    var theerror = '<div class="alert alert-error">' + error + '</div>';
197    jQuery("#errormsg").html(theerror).show();
198}
199function ratebreakdown(obj) {
200jQuery("#ratebreakdown").empty();
201    var tbl = jQuery("#ratebreakdown");
202
203    for (var i in obj.Charges) {
204        if(obj.Charges[i].Amount > 0 && obj.Charges[i].Description == 'Rent') {
205            var row = "<tr><td >" + obj.Charges[i].Description + "</td><td class='rate-breakdown-value'>$" + parseFloat(obj.Charges[i].Amount).toFixed(2) + "</td></tr>";
206            tbl.append(row);
207        }
208    }
209
210    if (obj.BookDetails) {
211        for (i in obj.BookDetails.charges) {
212            var row = "<tr><td >" + obj.BookDetails.charges[i].Description + "</td><td class='rate-breakdown-value'>$" + parseFloat(obj.BookDetails.charges[i].Amount).toFixed(2) + "</td></tr>";
213            tbl.append(row);
214        }
215    }
216
217    if(obj.TotalTax>0) {
218        var tax = "<tr><td>Occupancy Tax</td><td class='rate-breakdown-value'>$" + parseFloat(obj.TotalTax).toFixed(2) + "</td></tr>";
219        tbl.append(tax);
220    }
221
222    var total = '<tr class="double"><td><b>Reservation Total</b></td><td  class="rate-breakdown-value"><b>$' + (parseFloat(obj.TotalCost)).toFixed(2) + '</b></td></tr>';
223    tbl.append(total);
224    var totaldue = "<tr class='success'><td><b>Total Due Now</b></td><td class='rate-breakdown-value'><b>$" + (parseFloat(obj.DueToday)).toFixed(2) + "</b></td></tr>";
225    if(obj.DueToday !== obj.TotalCost) {
226        // No sense in displaying something that says 'Due Now' if it isn't less than the total cost.
227
228        tbl.append(totaldue);
229    }
230
231    if(obj.PromoCodeDiscount) {
232        var promoCodeDiscount = "<tr><td colspan='2'>" + obj.PromoCodeDiscount.text + "</td></tr>" +
233            "<tr><td>Total Savings:</td><td class='rate-breakdown-value'>$" + obj.PromoCodeDiscount.value + "</td></tr>";
234        tbl.append(promoCodeDiscount);
235    }
236
237    if (obj.Arrival) {
238        var day = getDayFromDate(obj.Arrival);
239    } else {
240        var day = getDayFromDate(obj.arrival);
241    }
242
243    if (jQuery('.abe-quote-info').length > 0) {
244        if (obj.Arrival) {
245            var day = getDayFromDate(obj.Arrival);
246        } else {
247            var day = getDayFromDate(obj.arrival);
248        }
249       
250        //var quoteText = `${day} ${obj.Arrival ? obj.Arrival : obj.arrival } <br> <span>$${addCommas(parseFloat(obj.TheRentalRate).toFixed(2))}</span> + <sup>tax/fees</sup>`;
251        var quoteText = `${day} ${obj.Arrival ? obj.Arrival : obj.arrival } <br>Total: <span>$${addCommas(parseFloat(obj.TotalCost).toFixed(2))}</span>`;
252        jQuery('.abe-quote-info').html(quoteText)
253    }
254    
255    //var quoteText = `${day} ${obj.Arrival ? obj.Arrival : obj.arrival } <br> <span>$${addCommas(parseFloat(obj.TheRentalRate).toFixed(2))}</span> + <sup>tax/fees</sup>`;
256    var quoteText = `${day} ${obj.Arrival ? obj.Arrival : obj.arrival } <br>Total: <span>$${addCommas(parseFloat(obj.TotalCost).toFixed(2))}</span>`;
257    jQuery('.ratebreakdown-quote').html(quoteText);
258}
259
260function getDayFromDate(date)
261{
262    var d = new Date(date);
263
264    var weekday = new Array(7);
265    weekday[0] = "Sunday";
266    weekday[1] = "Monday";
267    weekday[2] = "Tuesday";
268    weekday[3] = "Wednesday";
269    weekday[4] = "Thursday";
270    weekday[5] = "Friday";
271    weekday[6] = "Saturday";
272    return weekday[d.getDay()];
273}
274
275function addCommas(nStr) {
276    nStr += '';
277    x = nStr.split('.');
278    x1 = x[0];
279    x2 = x.length > 1 ? '.' + x[1] : '';
280    var rgx = /(\d+)(\d{3})/;
281    while (rgx.test(x1)) {
282            x1 = x1.replace(rgx, '$1' + ',' + '$2');
283    }
284    return x1 + x2;
285}
286
287function getDayFromDate(date)
288{
289    var d = new Date(date);
290
291    var weekday = new Array(7);
292    weekday[0] = "Sunday";
293    weekday[1] = "Monday";
294    weekday[2] = "Tuesday";
295    weekday[3] = "Wednesday";
296    weekday[4] = "Thursday";
297    weekday[5] = "Friday";
298    weekday[6] = "Saturday";
299    addCommas
300    return weekday[d.getDay()];
301}
302
303/**
304 * Google Map
305 */
306
307function initializeGoogleMap() {
308    var geocoder = new google.maps.Geocoder();
309    var map = new google.maps.Map(document.getElementById("map"), {
310        zoom: 13,
311        scrollwheel: false,
312        mapTypeId: google.maps.MapTypeId.ROADMAP,
313        streetViewControl: false,
314        styles: [
315            {
316              "featureType": "poi.business",
317              "stylers": [
318                {
319                  "visibility": "off"
320                }
321              ]
322            },
323            {
324              "featureType": "poi.park",
325              "elementType": "labels.text",
326              "stylers": [
327                {
328                  "visibility": "off"
329                }
330              ]
331            }
332          ]
333    });
334    var unitLatitude = unitDataSource.data("unit-latitude");
335    var unitLongitude = unitDataSource.data("unit-longitude");
336
337    if (unitLatitude && unitLongitude) {
338        console.log('lat long');
339        /**
340         * Latitude & Longitude are present - Use this data for mapping *
341         */
342        var unitMapPinLocation = new google.maps.LatLng(unitLatitude, unitLongitude);
343        map.setCenter(unitMapPinLocation);
344
345        new google.maps.Marker({
346            map: map,
347            position: unitMapPinLocation
348        });
349    } else {
350        console.log('address');
351        /**
352         * No lat/long present - Use address for mapping
353         */
354        var fullUnitAddress = unitDataSource.data("unit-address1")
355//                + " " + unitDataSource.data("unit-address2")
356            + " " + unitDataSource.data("unit-city")
357            + " " + unitDataSource.data("unit-state")
358            + " " + unitDataSource.data("unit-zip");
359        console.log(fullUnitAddress);
360
361        geocoder.geocode({'address': fullUnitAddress}, function (results, status) {
362            if (status == google.maps.GeocoderStatus.OK) {
363                map.setCenter(results[0].geometry.location);
364                new google.maps.Marker({
365                    map: map,
366                    position: results[0].geometry.location
367                });
368            }
369        });
370    }
371}
372
373jQuery(document).ready(function () {
374    // Unit Page Tabs
375    unitTabs = jQuery("#vrp-tabs").tabs();
376
377    //Unit Photo Gallery
378
379
380
381        // jQuery('#vrp-slider').lightSlider({
382        //     gallery:true,
383        //     item:1,
384        //     thumbItem:9,
385        //     slideMargin: 0,
386        //     speed:300,
387        //     loop:true,
388        //     pager:true,
389        //     thumbItem: 9,
390        //     pause: 5000,
391
392        // });
393
394
395
396
397    jQuery("#vrpinquire").submit(function () {
398        jQuery("#iqbtn").attr("disabled", "disabled");
399        jQuery.post(url_paths.site_url + "/?vrpjax=1&act=custompost&par=addinquiry", jQuery(this).serialize(), function (data) {
400            var obj = jQuery.parseJSON(data);
401            if (obj.success) {
402                jQuery("#vrpinquire").replaceWith("Thank you for your inquiry!");
403            } else {
404                var item;
405                var thetotal = obj.err.length - 1;
406                for (i = 0; i <= thetotal; i++) {
407                    item = obj.err[i];
408                    /// alert(item.name);
409                    jQuery("#i" + item.name).append("<span class='errormsg'>" + item.msg + "</span>");
410                }
411                jQuery("#iqbtn").removeAttr("disabled");
412            }
413        });
414        return false;
415    });
416
417    jQuery("#gmaplink").on('click', function () {
418        initializeGoogleMap();
419    });
420
421    jQuery("#icheckinput").datepicker();
422
423
424    jQuery( window ).resize(function() {
425
426            jQuery("#vrp").width() < 950 ? jQuery("#vrp").addClass('vrp-small') : jQuery("#vrp").removeClass('vrp-small');
427
428
429        });
430    jQuery("#vrp").width() < 950 ? jQuery("#vrp").addClass('vrp-small') : jQuery("#vrp").removeClass('vrp-small');
431});

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.