1jQuery(document).ready(function($) { 2 let selectedCategory = "*"; 3 let selectedLocation = "*"; 4 let itemsPerPage = 6; 5 let currentPage = 1; 6 7 function renderCategoryDescription($filterList, $link) { 8 if (!$filterList || !$filterList.length) return; 9 if (!$link || !$link.length) return; 10 11 const title = $link.data("title") || ""; 12 const desc = $link.data("desc") || ""; 13 14 $filterList.find(".cspt-category-description").remove(); 15 16 if (!title && !desc) return; 17 18 const descHtml = textToParagraphs(desc); 19 20 $filterList.append( 21 '<div class="cspt-category-description">' + 22 '<strong class="uppercase">' + escapeHtml(title) + '</strong>' + 23 '<div class="cspt-category-description__content">' + descHtml + '</div>' + 24 '</div>' 25 ); 26 27 $filterList.find(".cspt-category-description").fadeIn(); 28 } 29 30 31 function escapeHtml(str) { 32 return String(str || "") 33 .replace(/&/g, "&") 34 .replace(/</g, "<") 35 .replace(/>/g, ">") 36 .replace(/"/g, """) 37 .replace(/'/g, "'"); 38 } 39 40 // Zamienia tekst z enterami na <p>...</p> 41 // - pusta linia = nowy akapit 42 // - pojedynczy enter wewnÄ trz akapitu = <br> (możesz wyÅÄ czyÄ) 43 function textToParagraphs(text) { 44 const safe = escapeHtml(text || "").replace(/\r\n/g, "\n").replace(/\r/g, "\n"); 45 46 return safe 47 .split(/\n\s*\n+/) // podziaÅ na akapity po pustej linii 48 .map(block => block.trim()) 49 .filter(Boolean) 50 .map(block => `<p>${block.replace(/\n/g, "<br>")}</p>`) 51 .join(""); 52 } 53 54 // --- NOWA: schowaj opis na starcie --- 55 $(".cspt-category-description").hide(); 56 57 // Dodaj przyciski pod każdym selectem 58 $(".cspt-sortable-list-select").each(function() { 59 if ($(this).next(".cspt-filter-buttons").length === 0) { 60 $(this).after( 61 '<div class="cspt-filter-buttons" style="margin-top:10px;">' + 62 '<button class="cspt-show-results" style="display:none;margin-right:5px;">Wyniki filtrowania</button>' + 63 '<button class="cspt-clear-filters" style="display:none;">WyczyÅÄ</button>' + 64 '</div>' 65 ); 66 } 67 }); 68 69 function filterServices() { 70 let visibleItems = []; 71 $(".cspt-service-item").each(function() { 72 let categories = $(this).data("category") ? $(this).data("category").toString().split(" ") : []; 73 let locations = $(this).data("location") ? $(this).data("location").toString().split(" ") : []; 74 75 let categoryMatch = (selectedCategory === "*" || categories.includes(selectedCategory)); 76 let locationMatch = (selectedLocation === "*" || locations.includes(selectedLocation)); 77 78 if (categoryMatch && locationMatch) visibleItems.push(this); 79 $(this).toggle(categoryMatch && locationMatch); 80 }); 81 82 renderPage(visibleItems); 83 $(".cspt-preloader").fadeOut(); 84 } 85 86function renderPage(items) { 87 let totalPages = Math.ceil(items.length / itemsPerPage); 88 if (currentPage > totalPages) currentPage = totalPages; 89 90 $(items).hide(); 91 let start = (currentPage - 1) * itemsPerPage; 92 let end = start + itemsPerPage; 93 $(items.slice(start, end)).show(); 94 95 $(".cspt-pagination").remove(); 96 if (totalPages <= 1) return; 97 98 let pagination = '<div id="page_navigation" class="cspt-pagination">'; 99 100 // ð¹ Poprzednia 101 if (currentPage > 1) { 102 pagination += '<a href="#" id="ssf_previous_link" class="cspt-prev-page previous_link arrow-toggler-left pagination-btn paginationgrey" data-page="' + (currentPage - 1) + '"></a> '; 103 } 104 105 // ð¹ JeÅli stron jest maÅo â pokaż wszystkie numery 106 if (totalPages <= 6) { 107 for (let i = 1; i <= totalPages; i++) { 108 if (i === currentPage) { 109 pagination += '<span class="cspt-page-number current page_link active_page" data-page="' + i + '">' + i + '</span>'; 110 } else { 111 pagination += '<a href="#" class="cspt-page-number page_link" data-page="' + i + '">' + i + '</a>'; 112 } 113 } 114 } else { 115 // ð¹ Zawsze pokaż stronÄ 1 116 if (currentPage === 1) { 117 pagination += '<span class="cspt-page-number current page_link active_page" data-page="1">1</span>'; 118 } else { 119 pagination += '<a href="#" class="cspt-page-number page_link" data-page="1">1</a>'; 120 } 121 122 // ð¹ Oblicz zakres stron wokóŠbieÅ¼Ä cej 123 let startPage = Math.max(2, currentPage - 1); 124 let endPage = Math.min(totalPages - 1, currentPage + 1); 125 126 // JeÅli startPage > 2 dodaj elipsÄ 127 if (startPage > 2) pagination += '<span class="ellipsis">â¦</span>'; 128 129 for (let i = startPage; i <= endPage; i++) { 130 if (i === currentPage) { 131 pagination += '<span class="cspt-page-number current page_link active_page" data-page="' + i + '">' + i + '</span>'; 132 } else { 133 pagination += '<a href="#" class="cspt-page-number page_link" data-page="' + i + '">' + i + '</a>'; 134 } 135 } 136 137 // JeÅli endPage < totalPages -1 dodaj elipsÄ 138 if (endPage < totalPages - 1) pagination += '<span class="ellipsis">â¦</span>'; 139 140 // ð¹ Ostatnia strona 141 if (currentPage === totalPages) { 142 pagination += '<span class="cspt-page-number current page_link active_page" data-page="' + totalPages + '">' + totalPages + '</span>'; 143 } else { 144 pagination += '<a href="#" class="cspt-page-number page_link" data-page="' + totalPages + '">' + totalPages + '</a>'; 145 } 146 } 147 148 // ð¹ NastÄpna 149 if (currentPage < totalPages) { 150 pagination += ' <a href="#" id="ssf_next_link" class="cspt-next-page next_link arrow-toggler-right pagination-btn ssf-button" data-page="' + (currentPage + 1) + '"></a>'; 151 } 152 153 pagination += '</div>'; 154 $(".cspt-services-list").after(pagination); 155} 156 157 158 // ObsÅuga klikniÄcia Prev/Next 159 $(document).on("click", ".cspt-prev-page, .cspt-next-page", function(e) { 160 e.preventDefault(); 161 currentPage = parseInt($(this).data("page")); 162 filterServices(); 163 });
164 165 // ObsÅuga klikniÄÄ w numery stron 166 $(document).on("click", ".cspt-page-number", function(e) { 167 e.preventDefault(); 168 currentPage = parseInt($(this).data("page")); 169 filterServices(); 170 }); 171 172 173$(document).on("click", ".cspt-sortable-link", function(e) { 174 e.preventDefault(); 175 176 const $this = $(this); 177 const $filterList = $this.closest(".cspt-sortable-list"); 178 const $currentLi = $this.closest("li"); 179 const isAlreadySelected = $this.hasClass("cspt-selected"); 180 181 // JeÅli klikniÄto aktywny element -> wyÅÄ cz filtr kategorii 182 if (isAlreadySelected) { 183 $this.removeClass("cspt-selected"); 184 $currentLi.removeClass("cspt-selected"); 185 186 selectedCategory = "*"; 187 currentPage = 1; 188 filterServices(); 189 190 $filterList.find(".cspt-category-description").fadeOut(200, function() { 191 $(this).remove(); 192 }); 193 194 return; 195 } 196 197 // UsuÅ zaznaczenia tylko w tej liÅcie 198 $filterList.find(".cspt-sortable-link").removeClass("cspt-selected"); 199 $filterList.find("li").removeClass("cspt-selected"); 200 201 // Dodaj zaznaczenie 202 $this.addClass("cspt-selected"); 203 $currentLi.addClass("cspt-selected"); 204 205 // Filtruj 206 selectedCategory = $this.data("sortby"); 207 currentPage = 1; 208 filterServices(); 209 210 // Opis kategorii 211 renderCategoryDescription($filterList, $this); 212 213 // Pokaż przyciski 214 $(".cspt-sortable-list-select").each(function() { 215 $(this).next(".cspt-filter-buttons") 216 .find(".cspt-show-results, .cspt-clear-filters") 217 .fadeIn(); 218 }); 219}); 220 221 // Zmiana lokalizacji 222 // Zmiana lokalizacji (NIE resetuj opisu technologii) 223$(document).on("change", ".cspt-sortable-select", function() { 224 selectedLocation = $(this).val(); 225 currentPage = 1; 226 filterServices(); 227 228 // Szukaj aktywnej kategorii w gÅównej liÅcie kategorii (technologie / materiaÅy) 229 // Preferuj listÄ, która NIE jest selectem lokalizacji 230 let $filterList = $(".cspt-sortable-list").first(); 231 232 // jeÅli masz konkretnÄ listÄ kategorii (np. technologia), możesz zawÄziÄ: 233 // let $filterList = $(".cspt-sortable-list").not(".materialy-budowlane").first(); 234 235 let $activeLink = $filterList.find(".cspt-sortable-link.cspt-selected").first(); 236 237 // fallback -> "Wszystkie" w tej samej liÅcie 238 if (!$activeLink.length) { 239 $activeLink = $filterList.find(".cspt-sortable-link[data-sortby='*']").first(); 240 } 241 242 // OdÅwież opis wg aktywnej kategorii 243 renderCategoryDescription($filterList, $activeLink); 244 245 // Pokaż przyciski 246 $(".cspt-sortable-list-select").each(function() { 247 $(this).next(".cspt-filter-buttons") 248 .find(".cspt-show-results, .cspt-clear-filters") 249 .fadeIn(); 250 }); 251}); 252 253 // Klik w przycisk "Zobacz wyniki" 254 $(document).on("click", ".cspt-show-results", function() { 255 $('html, body').animate({ 256 scrollTop: $(".cspt-services-list").offset().top - 120 257 }, 600); 258 }); 259 260 $(document).on("click", ".cspt-pagination a", function() { 261 $('html, body').animate({ 262 scrollTop: $(".cspt-services-list").offset().top - 120 263 }, 600); 264 }); 265 266 // Klik w przycisk "WyczyÅÄ" 267 $(document).on("click", ".cspt-clear-filters", function() { 268 selectedCategory = "*"; 269 selectedLocation = "*"; 270 currentPage = 1; 271 272 $(".cspt-sortable-link").removeClass("cspt-selected"); 273 $(".cspt-sortable-link[data-sortby='*']").addClass("cspt-selected"); 274 $(".cspt-sortable-select").val("*"); 275 $(".cspt-category-description").hide(); // reset opisu 276 277 $(".cspt-show-results, .cspt-clear-filters").fadeOut(); 278 279 filterServices(); 280 }); 281 282 // Klik w paginacjÄ 283 $(document).on("click", ".cspt-page-link", function(e) { 284 e.preventDefault(); 285 currentPage = parseInt($(this).data("page")); 286 filterServices(); 287 }); 288 289 // Start â pokaż preloader 290 $(".cspt-preloader").show(); 291 filterServices(); 292 293 294// Klik w logotyp -> pokaż tylko ten service 295$(document).on("click", ".cspt-service-logo-item", function() { 296 let serviceId = $(this).data("service-id"); 297 298 $(".cspt-service-item").hide(); 299 $(".cspt-service-item[data-id='" + serviceId + "']").show(); 300 $(".cspt-pagination, #page_navigation").hide(); 301 302 $('html, body').animate({ 303 scrollTop: $(".cspt-services-list").offset().top - 120 304 }, 600); 305}); 306 307 308// Scroll do wybranego linku w sekcji "materiaÅy budowlane" â tylko na mobile 309$(document).on("click", ".materialy-budowlane.cspt-sortable-list .cspt-sortable-link", function() { 310 311 // Scroll tylko jeÅli szerokoÅÄ okna ⤠767 px 312 if (window.innerWidth > 767) return; 313 314 setTimeout(function() { 315 const $selected = $(".materialy-budowlane.cspt-sortable-list .cspt-sortable-link.cspt-selected"); 316 317 if ($selected.length) { 318 const rect = $selected[0].getBoundingClientRect(); 319 const scrollTop = window.pageYOffset || document.documentElement.scrollTop; 320 const targetY = rect.top + scrollTop - 40; // korekta na sticky header 321 322 $("html, body").stop(true).animate( 323 { scrollTop: targetY }, 324 700, 325 "swing" 326 ); 327 } 328 }, 1000); // lekka pauza 329}); 330 331 332});
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.