PageSourceSearch

https://happytravels.com.au/wp-content/themes/bonvoyage-child/js/custom-roaver.js?ver=1791300062

js happytravels.com.au collected 2026-10-06 19:59:26 UTC 5,386 bytes, 173 lines download raw bytes

1jQuery(document).ready(function ($) {
2  function removeScrollBars() {
3    $(".ht-wrapper .svc .search-modal .modal__content").removeClass("scroll-y scroll-bars");
4  }
5
6  function applyLocationFromChanges() {
7    $(".input.select.input-from")
8      .find("span.ico")
9      .addClass("icon icon-location")
10      .text("");
11  }
12
13  function applyLocationToChanges() {
14    $(".input.select.input-to")
15      .addClass("with-icon")
16      .append('<span class="ico icon icon-location"></span>');
17  }
18
19  function applyDateChanges() {
20    $(".date-input-container span.ico")
21      .addClass("icon icon-calendar-alt")
22      .text("");
23  }
24
25  function applyDriverAgeChanges() {
26    $(
27      'select[name="Parameters.DriverAge"], select[data-name="Parameters.DriverAge"]'
28    ).each(function () {
29      var $parent = $(this).parent(".input.select");
30      $parent.addClass("driver-age");
31      $parent.find("span.ico").addClass("icon icon-user").text("");
32    });
33  }
34
35  function applyNumberOfPeopleChanges() {
36    $(
37      'select[name="Parameters.NumberOfPeople"], select[data-name="Parameters.NumberOfPeople"]'
38    ).each(function () {
39      var $parent = $(this).parent(".input.select");
40      $parent.addClass("number-of-people");
41      $parent.find("span.ico").addClass("icon icon-persons").text("");
42    });
43  }
44
45  function applyDriverCountryChanges() {
46    $(
47      'select[name="Parameters.DriverCountryId"], select[data-name="Parameters.DriverCountryId"]'
48    ).each(function () {
49      var $parent = $(this).parent(".input.select");
50      $parent.addClass("driver-country");
51      $parent.find("label:first").text("Driver's license Issuing country");
52      $parent.find("span.ico").addClass("icon icon-vcard").text("");
53    });
54  }
55
56  setTimeout(function () {
57    $(".input-from")
58      .find('input[type="select-one"]')
59      .attr("placeholder", "Pick up location");
60
61    $(".input-from")
62      .next()
63      .find("label:first")
64      .text("Select drop off location");
65
66    $(".input-from").next().find('div[data-value="0"]').text("Same as pick up");
67
68    $(".date-range")
69      .find(".flx.clm.flx-between:eq(0)")
70      .find("label:first")
71      .text("Select pick up date");
72
73    $(".date-range")
74      .find(".flx.clm.flx-between:eq(1)")
75      .find("label:first")
76      .text("Select drop off date");
77
78    applyLocationFromChanges();
79    applyLocationToChanges();
80    applyDateChanges();
81    applyDriverAgeChanges();
82    applyNumberOfPeopleChanges();
83    applyDriverCountryChanges();
84  }, 1000);
85
86  $(document).on("click", ".search__button-modal", function () {
87    removeScrollBars();
88    applyLocationFromChanges();
89    applyLocationToChanges();
90    applyDateChanges();
91    applyDriverAgeChanges();
92    applyNumberOfPeopleChanges();
93    applyDriverCountryChanges();
94  });
95});
96
97document.addEventListener("DOMContentLoaded", () => {
98  const executeScript = () => {
99    const stages = document.querySelectorAll(
100      ".page-template-campervans-booking .svc .book-progress .stage.stage__present"
101    );
102    stages.forEach((stage) => {
103      if (stage.querySelector("span")) {
104        return;
105      }
106      const span = document.createElement("span");
107      span.textContent = stage.innerHTML;
108      stage.innerHTML = "";
109      stage.appendChild(span);
110    });
111
112    // Check for .book-payment__root and add class to .book-progress if found
113    const bookPaymentRoot = document.querySelector(".book-payment__root");
114    if (bookPaymentRoot) {
115      const bookProgress = document.querySelector(
116        ".page-template-campervans-booking .svc .book-progress"
117      );
118      if (bookProgress) {
119        bookProgress.classList.add("book-process-payment");
120      }
121    }
122
123    // Check for .customer-info__root and add title if found
124    const customerInfoRoot = document.querySelector(".book-options__root .customer-info__root");
125    if (customerInfoRoot) {
126      const customerInfoTitleWrapper = document.createElement("div");
127      customerInfoTitleWrapper.classList.add("customer-info__title-wrapper");
128      customerInfoTitleWrapper.innerHTML = `
129          <h2>Confirm Booking</h2>
130          <p>To confirm your booking we need a few more details</p>
131        `;
132      customerInfoRoot.insertBefore(customerInfoTitleWrapper, customerInfoRoot.firstChild);
133    }
134
135    // Add .search-form class to .quote-request__root
136    const quoteRequestRoot = document.querySelector(".quote-request__root");
137    if (quoteRequestRoot) {
138      quoteRequestRoot.classList.add("search-form");
139    }
140  };
141
142  // Initial execution
143  setTimeout(() => {
144    executeScript();
145  }, 1000);
146
147  // Function to get the value of __p from the query string
148  const getQueryParam = (param) => {
149    const urlParams = new URLSearchParams(window.location.search);
150    return urlParams.get(param);
151  };
152
153  let previousPValue = getQueryParam("__p");
154
155  // Periodically check for changes in the __p value
156  setInterval(() => {
157    const currentPValue = getQueryParam("__p");
158    if (currentPValue !== previousPValue) {
159      previousPValue = currentPValue;
160      executeScript();
161    }
162  }, 1000); // Check every second
163
164  // Optional: also listen for the popstate event to handle back/forward navigation
165  window.addEventListener("popstate", () => {
166    const currentPValue = getQueryParam("__p");
167    if (currentPValue !== previousPValue) {
168      previousPValue = currentPValue;
169      executeScript();
170    }
171  });
172  
173});

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.