PageSourceSearch

https://rentals.escapetomarco.com/rns/_content/RNSBookingTemplate.SharedUI/js/utils/range-datepicker-utils.js

js escapetomarco.com collected 2026-10-04 08:18:37 UTC 2,913 bytes, 98 lines download raw bytes

1const DATE_RANGE_AVAILABILITY_WARNING_CLASS = 'rns-dateRange-availability-warning';
2const DEFAULT_AVAILABILITY_WARNING = 'Availability could not be loaded. Dates shown may not reflect current bookings.';
3
4/**
5 * Resolve the date-range wrapper inside an optional page scope.
6 * @param {string} [scopeSelector] - Parent selector (e.g. '#checkoutApp', '.owner-checkout')
7 */
8export function getDateRangeWrapper(scopeSelector = '') {
9    if (scopeSelector) {
10        const scope = document.querySelector(scopeSelector);
11        return scope?.querySelector('.rns-dateRange') ?? null;
12    }
13
14    return document.querySelector('.rns-dateRange');
15}
16
17/**
18 * Toggle inline loading state on the scoped date-range picker.
19 */
20export function setDateRangeLoading(scopeSelector = '', isLoading = false) {
21    const wrapper = getDateRangeWrapper(scopeSelector);
22    if (!wrapper) {
23        return;
24    }
25
26    wrapper.classList.toggle('sidebar-calendar-loading', isLoading);
27}
28
29/**
30 * Show or hide degraded-mode availability warning below the date-range picker.
31 */
32export function setDateRangeAvailabilityWarning(
33    scopeSelector = '',
34    show = false,
35    message = DEFAULT_AVAILABILITY_WARNING
36) {
37    const wrapper = getDateRangeWrapper(scopeSelector);
38    if (!wrapper) {
39        return;
40    }
41
42    const host = wrapper.parentElement;
43    if (!host) {
44        return;
45    }
46
47    let notice = host.querySelector(`:scope > .${DATE_RANGE_AVAILABILITY_WARNING_CLASS}`);
48    if (!notice) {
49        notice = host.querySelector(`.${DATE_RANGE_AVAILABILITY_WARNING_CLASS}`);
50    }
51
52    if (show) {
53        if (!notice) {
54            notice = document.createElement('p');
55            notice.className = DATE_RANGE_AVAILABILITY_WARNING_CLASS;
56            notice.setAttribute('role', 'status');
57            wrapper.insertAdjacentElement('afterend', notice);
58        }
59
60        notice.textContent = message;
61        notice.hidden = false;
62        return;
63    }
64
65    if (notice) {
66        notice.hidden = true;
67    }
68}
69
70/**
71 * Fetch property calendar reservations with response validation.
72 */
73export async function fetchPropertyCalendarReservations(propertyId, baseApiUrl, options = {}) {
74    const {
75        headers = {
76            LegacyUse: 'true',
77            GuestCal: 'true'
78        }
79    } = options;
80
81    if (!propertyId || !baseApiUrl) {
82        throw new Error('Missing property ID or API base URL for calendar fetch');
83    }
84
85    const url = `${baseApiUrl}website/calendar/${propertyId}`;
86    const response = await fetch(url, { headers });
87
88    if (!response.ok) {
89        throw new Error(`Calendar request failed (${response.status})`);
90    }
91
92    const result = await response.json();
93    if (!Array.isArray(result)) {
94        throw new Error('Calendar response was not a reservation array');
95    }
96
97    return result;
98}

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.