PageSourceSearch

https://pauljohncaffeine.in/wp-content/plugins/kw-elementor-plugin/js/ajax.js

js pauljohncaffeine.in collected 2026-10-04 02:39:52 UTC 6,897 bytes, 208 lines download raw bytes

1jQuery(document).ready(function ($) {
2  $(".load-more-button").on("click", function () {
3    const currentUrl = new URL(window.location.href);
4    // Get the value of the 'search_value' parameter
5    const searchValue = currentUrl.searchParams.get("search_value");
6    const loadMoreWrap = document.querySelector(".load-more-wrap");
7    const maxPage = parseInt(loadMoreWrap.getAttribute("data-max-page"), 10);
8    ajax_var.current_page++;
9    var button = $(this),
10      data = {
11        action: "loadmore",
12        query: ajax_var.query_vars,
13        page: ajax_var.current_page,
14        searchValue: searchValue,
15        maxPage: maxPage,
16      };
17
18    $.ajax({
19      url: ajax_var.url,
20      data: data,
21      type: "POST",
22      beforeSend: function (xhr) {
23        button.text("Loading...");
24      },
25      success: function (data) {
26        if (data) {
27          $(".product_search--main").append(data); // insert new posts
28
29          if (ajax_var.current_page == maxPage) button.remove(); // if last page, remove the button
30
31          button.text("Load More");
32        } else {
33          console.log("no data");
34          button.remove(); // if no data, remove the button as well
35        }
36      },
37    });
38  });
39
40  $(".load-more").on("click", function () {
41    console.log(ajax_var.query_vars);
42    console.log(ajax_var.current_page);
43
44    var orderby = $("#orderby_custom").val(); // Example selector, update based on your sorting dropdown
45    //const currentUrl = new URL(window.location.href);
46    // Get the value of the 'search_value' parameter
47    //const searchValue = currentUrl.searchParams.get('search_value');
48    const loadMoreWrap = document.querySelector(".load-more-wrap");
49    const maxPage = parseInt(loadMoreWrap.getAttribute("data-max-page"), 10);
50    ajax_var.current_page++;
51    console.log(orderby);
52    var button = $(this),
53      data = {
54        action: "load_more_posts",
55        query: ajax_var.query_vars,
56        page: ajax_var.current_page,
57        order_by: orderby,
58      };
59
60    $.ajax({
61      url: ajax_var.url,
62      data: data,
63      type: "POST",
64      beforeSend: function (xhr) {
65        button.text("Loading...");
66      },
67      success: function (data) {
68        if (data) {
69          $(".product__archive--main").append(data); // insert new posts
70
71          if (ajax_var.current_page == maxPage) $(".load-more-wrap").hide();
72          //button.remove(); // if last page, remove the button
73
74          button.text("Load More");
75          initializeSwipers();
76        } else {
77          console.log("no data");
78          //button.remove(); // if no data, remove the button as well
79          $(".load-more-wrap").hide();
80        }
81      },
82    });
83  });
84
85  let swiperThumbnails = [];
86  let swiperFeatured = [];
87
88  function initializeSwipers() {
89    document.querySelectorAll(".swiper").forEach((swiperContainer) => {
90      const isThumbnail =
91        swiperContainer.className.includes("thumbnail_image_");
92      const isFeatured = swiperContainer.className.includes("featured_image_");
93
94      if (isThumbnail) {
95        let swiperThumbs = new Swiper(swiperContainer, {
96          slidesPerView: 6,
97          spaceBetween: 6,
98          freeMode: true,
99          watchSlidesProgress: true,
100        });
101        swiperThumbnails.push(swiperThumbs);
102      } else if (isFeatured) {
103        let swiperFeat = new Swiper(swiperContainer, {
104          spaceBetween: 10,
105          navigation: {
106            nextEl: ".swiper-button-next",
107            prevEl: ".swiper-button-prev",
108          },
109          thumbs: {
110            swiper: swiperThumbnails[swiperThumbnails.length - 1],
111          },
112        });
113        swiperFeatured.push(swiperFeat);
114      }
115    });
116  }
117
118  initializeSwipers();
119
120  $("#orderby_custom").on("change", function () {
121    ajax_var.current_page = 0;
122    var orderby = $("#orderby_custom").val(); // Example selector, update based on your sorting dropdown
123    //const currentUrl = new URL(window.location.href);
124    // Get the value of the 'search_value' parameter
125    //const searchValue = currentUrl.searchParams.get('search_value');
126    const loadMoreWrap = document.querySelector(".load-more-wrap");
127    const maxPage = parseInt(loadMoreWrap.getAttribute("data-max-page"), 10);
128    ajax_var.current_page++;
129    console.log(orderby);
130    console.log(ajax_var.query_vars);
131    var data = {
132      action: "load_more_posts",
133      query: ajax_var.query_vars,
134      page: ajax_var.current_page,
135      order_by: orderby,
136    };
137    $.ajax({
138      url: ajax_var.url,
139      data: data,
140      type: "POST",
141      success: function (data) {
142        if (data) {
143          //$('.product__archive--main').append(data); // insert new posts
144          $(".product__archive--main").html(data);
145          initializeSwipers();
146          if (ajax_var.current_page == maxPage) {
147            $(".load-more-wrap").hide();
148          } else {
149            $(".load-more-wrap").show();
150          }
151          //  button.remove(); // if last page, remove the button
152
153          //button.text('Load More');
154        } else {
155          console.log("no data");
156          $(".load-more-wrap").hide();
157        }
158      },
159    });
160  });
161
162  $(".load-more-blog").on("click", function () {
163    console.log(ajax_var.query_vars);
164    console.log(ajax_var.current_page);
165
166    var catagory = $("#cat").val(); // Example selector, update based on your sorting dropdown
167    //const currentUrl = new URL(window.location.href);
168    // Get the value of the 'search_value' parameter
169    //const searchValue = currentUrl.searchParams.get('search_value');
170    const loadMoreWrap = document.querySelector(".load-more-wrap");
171    const maxPage = parseInt(loadMoreWrap.getAttribute("data-max-page"), 10);
172    ajax_var.current_page++;
173    console.log(catagory);
174    var button = $(this),
175      data = {
176        action: "load_more_blogs",
177        query: ajax_var.query_vars,
178        page: ajax_var.current_page,
179        catagory: catagory,
180      };
181
182    $.ajax({
183      url: ajax_var.url,
184      data: data,
185      type: "POST",
186      beforeSend: function (xhr) {
187        button.text("Loading...");
188      },
189      success: function (response) {
190        if (response) {
191          response = JSON.parse(response);
192          $(".post__archive--main").append(response.data); // insert new posts
193
194          if (ajax_var.current_page == response.maxPage)
195            $(".load-more-wrap").hide();
196          //button.remove(); // if last page, remove the button
197
198          button.text("Load More");
199        } else {
200          console.log("no data");
201          //button.remove(); // if no data, remove the button as well
202          $(".load-more-wrap").hide();
203        }
204      },
205    });
206  });
207
208});

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.