PageSourceSearch

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

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

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.