PageSourceSearch

https://hr-on.com/wp-content/plugins/HRON-Prices/public/js/prices-public-n-n.js?ver=1.4.1

js hr-on.com collected 2026-10-02 03:08:25 UTC 9,775 bytes, 297 lines download raw bytes

1function debounce(func, timeout = 500) {
2  let timer;
3  return (...args) => {
4    clearTimeout(timer);
5    timer = setTimeout(() => {
6      func.apply(this, args);
7    }, timeout);
8  };
9}
10function initializeSignUp($) {
11  const initialSystem = document
12    .querySelector(".sign-up-container")
13    .getAttribute("data-initial-system");
14
15  let currentSystem = initialSystem;
16
17  const button = document.querySelector(`.nav-button`);
18  const backButton = document.querySelector(
19    ".sign-up-container .navigation .prev-button"
20  );
21  const formBackButton = document.querySelector(
22    ".sign-up-container .contact-form .back-button"
23  );
24   const valuta = document
25    .querySelector(".suite .price")
26    .getAttribute("data-valuta");
27
28  if (!$("#currency-field").val()) {
29    $("#currency-field").val(valuta);
30  }
31
32  const handleNavigation = (e, goBack) => {
33    e.preventDefault();
34
35    if (currentSystem === initialSystem) {
36      const otherSystem = currentSystem === "recruit" ? "staff" : "recruit";
37      const buttonLabel = button.getAttribute("data-continue-label");
38      button.innerHTML = buttonLabel;
39
40      backButton.classList.remove("hidden");
41      document
42        .querySelector(`.sign-up-container .${currentSystem}`)
43        .classList.add("hidden");
44      document
45        .querySelector(`.sign-up-container .${otherSystem}`)
46        .classList.remove("hidden");
47      $('input[type="range"]').rangeslider("update", true);
48      const currentActive = document.querySelector(`.pagination .active`);
49      currentActive.nextElementSibling.classList.add("active");
50      currentActive.nextElementSibling.classList.remove("future-step");
51      currentActive.classList.add("previous-step");
52      currentActive.classList.remove("active");
53
54      return (currentSystem = otherSystem);
55    }
56
57    if (goBack) {
58      const buttonLabel = button.getAttribute("data-initial-label");
59      button.innerHTML = buttonLabel;
60
61      backButton.classList.add("hidden");
62      document
63        .querySelector(`.sign-up-container .${currentSystem}`)
64        .classList.add("hidden");
65      document
66        .querySelector(`.sign-up-container .${initialSystem}`)
67        .classList.remove("hidden");
68      $('input[type="range"]').rangeslider("update", true);
69      const currentActive = document.querySelector(`.pagination .active`);
70      currentActive.previousElementSibling.classList.add("active");
71      currentActive.previousElementSibling.classList.remove("previous-step");
72      currentActive.classList.add("future-step");
73      currentActive.classList.remove("active");
74      return (currentSystem = initialSystem);
75    }
76
77   const jobslotsValue = document.querySelector(".recruit input").value;
78    const employeesValue = document.querySelector(".staff input").value;
79    const jobslotsField = document.querySelector("input[name='jobslots']");
80    const employeesField = document.querySelector("input[name='employees']");
81    const getSelectedSystem = () => {
82      if (employeesValue > 0 && jobslotsValue > 0) {
83        return "suite";
84      }
85      if (employeesValue > 0) {
86        return "staff";
87      }
88      return "recruit";
89    };
90    document.querySelector("#selectedSystem").value = getSelectedSystem();
91
92    jobslotsField.value = jobslotsValue;
93    employeesField.value = employeesValue;
94
95
96    document
97      .querySelector(`.sign-up-container .${currentSystem}`)
98      .classList.add("hidden");
99    document.querySelector(`.initial-navigation`).classList.add("hidden");
100    document.querySelector(`.contact-form`).classList.remove("hidden");
101
102    
103
104    if (formBackButton.getAttribute("listener") !== "true") {
105      formBackButton.addEventListener("click", (e) => {
106        e.preventDefault();
107        document
108          .querySelector(`.sign-up-container .${currentSystem}`)
109          .classList.remove("hidden");
110        document
111          .querySelector(`.initial-navigation`)
112          .classList.remove("hidden");
113        document.querySelector(`.contact-form`).classList.add("hidden");
114      });
115    }
116  };
117
118  button.addEventListener("click", handleNavigation);
119  backButton.addEventListener("click", (e) => handleNavigation(e, true));
120
121  // checkbox event listeners
122  const recruitCheckbox = document.querySelector("#omit-recruit");
123  const staffCheckbox = document.querySelector("#omit-staff");
124
125  const handleCheckboxChange = (e, system) => {
126    const slider = $(`.${system} input[type='range']`);
127    const sectionToDisable = document.querySelector(`.${system} .inputs`);
128
129    const input = document.querySelector(`.${system} input[type='number']`);
130    if (e.target.checked) {
131      sectionToDisable.classList.add("disabled-section");
132      slider.attr({ min: 0, max: 0 });
133      slider.val(0).change();
134      input.setAttribute("min", 0);
135      input.value = 0;
136      slider.rangeslider("update", true);
137      sectionToDisable.querySelector("input").value = 0;
138    } else {
139      input.setAttribute("min", 1);
140      input.value = system === "staff" ? 500 : 1;
141      slider.attr({ min: 1, max: system === "staff" ? 2000 : 150 });
142      slider.val(1).change();
143      slider.rangeslider("update", true);
144
145      sectionToDisable.classList.remove("disabled-section");
146    }
147  };
148
149  recruitCheckbox?.addEventListener("change", (e) => {
150    handleCheckboxChange(e, "recruit");
151  });
152  staffCheckbox?.addEventListener("change", (e) => {
153    handleCheckboxChange(e, "staff");
154  });
155
156  const systems = ["recruit", "staff"];
157  //slider sections
158  systems.forEach((system) => {
159    const limit = system === "recruit" ? 149 : 1999;
160    const slider = $(`.${system} input[type='range']`);
161    const input = document.querySelector(`.${system} input[type='number']`);
162    const plusSpan = document.querySelector(`.${system} .plus-span`);
163    const plusSpanVisible = !plusSpan.classList.contains("hidden");
164
165    slider.rangeslider({
166      polyfill: false,
167      rangeClass: "rangeslider",
168      disabledClass: "rangeslider-disabled",
169      horizontalClass: "rangeslider-horizontal",
170      verticalClass: "rangeslider-vertical",
171      fillClass: "rangeslider-fill-lower",
172      handleClass: "rangeslider-thumb",
173      onInit: function () {
174        const container = document.querySelector(`.inner-container`);
175        container.style.opacity = 1;
176        container.style.transform += "translateY(0)";
177
178        const input = document.querySelector(`.${system}  .wrapper`);
179        const position =
180          document.querySelector(`.rangeslider-thumb`).style.left;
181        const positionAsNumber = position.replace("px", "");
182        input.style.left = `${positionAsNumber}px`;
183      },
184      onSlide: function (position, value) {
185        const input = document.querySelector(`.${system}  .wrapper`);
186
187        if (value > limit) {
188          plusSpan.classList.remove("hidden");
189        }
190        if (value < limit && !plusSpanVisible) {
191          plusSpan.classList.add("hidden");
192        }
193        input.querySelector("input").value = value;
194
195        input.style.left = `${position}px`;
196      },
197    });
198
199    input.addEventListener(
200      "input",
201      debounce((e) => {
202        if (e.target.value > 1999) {
203          plusSpan.classList.remove("hidden");
204        }
205        if (e.target.value < 1999 && !plusSpanVisible) {
206          plusSpan.classList.add("hidden");
207        }
208
209        slider.val(e.target.value).change();
210      })
211    );
212  });
213  // form is submitted
214  const wpcf7Elm = document.querySelector(".wpcf7");
215  document
216    .querySelector(".navigation .wpcf7-submit")
217    .addEventListener("click", (event) => {
218    
219      const contactForm = document.querySelector(".contact-form");
220      const loader = document.createElement("div");
221      loader.classList.add("loader-inverted");
222      const overlay = document.createElement("div");
223      overlay.classList.add("overlay");
224      overlay.appendChild(loader);
225      contactForm.appendChild(overlay);
226    });
227
228  const failEvents = ["wpcf7invalid", "wpcf7spam", "wpcf7mailfailed"];
229  failEvents.forEach((event) => {
230    wpcf7Elm.addEventListener(
231      event,
232      function (event) {
233        setTimeout(() => {
234          const overlay = document.querySelector(".overlay");
235          if (overlay) {
236            overlay.remove();
237          }
238        }, 0);
239      },
240      false
241    );
242  });
243
244  wpcf7Elm.addEventListener(
245    "wpcf7mailsent",
246    function (event) {
247      const fields = {
248        jobslots: event.detail.inputs.find((input) => input.name === "jobslots")
249          .value,
250        employees: event.detail.inputs.find(
251          (input) => input.name === "employees"
252        ).value,
253        currency: event.detail.inputs.find((input) => input.name === "currency")
254          .value,
255      };
256
257      var ajax_url = plugin_ajax_object.ajax_url;
258
259      var data = {
260        action: "getPricePage",
261        ...fields,
262      };
263
264      $.ajax({
265        url: ajax_url,
266        type: "post",
267        data: data,
268        dataType: "html",
269        success: function (response) {
270          // create modal html
271          // remove old dimmer
272          const oldDimmer = document.querySelector(".dimmer");
273          document.querySelector(".contact-form .overlay").remove();
274          if (oldDimmer) {
275            document.querySelector("#grve-content").style.zIndex = 100;
276            oldDimmer.remove();
277          }
278
279          const modal = document.createElement("div");
280          modal.classList.add("dimmer");
281          modal.innerHTML = response.replace("null", " ");
282          document.querySelector("body").appendChild(modal);
283          console.log({ response });
284          initPricePage();
285          initSidebar($);
286        },
287      });
288    },
289    false
290  );
291}
292
293jQuery(document).ready(function ($) {
294  if (document.querySelector(".sign-up-container")) {
295    initializeSignUp($);
296  }
297});

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.