PageSourceSearch

https://wegwandern.ch/wp-content/themes/WEGW/js/filter.js?ver=1.0.0

js wegwandern.ch collected 2026-09-24 20:42:21 UTC 66,026 bytes, 1,607 lines download raw bytes

1if (typeof $ === 'undefined') {
2  var $ = jQuery;
3}
4var filterOtherPage, filteredData;
5var triggerFilterResult = false;
6jQuery(document).ready(function () {
7
8  /**check if the page has filter button(not tourenportal) */
9  if ($('.filter-btn.region-filter').length > 0) {
10    filterOtherPage = 'region';
11
12    regionCheckbox()
13    themaCheckbox();
14    routenverlaufCheckbox();
15    angebotCheckbox();
16    ausdauerCheckbox();
17    aktivitatCheckbox();
18    saisonCheckbox();
19    anforderungCheckbox();
20
21    /* Show count in the filter during initial load in region block */
22   // wegw_map_filter_results('hover', filterOtherPage);
23   // FilterList('hover', filterOtherPage);
24
25  } else {
26    filterOtherPage = '';
27  }
28
29  /*Show count in the filter during initial load
30  wegw_map_filter_results('hover', filterOtherPage); */
31  jQuery(".filterMenu .filter_content_wrapper .fc_block_select label input[type=checkbox]").on('change', function () {
32    jQuery(this).parent().toggleClass('active');
33
34  });
35  /*show only count in filter when checkbox is selected*/
36  jQuery('.filterMenu .filter_content_wrapper input[type=checkbox]').on('change', function () {
37   // wegw_map_filter_results('hover', filterOtherPage);
38    FilterList('hover', filterOtherPage);
39    
40  });
41
42  // /*keyup event on search field*/
43  // jQuery(".search input").on("keyup", function (e) {
44  //   /* show/hide close icon in search in menu sidebar  */
45  //   if (jQuery('.navigation_search input').val().length != 0) {
46  //     jQuery('.navigation_search_close').removeClass("hide");
47  //   } else {
48  //     jQuery('.navigation_search_close').addClass("hide");
49  //   }
50  //   /* show/hide close icon in search in header  */
51  //   if (jQuery('.head_navigation_search input').val().length != 0) {
52  //     jQuery('.head_navigation_search_close').removeClass("hide");
53  //   } else {
54  //     jQuery('.head_navigation_search_close').addClass("hide");
55  //   }
56  //   /* show/hide close icon in search in responsive cluster map(tourenportal)  */
57  //   if (jQuery('#map-resp .map_main_search input').val().length != 0) {
58  //     jQuery('#map-resp .map_main_search_close').removeClass("hide");
59  //   } else {
60  //     jQuery('#map-resp .map_main_search_close').addClass("hide");
61  //   }
62  //   /* show/hide close icon in search in desktop cluster map(tourenportal)  */
63  //   if (jQuery('#map_desktop .map_main_search input').val().length != 0) {
64  //     jQuery('#map_desktop .map_main_search_close').removeClass("hide");
65  //   } else {
66  //     jQuery('#map_desktop .map_main_search_close').addClass("hide");
67  //   }
68  // });
69
70  // if (jQuery('.searchinputField input').length > 0) {
71  //   /* show/hide close icon in search in search results page  */
72  //   if (jQuery('.searchinputField input').val().length != 0) {
73  //     jQuery('.searchResult_search_close').removeClass("hide");
74  //   } else {
75  //     jQuery('.searchResult_search_close').addClass("hide");
76  //   }
77  // }
78  
79
80  // jQuery(".searchinputField input").on("keyup", function (e) {
81  //   /* show/hide close icon in search in search results page  */
82  //   if (jQuery('.searchinputField input').val().length != 0) {
83  //     jQuery('.searchResult_search_close').removeClass("hide");
84  //   } else {
85  //     jQuery('.searchResult_search_close').addClass("hide");
86  //   }
87  // });
88
89  /*double side slider in the filter sidebar*/
90  jQuery(".slider.multi-slide").each(function (i, data) {
91    // $this is a reference to .slider in current iteration of each
92    var $this = jQuery(this);
93    // find any .slider-range element WITHIN scope of $this
94    jQuery(".slider-range", $this).slider({
95      range: true,
96      min: parseInt($this.attr('data-first')),
97      max: parseInt($this.attr('data-second')),
98      values: [parseInt($this.attr('data-first')), parseInt($this.attr('data-second'))],
99      /** change the first and last value while sliding the slider */
100      slide: function (event, ui) {
101        // find any element with class .amount WITHIN scope of $this
102        if ($this.attr('data-notation') === 'h') {
103          /**check if two digit no or not for first value*/
104          if (ui.values[0] <= 9) {
105            jQuery(".firstVal", $this).val("0" + ui.values[0] + ':00 ' + $this.attr('data-notation'));
106          } else {
107            jQuery(".firstVal", $this).val(ui.values[0] + ':00 ' + $this.attr('data-notation'));
108          }
109          /**check if two digit no or not for second value*/
110          if (ui.values[1] <= 9) {
111            jQuery(".secondVal", $this).val('> 0' + ui.values[1] + ':00 ' + $this.attr('data-notation'));
112          } else {
113            jQuery(".secondVal", $this).val('> ' + ui.values[1] + ':00 ' + $this.attr('data-notation'));
114          }
115
116          jQuery($this).attr("data-first", ui.values[0]);
117          jQuery($this).attr("data-second", ui.values[1]);
118       //   wegw_map_filter_results('hover', filterOtherPage);
119        } else {
120          jQuery(".firstVal", $this).val(ui.values[0] + " " + $this.attr('data-notation'));
121          jQuery(".secondVal", $this).val(ui.values[1] + " " + $this.attr('data-notation'));
122          jQuery($this).attr("data-first", ui.values[0]);
123          jQuery($this).attr("data-second", ui.values[1]);
124        //  wegw_map_filter_results('hover', filterOtherPage);
125        }
126
127        if (ui.handle === jQuery(".ui-slider-handle:first", $this)[0]){ // Left handle is being moved
128          if (ui.values[0] >= ui.values[1]) {
129            jQuery(".ui-slider-handle:first", $this).eq(0).addClass("startHandleEnd");
130            jQuery(".ui-slider-handle:first", $this).eq(0).removeClass("startHandle");
131          }else{
132            jQuery(".ui-slider-handle:first", $this).eq(0).removeClass("startHandleEnd");
133            jQuery(".ui-slider-handle:first", $this).eq(0).removeClass("startHandle");
134          }
135        }else if (ui.handle === jQuery(".ui-slider-handle:last", $this)[0]){// Right handle is being moved
136          if (ui.values[1] <= ui.values[0]) {
137            jQuery(".ui-slider-handle:last", $this).eq(0).addClass("endHandle");
138          }else{
139            jQuery(".ui-slider-handle:last", $this).eq(0).removeClass("endHandle");
140          }
141        }
142
143      },
144      stop: function (event, ui) {
145       // wegw_map_filter_results('hover', filterOtherPage);
146        FilterList('hover', filterOtherPage);
147      }
148    });
149    /** change the first and last value based on the slider */
150    if ($this.attr('data-notation') === 'h') {
151      /**check if two digit no or not for first value*/
152      if ($this.attr('data-first') <= 9) {
153        jQuery(".firstVal", $this).val("0" + $this.attr('data-first') + ':00 ' + $this.attr('data-notation'));
154      } else {
155        jQuery(".firstVal", $this).val($this.attr('data-first') + ':00 ' + $this.attr('data-notation'));
156      }
157      /**check if two digit no or not for second value*/
158      if ($this.attr('data-second') <= 9) {
159        jQuery(".secondVal", $this).val('> 0' + $this.attr('data-second') + ':00 ' + $this.attr('data-notation'));
160      } else {
161        jQuery(".secondVal", $this).val('> ' + $this.attr('data-second') + ':00 ' + $this.attr('data-notation'));
162      }
163    } else {
164      jQuery(".firstVal", $this).val($this.attr('data-first') + " " + $this.attr('data-notation'));
165      jQuery(".secondVal", $this).val($this.attr('data-second') + " " + $this.attr('data-notation'));
166    }
167  });
168
169  //loadmore button
170  var loadmore = jQuery(".LoadMore");
171  if (jQuery(".single-wander-wrappe").length) {
172    var wanderung_filter_query = jQuery("#wanderung_filter_query").val();
173  }
174  // loadmore for hikngs
175  jQuery(document).on("click", "#wanderung-loadmore", function () {
176    var itemcount = jQuery(".single-wander").length;
177    var loc = jQuery(".header_menu .search_head").val();
178    var sort = '';
179    /** get the sort value large/short */
180    if (window.innerWidth < 1200) {
181      /** sort div for responsive */
182      if (jQuery(".ListHead.mob .sort-largest").prop('checked') == true) {
183        var sort = 'large';
184      }
185      if (jQuery(".ListHead.mob .sort-shortest").prop('checked') == true) {
186        var sort = 'short';
187      }
188    } else {
189      /**sort div for desktop */
190      if (jQuery(".ListHead .sort-largest").prop('checked') == true) {
191        var sort = 'large';
192      }
193      if (jQuery(".ListHead .sort-shortest").prop('checked') == true) {
194        var sort = 'short';
195      }
196    }
197
198    
199
200    jQuery('#loader-icon').removeClass("hide");
201    /**loadmore in tourenportal page and region hike page  */
202    if (jQuery(".single-wander-wrappe-json").length || jQuery(".regi
202on-single-wander-wrappe").length) {
203     // var data = generate_data_array(null);
204      var mapDragEvent = $('#wanderung-loadmore').data("event");
205      var listDiv;
206
207      /* Update on 11/07/2023 for intial sort drag map issue */
208      // if (mapDragEvent == 'regionenMap') {
209      if (filterOtherPage === 'region') {
210        listDiv = $('.region-single-wander-wrappe');
211        //  data['action'] = "wanderung_regionen_map_load_more";
212        //   data['regionen_id'] = $('#regionen_id').val();
213      //  data['action'] = "wanderung_drag_map_hikes_load_more";
214     //   data['map_page'] = "region";
215      } else {
216        listDiv = $('.single-wander-wrappe');
217      //  data['action'] = "wanderung_drag_map_hikes_load_more";
218        // data['filtered_map_ids'] = $('#mapDragFilterHikeId').val();
219      }
220
221      // data['filtered_map_ids'] = $('#mapDragFilterHikeId').val();
222      // data['nonce'] = ajax_object.ajax_nonce;
223      // data['sort'] = sort;
224      // data['count'] = itemcount;
225      // var data = data;
226
227      // jQuery.ajax({
228      //   url: ajax_object.ajax_url,
229      //   type: "post",
230      //   data: data,
231      //   beforeSend: function () {
232      //     loadmore.addClass("active");
233      //   },
234      //   complete: function () {
235      //     loadmore.removeClass("active");
236      //   },
237      //   success: function (response) {
238      //     var posts = JSON.parse(response);
239      //     var countp = jQuery(posts[0]).filter(".single-wander").length;
240      //     console.log(countp);
241      //     if (posts == "" || countp < 1) {
242      //       console.log("empty");
243      //       jQuery(".LoadMore").hide();
244      //     }
245      //     jQuery('#loader-icon').addClass("hide");
246
247      //     if (countp > 0) {
248      //       console.log(posts[0]);
249      //       listDiv.append(posts[0]);
250      //       /**to remove empty hike info*/
251      //       toRemoveEmptyHikeInfo();
252      //       jQuery(".noWanderung").remove();
253      //     } else {
254
255      //       if (jQuery(".noWanderung").length < 1) {
256      //         jQuery("#wanderung-loadmore").before(posts);
257      //       }
258      //     }
259      //   },
260      //   error: function () {
261      //     jQuery('#loader-icon').addClass("hide");
262      //   },
263      // });
264      loadmoreData();
265      var posts = filteredData;
266      var countp = currentIndex;
267      console.log(countp);
268      if (posts == "" || countp < 1) {
269        console.log("empty");
270        jQuery(".LoadMore").hide();
271      }
272      jQuery('#loader-icon').addClass("hide");
273
274      if (countp > 0) {
275        console.log(posts[0]);
276       // listDiv.append(posts[0]);
277        listModifiedData(filteredData,currentIndex );
278        /**to remove empty hike info*/
279        toRemoveEmptyHikeInfo();
280        jQuery(".noWanderung").remove();
281      } else {
282
283        if (jQuery(".noWanderung").length < 1) {
284          jQuery("#wanderung-loadmore").before('<h2 class="noWanderung">Keine Wanderungen gefunden</h2>');
285        }
286      }
287      jQuery('#loader-icon').addClass("hide");
288    }
289
290  });
291
292  // cookie set for checking checkbox
293  jQuery(document).on("change", " .sort_dropdown label input[type=checkbox]", function () {
294
295    var sort_type = jQuery(this).prop("name");
296    var sort = '';
297
298    if (jQuery(this).prop('checked') == true) {
299
300      if (sort_type == 'sort_large') {
301        var sort = "large";
302        //check if its region page or tourenportal page
303        if (filterOtherPage === 'region') {
304          if (window.innerWidth < 900) {
305            if (jQuery(".ListHead.mob .sort-shortest").prop('checked') == true) {
306              jQuery(".ListHead.mob .sort-shortest").prop('checked', false);
307
308            }
309          } else {
310            if (jQuery(".ListHead .sort-shortest").prop('checked') == true) {
311              jQuery(".ListHead .sort-shortest").prop('checked', false);
312
313            }
314          }
315        } else {
316          if (window.innerWidth < 1200) {
317            if (jQuery(".ListHead.mob .sort-shortest").prop('checked') == true) {
318              jQuery(".ListHead.mob .sort-shortest").prop('checked', false);
319
320            }
321          } else {
322            if (jQuery(".ListHead .sort-shortest").prop('checked') == true) {
323              jQuery(".ListHead .sort-shortest").prop('checked', false);
324
325            }
326          }
327        }
328
329      } else if (sort_type == 'sort_short') {
330        var sort = "short";
331        //check if its region page or tourenportal page
332        if (filterOtherPage === 'region') {
333          if (window.innerWidth < 900) {
334            if (jQuery(".ListHead.mob .sort-largest").prop('checked') == true) {
335              jQuery(".ListHead.mob .sort-largest").prop('checked', false);
336            }
337          } else {
338            if (jQuery(".ListHead .sort-largest").prop('checked') == true) {
339              jQuery(".ListHead .sort-largest").prop('checked', false);
340            }
341          }
342        } else {
343          if (window.innerWidth < 1200) {
344            if (jQuery(".ListHead.mob .sort-largest").prop('checked') == true) {
345              jQuery(".ListHead.mob .sort-largest").prop('checked', false);
346            }
347          } else {
348            if (jQuery(".ListHead .sort-largest").prop('checked') == true) {
349              jQuery(".ListHead .sort-largest").prop('checked', false);
350            }
351          }
352        }
353
354      }
355    } else if (jQuery(this).prop('checked') == false) {
356
357    }
358   // var data = generate_data_array(null);
359
360   // var mapDragEvent = $('#wanderung-loadmore').data("event");
361
362    /* Check page type */
363    // if (filterOtherPage === 'region') {
364    //   data['map_page'] = "region";
365    // } else {
366    //   data['map_page'] = "";
367    // }
368
369   // data['filtered_map_ids'] = $('#mapDragFilterHikeId').val();
370
371    // if (mapDragEvent == 'dragMap') {
372    // data['action'] = "wanderung_drag_map_hikes_sort_query";
373    // } else {
374    //   data['action'] = "get_wanderung_sort_query";
375    // }
376    // data['nonce'] = ajax_object.ajax_nonce;
377    // data['sort'] = sort;
378
379    // jQuery.ajax({
380    //   url: ajax_object.ajax_url,
381    //   type: "post",
382    //   data: data,
383    //   beforeSend: function () {
384    //     loadmore.show();
385    //     jQuery("#wegw-preloader").css("display", "block");
386    //   },
387    //   success: function (response) {
388    //     var posts = JSON.parse(response);
389    //     var countp = jQuery(posts[0]).filter(".single-wander").length;
390    //     console.log(countp);
391    //     if (posts == "" || countp < 1) {
392    //       console.log("empty");
393    //       jQuery(".LoadMore").hide();
394    //     }
395    //     if (countp > 0) {
396    //       if (filterOtherPage === 'region') {
397    //         jQuery(".region-single-wander-wrappe").html(posts);
398    //       } else {
399    //         jQuery(".single-wander-wrappe").html(posts);
400    //       }
401
402    //     }
403    //     /**to remove empty hike info*/
404    //     toRemoveEmptyHikeInfo();
405    //     jQuery("#wegw-preloader").css("display", "none");
406    //   },
407    //   error: function () { },
408    // });
409    sortJsonData(sort,filteredData);
410     /**to remove empty hike info*/
411  toRemoveEmptyHikeInfo();
412
413  });
414
415  // // header search
416  // jQuery('.header_menu .search_head').keyup(function (e) {
417  //   if (e.key === 'Enter' || e.keyCode === 13) {
418
419  //     /* Remove `dragMap` from load more btn */
420  //     $('#wanderung-loadmore').attr("data-event", "");
421
422  //     var data = generate_data_array(null);
423
424  //     data['action'] = "get_wanderung_sort_query";
425  //     data['nonce'] = ajax_object.ajax_nonce;
426  //     jQuery.ajax({
427  //       url: ajax_object.ajax_url,
428  //       type: "post",
429  //       data: data,
430  //       beforeSend: function () {
431  //         loadmore.show();
432  //         jQuery("#wegw-preloader").css("display", "block");
433  //       },
434  //       success: function (response) {
435  //         var posts = JSON.parse(response);
436  //         var countp = jQuery(posts[0]).filter(".single-wander").length;
437  //         console.log(countp);
438  //         if (posts == "" || countp < 1) {
439  //           jQuery(".LoadMore").hide();
440  //         }
441  //         if (countp > 0) {
442  //           if (filterOtherPage === 'region') {
443  //             jQuery(".region-single-wander-wrappe").html(posts);
444  //           } else {
445  //             jQuery(".single-wander-wrappe").html(posts);
446  //           }
447
448  //           jQuery(".noWanderung").remove();
449  //         } else {
450  //           if (filterOtherPage === 'region') {
451  //             jQuery(".region-single-wander-wrappe").html('');
452  //           } else {
453  //             jQuery(".single-wander-wrappe").html('');
454  //           }
455
456  //           if (jQuery(".noWanderung").length < 1) {
457  //             jQuery("#wanderung-loadmore").before('<h2 class="noWanderung">' + posts[1] + '</h2>');
458  //           }
459  //         }
460  //         jQuery("#wegw-preloader").css("display", "none");
461  //         jQuery('#searchbox_main_filter').val(jQuery('.header_menu .search_head').val());
462  //       },
463  //       error: function () { },
464  //     });
465  //     // wegw_map_filter_results('hover', e);
466  //    // wegw_map_filter_results('btnClick', e, filterOtherPage);
467  //     FilterList('btnClick', e, filterOtherPage);
468  //   }
469  // });
470  /*
471  * Filter hike results via main sidebar in tourenportal page
472  */
473  jQuery('#wegw_map_filter_btn').on("click", function (e) {
474    /* Remove `dragMap` from load more btn */
475    // if(triggerFilterResult){
476    //   triggerFilterResult = false;
477    //   return;
478    // }
479    $('#wanderung-loadmore').attr("data-event", "");
480    $('#mapDragFilterHikeId').remove();
481    // if (filterOtherPage === 'region') {
482    //   //Filter hike results via main sidebar in region page
483    // //  wegw_map_filter_results('btnClick', e, filterOtherPage);
484    //   FilterList('btnClick', e, filterOtherPage);
485    // } else {
486    //   //Filter hike results via main sidebar in tourenportal page
487    //  // wegw_map_filter_results('btnClick', e);
488    //   FilterList('btnClick', e);
489    // }
490
491    jQuery("#wegw-preloader").css("display", "block");
492    jQuery('.filterMenu').addClass('filterWindow');
493  });
494
495
496  // jQuery('.filter_reset').on("click", function (e) {
497  //   /* Remove `dragMap` from load more btn */
498  //     $('#wanderung-loadmore').attr("data-event", "");
499  //     $('#mapDragFilterHikeId').remove();
500  //     reset_filter('btnClick', e);
501  // });
502
503  // /* clear the menu serach when clicked on close icon  */
504  // jQuery('.navigation_search .navigation_search_close').on("click", function (e) {
505  //   jQuery(".navigation_search input").val("");
506  //   jQuery('.navigation_search_close').addClass("hide");
507  // });
508  // /* clear the serach on responsive map when clicked on close icon  */
509  // jQuery('#map-resp .map_main_search  .map_main_search_close').on("click", function (e) {
510  //   jQuery("#map-resp .map_main_search  input").val("");
511  //   jQuery('#map-resp .map_main_search_close').addClass("hide");
512  // });
513  // /* clear the serach on desktop map when clicked on close icon  */
514  // jQuery('#map_desktop .map_main_search  .map_main_search_close').on("click", function (e) {
515  //   jQuery("#map_desktop .map_main_search  input").val("");
516  //   jQuery('#map_desktop .map_main_search_close').addClass("hide");
517  // });
518  // /* clear the serach in header when clicked on close icon  */
519  // jQuery('.head_navigation_search .head_navigation_search_close').on("click", function (e) {
520  //   jQuery(".head_navigation_search input").val("");
521  //   jQuery('.head_navigation_search_close').addClass("hide");
522  // });
523  // /* clear the serach in search results page  when clicked on close icon  */
524  // jQuery('.searchinputField .searchResult_search_close').on("click", function (e) {
525  //   jQuery(".searchinputField input").val("");
526  //   jQuery('.searchResult_search_close').addClass("hide");
527  // });
528
529});
530
531// /** header search clear  */
532// function clearSearch() {
533//   jQuery(".header_menu .search.search input").val("");
534//   jQuery('.header_menu .filter_search_close').addClass("hide");
535//   jQuery('#searchbox_main_filter').val("");
536//   //  document.cookie = 'wegw_loc' +'=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';
537//   location.reload();
538// }
539
540/* Function to reset multi sliders value */
541function resetSlider() {
542
543  jQuery(".slider.multi-slide").each(function (i, data) {
544    // $this is a reference to .slider in current iteration of each
545    var $this = jQuery(this);
546    // find any .slider-range element WITHIN scope of $this
547    jQuery(".slider-range", $this).slider({
548      range: true,
549      min: parseInt($this.attr('data-initial')),
550      max: parseInt($this.attr('data-final')),
551      values: [parseInt($this.attr('data-initial')), parseInt($this.attr('data-final'))],
552    });
553    if ($this.attr('data-notation') === 'h') {
554      if ($this.attr('data-first') <= 9) {
555        jQuery(".firstVal", $this).val("0" + $this.attr('data-initial') + ':00 ' + $this.attr('data-notation'));
556        jQuery($this).attr("data-first", $this.attr('data-initial'));
557      } else {
558        jQuery(".firstVal", $this).val($this.attr('data-initial') + ':00 ' + $this.attr('data-notation'));
559        jQuery($this).attr("data-first", $this.attr('data-initial'));
560      }
561      if ($this.attr('data-second') <= 9) {
562        jQuery(".secondVal", $this).val('> 0' + $this.attr('data-final') + ':00 ' + $this.attr('data-notation'));
563        jQuery($this).attr("data-second", $this.attr('data-final'));
564      } else {
565        jQuery(".secondVal", $this).val('> ' + $this.attr('data-final') + ':00 ' + $this.attr('data-notation'));
566        jQuery($this).attr("data-second", $this.attr('data-final'));
567      }
568
569    } else {
570      jQuery(".firstVal", $this).val($this.attr('data-initial') + " " + $this.attr('data-notation'));
571      jQuery(".secondVal", $this).val($this.attr('data-final') + " " + $this.attr('data-notation'));
572      jQuery($this).attr("data-first", $this.attr('data-initial'));
573      jQuery($this).attr("data-second", $this.attr('data-final'));
574    }
575
576  });
577
578}
579function regionCheckbox() {
580  // var checkboxes = document.querySelectorAll(".wanderregionen_search");
581
582  // // Find and check the checkbox with the value "21"
583  // checkboxes.forEach(function (checkbox) {
584  //   if (parseInt(checkbox.value) === $('.filter-btn.region-filter').data('val')) {
585  //     checkbox.checked = true;
586  //   }
587  // });
588
589
590  // Get all checkboxes with the specified class name (wanderregionen_search)
591  var checkboxesRegion = document.querySelectorAll(".wanderregionen_search");
592
593  // Get the data-region value from the hidden input element
594  var selectedRegion = $('#regionen_id').data('region');
595  if (selectedRegion) {
596    // Convert the selectedThema value to an array if it's a comma-separated string
597    var selectedRegionArray = selectedRegion.toString().split(',').map(Number);
598
599    // Loop through the checkboxes and check those with values in selectedThemaArray
600    checkboxesRegion.forEach(function (checkbox) {
601      var checkboxValue = parseInt(checkbox.value);
602      if (selectedRegionArray.includes(checkboxValue)) {
603        checkbox.checked = true;
604      }
605    });
606  }
607}
608function themaCheckbox() {
609  // Get all checkboxes with the specified class name (thema_search)
610  var checkboxesThema = document.querySelectorAll(".thema_search");
611
612  // Get the data-thema value from the hidden input element
613  var selectedThema = $('#regionen_id').data('thema');
614  if (selectedThema) {
615    // Convert the selectedThema value to an array if it's a comma-separated string
616    var selectedThemaArray = selectedThema.toString().split(',').map(Number);
617
618    // Loop through the checkboxes and check those with values in selectedThemaArray
619    checkboxesThema.forEach(function (checkbox) {
620      var checkboxValue = parseInt(checkbox.value);
621      if (selectedThemaArray.includes(checkboxValue)) {
622        checkbox.checked = true;
623      }
624    });
625  }
626}
627
628function routenverlaufCheckbox() {
629
630  // Get all checkboxes with the specified class name(routenverlauf_search)
631  var checkboxesRoutenverlauf = document.querySelectorAll(".routenverlauf_search");
632  var selectedRoutenverlauf = $('#regionen_id').data('routenverlauf');
633  if (selectedRoutenverlauf) {
634    var selectedRoutenverlaufArray = selectedRoutenverlauf.toString().split(',').map(Number);
635
636    // Find and check the checkbox with the data-routenverlauf value
637    checkboxesRoutenverlauf.forEach(function (checkbox) {
638      var checkboxValue = parseInt(checkbox.value);
639      if (selectedRoutenverlaufArray.includes(checkboxValue)) {
640        checkbox.checked = true;
641      }
642    });
643  }
644}
645
646function angebotCheckbox() {
647  // Get all checkboxes with the specified class name(angebote_search)
648  var checkboxesAngebot = document.querySelectorAll(".angebote_search");
649  var selectedAngebot = $('#regionen_id').data('angebot');
650  if (selectedAngebot) {
651    var selectedAngebotArray = selectedAngebot.toString().split(',').map(Number);
652
653    // Find and check the checkbox with the data-angebot value
654    checkboxesAngebot.forEach(function (checkbox) {
655      var checkboxValue = parseInt(checkbox.value);
656      if (selectedAngebotArray.includes(checkboxValue)) {
657        checkbox.checked = true;
658      }
659    });
660  }
661}
662
663function ausdauerCheckbox() {
664  // Get all checkboxes with the specified class name(ausdauer_search)
665  var checkboxesAusdauer = document.querySelectorAll(".ausdauer_search");
666  var selectedAusdauer = $('#regionen_id').data('ausdauer');
667  if (selectedAusdauer) {
668    var selectedAusdauerArray = selectedAusdauer.toString().split(',').map(Number);
669
670    // Find and check the checkbox with the data-angebot value
671    checkboxesAusdauer.forEach(function (checkbox) {
672      var checkboxValue = parseInt(checkbox.value);
673      if (selectedAusdauerArray.includes(checkboxValue)) {
674        checkbox.checked = true;
675      }
676    });
677  }
678}
679function aktivitatCheckbox() {
680  // Get all checkboxes with the specified class name(activity_search)
681  var checkboxesAktivitat = document.querySelectorAll(".activity_search");
682  var selectedAktivitat = $('#regionen_id').data('aktivitat');
683  if (selectedAktivitat) {
684    var selectedAktivitatArray = selectedAktivitat.toString().split(',').map(Number);
685
686    // Find and check the checkbox with the data-angebot value
687    checkboxesAktivitat.forEach(function (checkbox) {
688      var checkboxValue = parseInt(checkbox.value);
689      if (selectedAktivitatArray.includes(checkboxValue)) {
690        checkbox.checked = true;
691        if (checkbox.value === '20') {
692          if (jQuery(".activity_type_1").prop('checked') === true) {
693            jQuery(".activity_type_2").prop('checked', false);
694            jQuery(".activity_type_3").prop('checked', false);
695            jQuery(".fc_difficult_wt_block").removeClass('hide');
696            jQuery(".fc_difficult_t_block").addClass('hide');
697            jQuery('.fc_heading.fc_diff_level').removeClass('fc_devel_default');
698            jQuery('.fc_heading.fc_diff_level .fc_block_select_wrapper .fc_difficult_t_block.fc_block_select label').removeClass('active');
699          } else {
700            clearActivityCheck();
701
702          }
703
704        } else if (checkbox.value === '18') {
705          if (jQuery(".activity_type_2").prop('checked') === true) {
706            jQuery(".activity_type_1").prop('checked', false);
707            jQuery(".activity_type_3").prop('checked', false);
708            jQuery(".fc_difficult_t_block").removeClass('hide');
709            jQuery(".fc_difficult_wt_block").addClass('hide');
710            jQuery('.fc_heading.fc_diff_level').removeClass('fc_devel_default');
711            jQuery('.fc_heading.fc_diff_level .fc_block_select_wrapper .fc_difficult_wt_block.fc_block_select label').removeClass('active');
712          } else {
713            clearActivityCheck();
714
715          }
716
717        } else if (checkbox.value === '19') {
718
719          jQuery(".activity_type_1").prop('checked', false);
720          jQuery(".activity_type_2").prop('checked', false);
721          jQuery(".fc_difficult_wt_block").removeClass('hide');
722          jQuery(".fc_difficult_t_block").removeClass('hide');
723          jQuery('.fc_heading.fc_diff_level').addClass('fc_devel_default');
724          jQuery('.fc_heading.fc_diff_level .fc_block_select_wrapper .fc_block_select label').removeClass('active');
725        }
726      }
727    });
728  }
729}
730
731function saisonCheckbox() {
732  // Get all checkboxes with the specified class name(wander_saison_search)
733  var checkboxesSaison = document.querySelectorAll(".wander_saison_search");
734  var selectedSaison = $('#regionen_id').data('saison');
735  if (selectedSaison) {
736    var selectedSaisonArray = selectedSaison.toString().split(',').map(Number);
737
738    // Find and check the checkbox with the data-angebot value
739    checkboxesSaison.forEach(function (checkbox) {
740      var checkboxValue = parseInt(checkbox.value);
741      if (selectedSaisonArray.includes(checkboxValue)) {
742        checkbox.checked = true;
743        checkbox.parentElement.classList.toggle('active');
744      }
745    });
746  }
747}
748
749function anforderungCheckbox() {
750  // Get all checkboxes with the specified class name(difficulty_search)
751  var checkboxesAnforderung = document.querySelectorAll(".difficulty_search");
752  var selectedAnforderung = $('#regionen_id').data('anforderung');
753  if (selectedAnforderung) {
754    var selectedAnforderungArray = selectedAnforderung.toString().split(',').map(Number);
755
756    // Find and check the checkbox with the data-angebot value
757    checkboxesAnforderung.forEach(function (checkbox) {
758      var checkboxValue = parseInt(checkbox.value);
759      if (selectedAnforderungArray.includes(checkboxValue)) {
760        checkbox.checked = true;
761        checkbox.parentElement.classList.toggle('active');
762      }
763    });
764  }
765}
766
767// //loadmore for blog
768
769// jQuery(document).on("click", "#blog-loadmore", function () {
770//   var itemcount = jQuery(".blog-wander").length;
771//   var loadmore  = jQuery(".LoadMore");
772//   var listDiv   = jQuery('.blog_list');
773//   var page_type = jQuery(".page_type").val();
774//   jQuery('#loader-icon').removeClass("hide");
775//   var data = {
776//     'action' : 'wanderung_blogs_load_more',
777//     'nonce': ajax_object.ajax_nonce,
778//     'count'  : itemcount,
779//     'page_type' : page_type,
780//   };
781
782//   jQuery.ajax({
783//     url: ajax_object.ajax_url,
784//     type: "post",
785//     data: data,
786//     beforeSend: function () {
787//       loadmore.addClass("active");
788//     },
789//     complete: function () {
790//       loadmore.removeClass("active");
791//     },
792//     success: function (response) {
793//       var posts = JSON.parse(response);
794//       var countp = jQuery(posts[0]).filter(".blog-wander").length;
795//       console.log(countp);
796//       if (posts == "" || countp < 1) {
797//         console.log("empty");
798//         jQuery(".LoadMore").hide();
799//       }
800//       jQuery('#loader-icon').addClass("hide");
801
802//       if (countp > 0) {
803//         console.log(posts[0]);
804//         listDiv.append(posts[0]);
805//         jQuery(".noWanderung").remove();
806//       } else {
807
808//         if (jQuery(".noWanderung").length < 1) {
809//           jQuery("#blog-loadmore").before(posts);
810//         }
811//       }
812//     },
813//     error: function () {
814//       jQuery('#loader-icon').addClass("hide");
815//     },
816//   });
817
818// });
819
820// //loadmore for Search page
821// jQuery(document).on("click", "#search-loadmore", function () {
822  
823//   var loadmore  = jQuery(".LoadMore");
824 
825//   var itemcounts = jQuery(this).data("count");
826//   var search_query =  jQuery(this).data("query");
827//   var search_offset =  jQuery(this).data("offset");
828//   var post_type = jQuery(this).attr("data-postType");
829//   let next_offset = parseInt(search_offset) + 9 ; 
830//   jQuery(this).data("offset", next_offset);
831  
832//   var search_nonce =  jQuery(this).data("nonce");
833
834
835//   if( itemcounts < next_offset ){
836//     jQuery('#search-loadmore').hide();
837//     jQuery('.noWanderungSearchPost').show();
838//   }
839
840
841//   jQuery('#loader-icon').removeClass("hide");
842//   var data = {
843//     'action' : 'wanderung_search_load_more',
844//     'count'  : itemcounts,
845//     'search_query' : search_query,
846//     'offset' : search_offset,
847//     'search_nonce' : search_nonce,
848//     'post_type' : post_type
849  
850//   };
851
852//   jQuery.ajax({
853//     url: ajax_object.ajax_url,
854//     type: "post",
855//     data: data,
856//     beforeSend: function () {
857//       loadmore.addClass("active");
858//     },
859//     complete: function () {
860//       loadmore.removeClass("active");
861//     },
862//     success: function (response) {
863//       jQuery('.searchResult_list').append(response.data);
864// 		jQuery('#loader-icon').addClass("hide");
865//     },
866//     error: function () {
867//       jQuery('#loader-icon').addClass("hide");
868//     },
869//   });
870
871// });
872
873// //loadmore for taxonomies
874// jQuery(document).on("click", "#taxonomy-loadmore", function () {
875  
876//   var loadmore  = jQuery(".LoadMore");
877 
878//   var itemcounts = jQuery(this).data("count");
879//   var search_offset =  jQuery(this).data("offset");
880//   var post_type = jQuery(this).attr("data-postType");
881//   var taxonomy = jQuery(this).attr("data-taxonomy");
882//   var term_id = jQuery(this).attr("data-termId");
883//   let next_offset = parseInt(search_offset) + 9 ; 
884//   jQuery(this).data("offset", next_offset);
885  
886//   var taxonomy_nonce =  jQuery(this).data("nonce");
887
888
889//   if( itemcounts < next_offset ){
890//     jQuery('#taxonomy-loadmore').hide();
891//     jQuery('.noWanderungSearchPost').show();
892//   }
893
894
895//   jQuery('#loader-icon').removeClass("hide");
896//   var data = {
897//     'action' : 'wanderung_taxonomy_load_more',
898//     'count'  : itemcounts,
899//     'offset' : search_offset,
900//     'taxonomy_nonce' : taxonomy_nonce,
901//     'post_type' : post_type,
902//     'taxonomy' : taxonomy,
903//     'term_id' : term_id
904//   };
905
906//   jQuery.ajax({
907//     url: ajax_object.ajax_url,
908//     type: "post",
909//     data: data,
910//     beforeSend: function () {
911//       loadmore.addClass("active");
912//     },
913//     complete: function () {
914//       loadmore.removeClass("active");
915//     },
916//     success: function (response) {
917//       jQuery('.searchResult_list').append(response.data);
918// 		jQuery('#loader-icon').addClass("hide");
919//     },
920//     error: function () {
921//       jQuery('#loader-icon').addClass("hide");
922//     },
923//   });
924
925// });
926
927/* Function to reset multi sliders value */
928function resetSlider() {
929
930  jQuery(".slider.multi-slide").each(function (i, data) {
931    // $this is a reference to .slider in current iteration of each
932    var $this = jQuery(this);
933    // find any .slider-range element WITHIN scope of $this
934    jQuery(".slider-range", $this).slider({
935      range: true,
936      min: parseInt($this.attr('data-initial')),
937      max: parseInt($this.attr('data-final')),
938      values: [parseInt($this.attr('data-initial')), parseInt($this.attr('data-final'))],
939    });
940    if ($this.attr('data-notation') === 'h') {
941      if ($this.attr('data-first') <= 9) {
942        jQuery(".firstVal", $this).val("0" + $this.attr('data-initial') + ':00 ' + $this.attr('data-notation'));
943        jQuery($this).attr("data-first", $this.attr('data-initial'));
944      } else {
945        jQuery(".firstVal", $this).val($this.attr('data-initial') + ':00 ' + $this.attr('data-notation'));
946        jQuery($this).attr("data-first", $this.attr('data-initial'));
947      }
948      if ($this.attr('data-second') <= 9) {
949        jQuery(".secondVal", $this).val('> 0' + $this.attr('data-final') + ':00 ' + $this.attr('data-notation'));
950        jQuery($this).attr("data-second", $this.attr('data-final'));
951      } else {
952        jQuery(".secondVal", $this).val('> ' + $this.attr('data-final') + ':00 ' + $this.attr('data-notation'));
953        jQuery($this).attr("data-second", $this.attr('data-final'));
954      }
955
956    } else {
957      jQuery(".firstVal", $this).val($this.attr('data-initial') + " " + $this.attr('data-notation'));
958      jQuery(".secondVal", $this).val($this.attr('data-final') + " " + $this.attr('data-notation'));
959      jQuery($this).attr("data-first", $this.attr('data-initial'));
960      jQuery($this).attr("data-second", $this.attr('data-final'));
961    }
962
963  });
964
965}
966/*Open filter sidebar*/
967function openFilter(event) {
968   jQuery(".filterMenu").toggleClass("filterWindow");
969}
970
971/****************** */
972function sortJsonData(sort, filteredData){
973  if(filteredData === undefined){
974    filteredData = jsonplaces;
975  }
976  
977  filteredData.sort(function(a, b) {
978      if (sort ==="short") {
979        return a.location_travel_distance - b.location_travel_distance;
980      } else if(sort ==="large") {
981        return b.location_travel_distance - a.location_travel_distance;
982      }
983    });
984    if (filterOtherPage === 'region'){
985      $('.region-single-wander-wrappe').html("");
986    }else{
987      $('.single-wander-wrappe-json').html("");
988    } 
989    currentIndex = 0;
990    listModifiedData(filteredData, 0);
991    if (filteredData.length < 1) {
992      console.log("empty");
993      jQuery(".LoadMore").hide();
994    }else if (filteredData.length > 0) {
995      
996      jQuery(".LoadMore").show();
997      jQuery(".noWanderung").remove();
998    } else {
999
1000      if (jQuery(".noWanderung").length < 1) {
1001        jQuery("#wanderung-loadmore").before('<h2 class="noWanderung">Keine Wanderungen gefunden</h2>');
1002      }
1003    }
1004  }
1005  
1006  function listModifiedData(jsonplaces, currentIndex){
1007    var i =currentIndex;
1008   
1009    
1010   count = -1;
1011    for(i; i< jsonplaces.length; i++) {
1012      count = count+1;
1013      var loc_season = jsonplaces[i].location_wander_saison_name;
1014      if( loc_season.length > 7 ) {
1015          loc_season = loc_season.slice(0,7) + "...";
1016      }
1017  
1018      var hikeDescriptionZoomFunc = jsonplaces[i].location_desc.substring(0, hikeDescriptionLetterCount) + "...";
1019      if (filterOtherPage === 'region'){
1020
1021        var wanderHtml = '<div class="single-wander"><div class="single-wander-img"><a href="' + 
1022          jsonplaces[i].location_link + '"><img class="wander-img" src="' + 
1023          jsonplaces[i].location_feature_image + '"></a><div '+
1024          (jsonplaces[i].watchlisted_by.indexOf( $('.region-single-wander-wrappe').data('logged-user').toString()) !== -1 ? "class='single-wander-heart watchlisted' ":"class='single-wander-heart' onclick='addToWatchlist(this, "+jsonplaces[i].location_id +")'" )+'></div><div class="single-wander-map" onclick="openPopupMap(this)" data-hikeid="' + 
1025          jsonplaces[i].location_id + '"></div></div><div class="single-region-rating"><h6 class="single-region">' + 
1026          jsonplaces[i].location_regionen_name + '</h6><span class="average-rating-display">' + 
1027          jsonplaces[i].average_rating + '<i class="fa fa-star"></i></span></div><a href="' + 
1028          jsonplaces[i].location_link + '" class="wander-redirect"><h2>' + 
1029          jsonplaces[i].location_name + '</h2></a><div class="wanderung-infobox"><div class="hiking_info"><div class="hike_level"><span class="' + 
1030          jsonplaces[i].location_level_cls + '"></span><p>' + jsonplaces[i].location_level_name + '</p></div><div class="hike_time"><span class="hike-time-icon"></span><p>' + 
1031          jsonplaces[i].location_hike_time + ' h </p></div><div class="hike_distance"><span class="hike-distance-icon"></span><p>' + 
1032          jsonplaces[i].location_travel_distance + ' km</p></div><div class="hike_ascent"><span class="hike-ascent-icon"></span><p>' + 
1033          jsonplaces[i].location_hike_ascent + ' m</p></div><div class="hike_descent"><span class="hike-descent-icon"></span><p>' + 
1034          jsonplaces[i].location_hike_descent + ' m</p></div><div class="hike_month"><span class="hike-month-icon"></span><p>' +
1035          loc_season + '</p></div></div></div><div class="wanderung-desc">' + hikeDescriptionZoomFunc + '</div>'+
1036          
1037          
1038          '<div class="weg-map-popup-outter"><div id="weg-map-popup'+jsonplaces[i].location_id+'" ><div class="map-fixed-position">'+
1039          '<div id="weg-map-popup-inner-wrapper'+jsonplaces[i].location_id+'">'+
1040            '<div class="close_map" onclick="closeElement(this)"><span class="close_map_icon"></span></div>'+
1041            '<div id="cesiumContainer" class="cesiumContainer"></div>'+
1042            '<div class="map_currentLocation"></div>'+
1043            '<div id="threeD" class="map_3d"></div>'+
1044            '<div id="map_direction" class="map_direction"></div>'+
1045            '<div class="botom_layer_icon">'+
1046              '<div class="accordion" >'+
1047                '<div class="weg-layer-wrap layer_head">'+
1048                  '<div class="weg-layer-text">Hintergrund</div>'+
1049                '</div>'+
1050              '</div>'+
1051              '<div class="panel">'+
1052                '<div class="weg-layer-wrap activeLayer" id="colormap_view_section">'+
1053                  '<div class="weg-layer-text">Karte farbig</div>'+
1054                '</div>'+
1055                '<div class="weg-layer-wrap" id="aerial_view_section">'+
1056                  '<div class="weg-layer-text">Luftbild</div>'+
1057                '</div>'+
1058                '<div class="weg-layer-wrap" id="grey_view_section">'+
1059                  '<div class="weg-layer-text">Karte SW</div>'+
1060                '</div>'+
1061              '</div>'+
1062            '</div>'+
1063            '<div class="copyRight">'+
1064              '<a target="_blank" href="https://www.swisstopo.admin.ch/de/home.html">© swisstopo</a>'+
1065            '</div>'+
1066            '<div class="map_filter">'+
1067              '<div class="map_filter_inner_wrapper">'+
1068                '<div class="accordion">Karteninformationen</div>'+
1069                '<div class="panel">'+
1070                  '<div class="fc_check_wrap">'+
1071                    '<label class="check_wrapper">ÖV-Haltestellen'+
1072                      '<input type="checkbox" name="" id="transport_layer_checkbox" value="">'+
1073                      '<span class="redmark"></span>'+
1074                    '</label>'+
1075                    '<label class="check_wrapper">Wanderwege'+
1076                      '<input type="checkbox" name="" id="hikes_trailing_layer" value="">'+
1077                      '<span class="redmark"></span>'+
1078                    '</label>'+
1079                    '<label class="check_wrapper">Gesperrte Wanderwege'+
1080                      '<input type="checkbox" name="" id="closure_hikes_layer" value="">'+
1081                      '<span class="redmark"></span>'+
1082                    '</label>'+
1083                    '<label class="check_wrapper">Schneehöhe ExoLabs'+
1084                      '<input type="checkbox" name="" id="snow_depth_layer" value="">'+
1085                      '<span class="redmark"></span>'+
1086                      '<div class="info_icon" onclick="infoIconCl
1086icked(event,&quot;weg-map-popup'+jsonplaces[i].location_id+'&quot;)"></div>'+
1087                    '</label>'+
1088                    '<label class="check_wrapper">Schneebedeckung ExoLabs'+
1089                      '<input type="checkbox" name="" id="snow_cover_layer" value="">'+
1090                      '<span class="redmark"></span>'+
1091                    '</label>'+
1092                    '<label class="check_wrapper">Hangneigungen über 30°'+
1093                      '<input type="checkbox" id="slope_30_layer" name="" value="">'+
1094                      '<span class="redmark"></span>'+
1095                    '</label>'+
1096                    '<label class="check_wrapper">Wildruhezonen'+
1097                      '<input type="checkbox" id="wildlife_layer" name="" value="">'+
1098                      '<span class="redmark"></span>'+
1099                    '</label>'+
1100                    '<label class="check_wrapper">Wegpunkte WegWandern.ch'+
1101                      '<input type="checkbox" id="waypoints_layer" name="" value="">'+
1102                      '<span class="redmark"></span>'+
1103                    '</label>'+
1104                  '</div>'+
1105                '</div>'+
1106              '</div>'+
1107            '</div>'+
1108          '</div>'+
1109          '<div id="detailPgPopup"><div id="detailPgPopupContent"></div></div>'+
1110          '<div class="elevationGraph"></div>	'+
1111          '<div class="options" id="mapOptions"></div>'+
1112          '<div class="snow_info_details hide">'+
1113		                '<div class="snow_inner_wrapper">'+
1114			                '<div class="snow_close_wrapper" onclick="infoIconClosed(event,&quot;weg-map-popup'+jsonplaces[i].location_id+'&quot;)"><div class="snow_close"></div></div>'+
1115			                '<div class="snow_tile">Auf der Karte wird die Schneehöhe (in cm) mit den folgenden Farben angezeigt:</div>'+
1116			                '<div class="snow_image"></div>'+
1117			                '<a href="https://wegwandern.ch/schneekarten-wo-liegt-jetzt-schnee/" target="_blank"><div class="snow_link externalLink">Weitere Informationen</div></a>'+
1118		                '</div>'+
1119	                '</div>'+
1120          '<div id="info"></div>'+
1121          '<div class="popover" id="transport-layer-info-popup">'+
1122            '<div class="arrow"></div>'+
1123            '<div class="popover-title">'+
1124              '<div class="popup-title">Objekt Informationen</div>'+
1125              '<div class="popup-buttons">'+
1126               
1127                '<button class="fa fa-remove" title="Close" onclick="closeTransportLayerPopup()"></button>'+
1128              '</div>'+
1129            '</div>'+
1130            '<div class="popover-content">'+
1131              '<div class="popover-scope">'+
1132                '<div class="popover-binding">'+
1133                  '<div class="htmlpopup-container" id="tl-content-area">'+
1134                  '</div>'+
1135                '</div>'+
1136              '</div>'+
1137            '</div>'+
1138          '</div>'+
1139        '</div></div></div></div>';
1140     
1141         if(count < 9) {
1142              // All 20
1143             
1144              $('.region-single-wander-wrappe').append(wanderHtml);
1145         
1146          }
1147
1148      }else{
1149        var wanderHtml = '<div class="single-wander"><div class="single-wander-img"><a href="' + 
1150          jsonplaces[i].location_link + '"><img class="wander-img" src="' + 
1151          jsonplaces[i].location_feature_image + '"></a><div '+
1152          (jsonplaces[i].watchlisted_by.indexOf( $('.single-wander-wrappe-json').data('logged-user').toString()) !== -1 ? "class='single-wander-heart watchlisted' ":"class='single-wander-heart' onclick='addToWatchlist(this, "+jsonplaces[i].location_id +")'" )+'></div><div class="single-wander-map" onclick="openPopupMap(this)" data-hikeid="' + 
1153          jsonplaces[i].location_id + '"></div></div><div class="single-region-rating"><h6 class="single-region">' + 
1154          jsonplaces[i].location_regionen_name + '</h6><span class="average-rating-display">' + 
1155          jsonplaces[i].average_rating + '<i class="fa fa-star"></i></span></div><a href="' + 
1156          jsonplaces[i].location_link + '" class="wander-redirect"><h2>' + 
1157          jsonplaces[i].location_name + '</h2></a><div class="wanderung-infobox"><div class="hiking_info"><div class="hike_level"><span class="' + 
1158          jsonplaces[i].location_level_cls + '"></span>
1158<p>' + jsonplaces[i].location_level_name + '</p></div><div class="hike_time"><span class="hike-time-icon"></span><p>' + 
1159          jsonplaces[i].location_hike_time + ' h </p></div><div class="hike_distance"><span class="hike-distance-icon"></span><p>' + 
1160          jsonplaces[i].location_travel_distance + ' km</p></div><div class="hike_ascent"><span class="hike-ascent-icon"></span><p>' + 
1161          jsonplaces[i].location_hike_ascent + ' m</p></div><div class="hike_descent"><span class="hike-descent-icon"></span><p>' + 
1162          jsonplaces[i].location_hike_descent + ' m</p></div><div class="hike_month"><span class="hike-month-icon"></span><p>' +
1163          loc_season + '</p></div></div></div><div class="wanderung-desc">' + hikeDescriptionZoomFunc + '</div>'+
1164          
1165          
1166          '<div class="weg-map-popup-outter"><div id="weg-map-popup'+jsonplaces[i].location_id+'" ><div class="map-fixed-position">'+
1167          '<div id="weg-map-popup-inner-wrapper'+jsonplaces[i].location_id+'">'+
1168            '<div class="close_map" onclick="closeElement(this)"><span class="close_map_icon"></span></div>'+
1169            '<div id="cesiumContainer" class="cesiumContainer"></div>'+
1170            '<div class="map_currentLocation"></div>'+
1171            '<div id="threeD" class="map_3d"></div>'+
1172            '<div id="map_direction" class="map_direction"></div>'+
1173            '<div class="botom_layer_icon">'+
1174              '<div class="accordion" >'+
1175                '<div class="weg-layer-wrap layer_head">'+
1176                  '<div class="weg-layer-text">Hintergrund</div>'+
1177                '</div>'+
1178              '</div>'+
1179              '<div class="panel">'+
1180                '<div class="weg-layer-wrap activeLayer" id="colormap_view_section">'+
1181                  '<div class="weg-layer-text">Karte farbig</div>'+
1182                '</div>'+
1183                '<div class="weg-layer-wrap" id="aerial_view_section">'+
1184                  '<div class="weg-layer-text">Luftbild</div>'+
1185                '</div>'+
1186                '<div class="weg-layer-wrap" id="grey_view_section">'+
1187                  '<div class="weg-layer-text">Karte SW</div>'+
1188                '</div>'+
1189              '</div>'+
1190            '</div>'+
1191            '<div class="copyRight">'+
1192              '<a target="_blank" href="https://www.swisstopo.admin.ch/de/home.html">© swisstopo</a>'+
1193            '</div>'+
1194            '<div class="map_filter">'+
1195              '<div class="map_filter_inner_wrapper">'+
1196                '<div class="accordion">Karteninformationen</div>'+
1197                '<div class="panel">'+
1198                  '<div class="fc_check_wrap">'+
1199                    '<label class="check_wrapper">ÖV-Haltestellen'+
1200                      '<input type="checkbox" name="" id="transport_layer_checkbox" value="">'+
1201                      '<span class="redmark"></span>'+
1202                    '</label>'+
1203                    '<label class="check_wrapper">Wanderwege'+
1204                      '<input type="checkbox" name="" id="hikes_trailing_layer" value="">'+
1205                      '<span class="redmark"></span>'+
1206                    '</label>'+
1207                    '<label class="check_wrapper">Gesperrte Wanderwege'+
1208                      '<input type="checkbox" name="" id="closure_hikes_layer" value="">'+
1209                      '<span class="redmark"></span>'+
1210                    '</label>'+
1211                    '<label class="check_wrapper">Schneehöhe Exolabs'+
1212                      '<input type="checkbox" name="" id="snow_depth_layer" value="">'+
1213                      '<span class="redmark"></span>'+
1214                      '<div class="info_icon" onclick="infoIconClicked(event,&quot;weg-map-popup'+jsonplaces[i].location_id+'&quot;)"></div>'+
1215                    '</label>'+
1216                    '<label class="check_wrapper">Schneebedeckung ExoLabs'+
1217                      '<input type="checkbox" name="" id="snow_cover_layer" value="">'+
1218                      '<span class="redmark"></span>'+
1219                    '</label>'+
1220                    '<label class="check_wrapper">Hangneigungen über 30°'+
1221                      '<input type="checkbox" id="slope_30_layer" name="" value="">'+
1222                      '<span class="redmark"></span>'+
1223                    '</label>'+
1224                    '<label class="check_wrapper">Wildruhezonen'+
1225                      '<input type="checkbox" id="wildlife_layer" name="" value="">'+
1226                      '<span class="redmark"></span>'+
1227                    '</label>'+
1228                    '<label class="check_wrapper">Wegpunkte WegWandern.ch'+
1229                      '<input type="checkbox" id="waypoints_layer" name="" value="">'+
1230                      '<span class="redmark"></span>'+
1231                    '</label>'+
1232                  '</div>'+
1233                '</div>'+
1234              '</div>'+
1235            '</div>'+
1236          '</div>'+
1237          '<div id="detailPgPopup"><div id="detailPgPopupContent"></div></div>'+
1238          '<div class="elevationGraph"></div>	'+
1239          '<div class="options" id="mapOptions"></div>'+
1240          '<div class="snow_info_details hide">'+
1241		                '<div class="snow_inner_wrapper">'+
1242			                '<div class="snow_close_wrapper" onclick="infoIconClosed(event,&quot;weg-map-popup'+jsonplaces[i].location_id+'&quot;)"><div class="snow_close"></div></div>'+
1243			                '<div class="snow_tile">Auf der Karte wird die Schneehöhe (in cm) mit den folgenden Farben angezeigt:</div>'+
1244			                '<div class="snow_image"></div>'+
1245			                '<a href="https://wegwandern.ch/schneekarten-wo-liegt-jetzt-schnee/" target="_blank"><div class="snow_link externalLink">Weitere Informationen</div></a>'+
1246		                '</div>'+
1247	                '</div>'+
1248          '<div id="info"></div>'+
1249          '<div class="popover" id="transport-layer-info-popup">'+
1250            '<div class="arrow"></div>'+
1251            '<div class="popover-title">'+
1252              '<div class="popup-title">Objekt Informationen</div>'+
1253              '<div class="popup-buttons">'+
1254               
1255                '<button class="fa fa-remove" title="Close" onclick="closeTransportLayerPopup()"></button>'+
1256              '</div>'+
1257            '</div>'+
1258            '<div class="popover-content">'+
1259              '<div class="popover-scope">'+
1260                '<div class="popover-binding">'+
1261                  '<div class="htmlpopup-container" id="tl-content-area">'+
1262                  '</div>'+
1263                '</div>'+
1264              '</div>'+
1265            '</div>'+
1266          '</div>'+
1267        '</div></div></div></div>';
1268     
1269         if(count < 20) {
1270              // All 20
1271             
1272              $('.single-wander-wrappe-json').append(wanderHtml);
1273         
1274          }
1275      }
1276      
1277          
1278    }
1279  }
1280  
1281  // Number of items to show per page
1282  let itemsPerPage;
1283  if($('.region-single-wander-wrappe').length > 0){
1284    itemsPerPage = 9;
1285  }
1286  if($('.single-wander-wrappe-json').length > 0){
1287    itemsPerPage = 20;
1288  }
1289  // Variable to keep track of the current index
1290  currentIndex = 0;
1291  // Function to show the next page
1292  function loadmoreData(){
1293    if(filteredData === undefined){
1294      filteredData = jsonplaces;
1295    }
1296    currentIndex += itemsPerPage;
1297    if (currentIndex >= filteredData.length) {
1298        currentIndex = 0; // Loop back to the beginning
1299    }
1300   
1301  }
1302 
1303  
1304
1305
1306  
1307function getActiveCheckboxValues(className) {
1308  // Get all checkboxes with the specified class
1309  var checkboxes = document.querySelectorAll('.' + className);
1310  
1311  // Create an array to store the values of active checkboxes
1312  var activeCheckboxValues = [];
1313
1314  // Loop through each checkbox
1315  checkboxes.forEach(function (checkbox) {
1316      // Check if the checkbox is checked (active)
1317      if (checkbox.checked) {
1318          // Get the value attribute of the checked checkbox and push it to the array
1319          activeCheckboxValues.push(parseInt(checkbox.value));
1320      }
1321  });
1322
1323  // Return the array of active checkbox values
1324  return activeCheckboxValues;
1325}
1326
1327  //filter data
1328function FilterList(eventType, e, filterOtherPage){
1329
1330    if (eventType == "hover") {
1331      jQuery('#loader-icon-filter').removeClass("hide");
1332      jQuery('.wegw_filtered_result_count').addClass("hide");
1333    } else {
1334      jQuery("#wegw-preloader").css("display", "block");
1335      jQuery('.ListSec').addClass('disabled');
1336    }
1337
1338    var initial, final;
1339    dataReset = null;
1340    //get initial and final data of double slider in filter window
1341    if (dataReset === 'reset') {
1342      initial = 'data-initial';
1343      final = 'data-final';
1344    } else {
1345      initial = 'data-first';
1346      final = 'data-second';
1347    }
1348
1349    var sort = '';
1350    //get the sort large/short
1351    if (window.innerWidth < 1200) {
1352        if (jQuery(".ListHead.mob .sort-largest").prop('checked') == true) {
1353        var sort = 'large';
1354        }
1355        if (jQuery(".ListHead.mob .sort-shortest").prop('checked') == true) {
1356        var sort = 'short';
1357        }
1358    } else {
1359        if (jQuery(".ListHead .sort-largest").prop('checked') == true) {
1360        var sort = 'large';
1361        }
1362        if (jQuery(".ListHead .sort-shortest").prop('checked') == true) {
1363        var sort = 'short';
1364        }
1365    }
1366    
1367
1368    var wanderSaisonValues = getActiveCheckboxValues('wander_saison_search');
1369    var ausdauerValues = getActiveCheckboxValues('ausdauer_search');
1370    var routenverlaufValues = getActiveCheckboxValues('routenverlauf_search');
1371    var themaValues = getActiveCheckboxValues('thema_search');
1372    var angeboteValues = getActiveCheckboxValues('angebote_search');
1373    var wanderregionenValues = getActiveCheckboxValues('wanderregionen_search');
1374    var activityValues = getActiveCheckboxValues('activity_search');
1375    var levelIdValues = getActiveCheckboxValues('difficulty_search');
1376
1377    
1378
1379
1380    // generic for slider filters
1381    const createSliderFilter = (propertyName, sliderType) => (item) => {
1382      const firstValue = parseInt($(`.${sliderType}`).attr('data-first'));
1383      const initialValue = parseInt($(`.${sliderType}`).attr('data-initial'));
1384      const secondValue = parseInt($(`.${sliderType}`).attr('data-second'));
1385      const finalValue = parseInt($(`.${sliderType}`).attr('data-final'));
1386
1387      // Check if the relevant values are different before applying the filter
1388      if (
1389        (firstValue !== initialValue || secondValue !== finalValue) &&
1390        (firstValue !== secondValue || initialValue !== finalValue)
1391      ) {
1392        return (
1393          item[propertyName] >= firstValue &&
1394          item[propertyName] <= secondValue
1395        );
1396      }
1397
1398      // If the values are the same, return true to include the item in the filter
1399      return true;
1400    };
1401
1402    // generic for array filters
1403    const createArrayFilter = (propertyName, values) => (item) => {
1404      // Check if values array is not null before applying the filter
1405      if (values.length !== 0) {
1406        return item[propertyName].some(data => values.includes(data));
1407      }
1408      // If values array is null, return true to include the item in the filter
1409      return true;
1410    };
1411
1412    const filterByAltitude = (item) => {
1413      const firstValue = parseFloat($('.aaltitude-slider').attr('data-first'));
1414      const initialValue = parseFloat($('.aaltitude-slider').attr('data-initial'));
1415      const secondValue = parseFloat($('.aaltitude-slider').attr('data-second'));
1416      const finalValue = parseFloat($('.aaltitude-slider').attr('data-final'));
1417
1418      const highestPoint = parseFloat(item.location_hike_hochster_punkt);
1419      const lowestPoint = parseFloat(item.location_hike_tiefster_punkt);
1420
1421      // Check if either highest or lowest point is within the slider range
1422      const isInRange =(lowestPoint >= firstValue ) && ( highestPoint <= secondValue);
1423
1424      // Check if the relevant values are different before applying the filter
1425      if (
1426        (firstValue !== initialValue || secondValue !== finalValue) &&
1427        (firstValue !== secondValue || initialValue !== finalValue)
1428      ) {
1429        return isInRange;
1430      }
1431
1432      // If the values are the same, return true to include the item in the filter
1433      return true;
1434    };
1435
1436    const filterByTime = (item) => {
1437      const firstValue = parseFloat($('.dauer-slider').attr('data-first'));
1438      const initialValue = parseFloat($('.dauer-slider').attr('data-initial'));
1439      const secondValue = parseFloat($('.dauer-slider').attr('data-second'));
1440      const finalValue = parseFloat($('.dauer-slider').attr('data-final'));
1441
1442      // const hikeTime = item.location_hike_time.split(':')[0];
1443      // Check if hike time is empty
1444      if (item.location_hike_time === "") {
1445        return true;
1446      }
1447      const hikeTime = parseFloat(item.location_hike_time.split(':')[0]+"."+item.location_hike_time.split(':')[1]);
1448
1449      // Check if either highest or lowest point is within the slider range
1450      const isInRange = hikeTime >= firstValue+".00" &&
1451                        hikeTime <= secondValue+".00";
1452
1453      // Check if the relevant values are different before applying the filter
1454      if (
1455        (firstValue !== initialValue || secondValue !== finalValue) &&
1456        (firstValue !== secondValue || initialValue !== finalValue)
1457      ) {
1458        return isInRange;
1459      }
1460
1461      // If the values are the same, return true to include the item in the filter
1462      return true;
1463    };
1464
1465
1466    // Add more slider filters as needed
1467    const filterByDistance = createSliderFilter('location_travel_distance', 'km-slider');
1468    const filterByAscent = createSliderFilter('location_hike_ascent', 'aufstieg-slider');
1469    const filterByDescent = createSliderFilter('location_hike_descent', 'abstieg-slider');
1470    //const filterByTime = createSliderFilter('location_hike_time', 'dauer-slider');
1471
1472    // Add more array filters as needed
1473    const filterBySaison = createArrayFilter('location_wander_saison', wanderSaisonValues);
1474    const filterByAusdauer = createArrayFilter('location_ausdauer', ausdauerValues);
1475    const filterByThema = createArrayFilter('location_thema', themaValues);
1476    const filterByAngebote = createArrayFilter('location_angebote', angeboteValues);
1477    // if(filterOtherPage === 'region') {
1478    //   const filterByWanderregionen = createArrayFilter('location_regionen_id', wanderregionenValues);
1479     
1480    // }else{
1481    //   const filterByWanderParentregionen = createArrayFilter('location_regionen_parent_id', wanderregionenValues);
1482    // }
1483   
1484    
1485    // const filterByWanderregionen = createArrayFilter('location_regionen_id', wanderregionenValues);
1486    const filterByRoutenverlauf = createArrayFilter('location_routenverlauf', routenverlaufValues);
1487    const filterByActivity = createArrayFilter('location_aktivitat', activityValues);
1488    const filterBylevelId = createArrayFilter('location_level_id', levelIdValues);
1489
1490
1491    const filterFunctions = [
1492      filterByDistance,
1493      filterByAscent,
1494      filterByDescent,
1495      filterByTime,
1496      filterByAltitude,
1497      filterBySaison,
1498      filterByAusdauer,
1499      filterByThema,
1500      filterByAngebote,
1501     // filterByWanderregionen,
1502      filterByRoutenverlauf,
1503      filterByActivity,
1504      filterBylevelId,
1505      
1506    ];
1507
1508    //for region pages only
1509    if ($('.filter-btn.region-filter').length > 0) {
1510      if($('#template_region_type')[0].value === 'parent'){
1511        //if parent
1512        const filterByWanderParentregionen = createArrayFilter('location_regionen_parent_id', wanderregionenValues);
1513        filterFunctions.push(filterByWanderParentregionen);
1514      }else{
1515        const filterByWanderregionen = createArrayFilter('location_regionen_id', wanderregionenValues);
1516        filterFunctions.push(filterByWanderregionen);
1517      }
1518      
1519    } else {//for tourenportal page only
1520      const filterByWanderParentregionen = createArrayFilter('location_regionen_parent_id', wanderregionenValues);
1521      filterFunctions.push(filterByWanderParentregionen);
1522    }
1523
1524    
1525    
1526    const combinedFilter = item => filterFunctions.every(filterFn => filterFn(item));
1527
1528    filteredData = jsonplaces.filter(combinedFilter);
1529    console.log(filteredData);
1530
1531
1532    if (eventType == "hover") {
1533      $('.wegw_filtered_result_count').html(filteredData.length);
1534      jQuery('.header_menu .search_head').val(jQuery('#searchbox_main_filter').val());
1535      jQuery('#loader-icon-filter').addClass("hide");
1536      jQuery('.wegw_filtered_result_count').removeClass("hide");
1537      if (filteredData.length == "0") {
1538        jQuery(".LoadMore").hide();
1539      } else {
1540        jQuery(".LoadMore").show();
1541      }
1542
1543    } else if (eventType == "btnClick") {
1544
1545      /* Check if the `Click` event is triggered or actually clicked */
1546      if (e.which) {
1547        var posts = filteredData;
1548        var countp = filteredData.length;
1549
1550        if (posts == "" || countp < 1) {
1551          jQuery(".LoadMore").hide();
1552        } else {
1553          jQuery(".LoadMore").show();
1554        }
1555
1556        /* 
1557          * Update respose coming from ajax function inside html
1558          * If hike count = 0. In script `places` load as empty json
1559          * Else load complete hike html inside the script
1560          */
1561
1562        //check if its region page or tourenportal page
1563        if (filterOtherPage === 'region') {
1564          // jQuery(".region-single-wander-wrappe").html(posts[0]);
1565          jQuery(".region-single-wander-wrappe").html("");
1566          listModifiedData(posts, 0);
1567        } else {
1568        // jQuery(".single-wander-wrappe-json").html(posts[0]);
1569        $('.single-wander-wrappe-json').html("");
1570          listModifiedData(posts, 0);
1571        }
1572
1573        if (countp > 0) {
1574          $('.wegw_filtered_result_count').html(posts.length);
1575          jQuery(".noWanderung").remove();
1576        } else {
1577          //check if its region page or tourenportal page
1578          if (filterOtherPage === 'region') {
1579            jQuery(".region-single-wander-wrappe").html('');
1580            listModifiedData(posts,0);
1581          } else {
1582          // jQuery(".single-wander-wrappe").html('');
1583          $('.single-wander-wrappe-json').html("");
1584            listModifiedData(posts,0);
1585          }
1586
1587          if (jQuery(".noWanderung").length < 1) {
1588            jQuery("#wanderung-loadmore").before('<h2 class="noWanderung">Keine Wanderungen gefunden</h2>');
1589          }
1590        }
1591        /* If `Click` event is actually clicked trigger automatically to plot cluster markers */
1592
1593        //check if its region page or tourenportal page
1594        triggerFilterResult = true;
1595        sortJsonData(sort, filteredData);
1596
1597      }
1598
1599    }
1600    /**to remove empty hike info*/
1601    toRemoveEmptyHikeInfo();
1602    jQuery("#wegw-preloader").css("display", "none");
1603    jQuery('.ListSec').removeClass('disabled');
1604
1605}
1606  
1607

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.