PageSourceSearch

https://qualitim.pl/wp-content/themes/awa-child-theme/js/index.js?ver=1.0

js qualitim.pl collected 2026-10-08 10:19:11 UTC 6,038 bytes, 193 lines download raw bytes

1let city_select, top_part, search, date_from, date_to;
2let selected_city = null,
3  selected_city_id = null;
4let four_column, three_column, two_column, event_grid;
5
6function init_city_select() {
7  top_part.addEventListener("click", () => {
8    city_select.classList.toggle("expanded");
9  });
10
11  city_select.querySelectorAll(".single-city").forEach((v) => {
12    v.onclick = () => {
13      city_select.classList.remove("expanded");
14      selected_city = v.querySelector(".city-name").textContent;
15      selected_city_id = v.getAttribute("data-id");
16      top_part.querySelector("span").innerText = selected_city;
17      // update_grid();
18      update_grid_offline();
19    };
20  });
21}
22
23function init_fitlering() {
24  city_select = document.querySelector("#city-select");
25  top_part = city_select.querySelector(".tickets-filter-top");
26  search = document.querySelector('input[name="search"]');
27  date_from = document.querySelector('input[name="date-from"]');
28  date_to = document.querySelector('input[name="date-to"]');
29
30  //     search.addEventListener("change", () => update_grid());
31  //     search.addEventListener("input", () => update_grid());
32  search.addEventListener("input", () => update_grid_offline());
33  date_from.addEventListener("change", () => update_grid());
34  date_to.addEventListener("change", () => update_grid());
35
36  // four_column = document.querySelector(".four-grid");
37  // three_column = document.querySelector(".three-grid");
38  // two_column = document.querySelector(".two-grid");
39
40  // four_column.addEventListener("click", (e) => update_grid_type(4));
41  // three_column.addEventListener("click", (e) => update_grid_type(3));
42  // two_column.addEventListener("click", (e) => update_grid_type(2));
43
44  event_grid = document.querySelector(".event-grid");
45}
46
47async function update_grid() {
48  const search_value = search.value.toLowerCase();
49  const date_from_value = date_from.value.toLowerCase();
50  const date_to_value = date_to.value.toLowerCase();
51  const city_value = selected_city_id;
52
53  const data = {};
54
55  if (search_value != "") data["q"] = search_value;
56  if (date_from_value != "") data["date_from"] = date_from_value;
57  if (date_to_value != "") data["date_to"] = date_to_value;
58  if (city_value != null) data["city_id"] = city_value;
59
60  const response = await fetch(
61    "https://qualitim.pl/wp-content/themes/awa-child-theme/api/get_events_js.php",
62    {
63      method: "POST",
64      body: JSON.stringify(data),
65    }
66  );
67
68  const output = await response.json();
69
70  filter_grid(output.result.events);
71}
72
73function filter_grid(output) {
74  const unfiltered_elements = document.querySelectorAll(
75    ".event-single-container"
76  );
77
78  const event_ids = output.map((v) => v.event_id);
79
80  unfiltered_elements.forEach((v) => {
81    const event_id = v.getAttribute("event-id");
82
83    if (event_ids.indexOf(event_id) == -1) {
84      v.classList.add("single-hidden");
85    }
86    //
87    else {
88      v.classList.remove("single-hidden");
89    }
90  });
91
92  if (event_ids.length == 0) {
93    document.querySelector(".event-empty").classList.remove("event-hidden");
94  }
95  //
96  else {
97    document.querySelector(".event-empty").classList.add("event-hidden");
98  }
99}
100function update_grid_type(size) {
101  event_grid.style.gridTemplateColumns = `repeat(${size}, 1fr)`;
102
103  if (size == 2) {
104    event_grid.classList.add("two-c-grid");
105    event_grid.classList.remove("three-c-grid");
106    event_grid.classList.remove("four-c-grid");
107  }
108  if (size == 3) {
109    event_grid.classList.add("three-c-grid");
110    event_grid.classList.remove("four-c-grid");
111    event_grid.classList.remove("two-c-grid");
112  }
113  if (size == 4) {
114    event_grid.classList.add("four-c-grid");
115    event_grid.classList.remove("three-c-grid");
116    event_grid.classList.remove("two-c-grid");
117  }
118
119  if (size == 2) {
120    four_column.classList.remove("grid-selected");
121    three_column.classList.remove("grid-selected");
122    two_column.classList.add("grid-selected");
123  }
124  if (size == 3) {
125    four_column.classList.remove("grid-selected");
126    three_column.classList.add("grid-selected");
127    two_column.classList.remove("grid-selected");
128  }
129  if (size == 4) {
130    four_column.classList.add("grid-selected");
131    three_column.classList.remove("grid-selected");
132    two_column.classList.remove("grid-selected");
133  }
134}
135
136function update_grid_offline() {
137  const search_value = search.value.toLowerCase();
138  const date_from_value = date_from.value.toLowerCase();
139  const date_to_value = date_to.value.toLowerCase();
140  const city_value = selected_city_id;
141
142  const data = {};
143
144  if (search_value != "") data["q"] = search_value;
145  if (date_from_value != "") data["date_from"] = date_from_value;
146  if (date_to_value != "") data["date_to"] = date_to_value;
147  if (city_value != null && city_value != -1) data["city_id"] = city_value;
148
149  const unfiltered_elements = document.querySelectorAll(
150    ".event-single-container"
151  );
152
153  unfiltered_elements.forEach((v) => {
154    let pass = true;
155    if (data.q) {
156      if (
157        !v
158          .querySelector(".event-title")
159          .textContent.toLowerCase()
160          .includes(data.q) &&
161        !v
162          .querySelector(".event-detail-city")
163          .textContent.toLowerCase()
164          .includes(data.q)
165      ) {
166        v.classList.add("single-hidden");
167        return;
168      }
169    }
170    if (data.city_id) {
171      if (v.getAttribute("city-id") != data.city_id) {
172        v.classList.add("single-hidden");
173        return;
174      }
175    }
176
177    v.classList.remove("single-hidden");
178  });
179}
180function buyNow(id) {
181  window.location = "/ticket/?evt_id=" + id;
182  //     const script = document.querySelector(".iframe_container > script");
183  //     if (script) script.remove();
184
185  //     const newScript = document.createElement("script");
186  //     newScript.src = `https://biletyna.pl/javascript?ifid=266&action_url=event/view/id/${id}`;
187
188  //     document.querySelector(".iframe_container").appendChild(newScript);
189  //     document.querySelector(".tickets-container").style.display = "none";
190}
191
192init_fitlering();
193init_city_select();

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.