PageSourceSearch

https://www.produits-de-nouvelle-aquitaine.fr/wp-content/plugins/c…-map-poi-exploration-gourmande.js?ver=7.1.2

js produits-de-nouvelle-aquitaine.fr collected 2026-10-02 11:30:33 UTC 29,944 bytes, 931 lines download raw bytes

1(function ($) {
2  var markers = L.markerClusterGroup();
3  // var roads = L.markerClusterGroup();
4  var arrayCoordsGlobal = [];
5  var currentRequest = undefined;
6
7  var idCurrentpage = jsVars.currentpage;
8
9  $(document).ready(function () {
10    if ($("#mapBloc").length > 0) {
11      $("#loader").hide();
12
13      $(".filterCategory.labels").addClass("active");
14
15      // Produits
16      var produits = JSON.parse(jsVars.produits);
17
18      var data = getProduitsToDisplay(produits, idCurrentpage);
19      var produitsDisplay = data.produitsDisplay;
20
21      //Definition de la map leaflet
22      var mainMap = L.map("mapBloc", {
23        // dragging: !L.Browser.mobile, // Cause un souci en mobile. Impossible de zoomer
24        zoomControl: false,
25        touchZoom: true,
26        tap: false,
27        scrollWheelZoom: false,
28        maxZoom: 18,
29      }).setView([46.603354, 1.8883335], 6);
30
31      var gl = L.mapboxGL({
32        tileSize: 512,
33        zoomOffset: -1,
34        minZoom: 1,
35        attribution:
36          '\u003ca href="https://www.maptiler.com/copyright/" target="_blank"\u003e\u0026copy; MapTiler\u003c/a\u003e \u003ca href="https://www.openstreetmap.org/copyright" target="_blank"\u003e\u0026copy; OpenStreetMap contributors\u003c/a\u003e',
37        style:
38          "https://api.maptiler.com/maps/streets/style.json?key=YzdBdNTaB4ZNzV5d2tM6",
39        crossOrigin: true,
40      }).addTo(mainMap);
41
42      L.control
43        .zoom({
44          position: "topright",
45        })
46        .addTo(mainMap);
47
48      if (produitsDisplay.length > 0) {
49        createProduitsMarkers(produitsDisplay, mainMap);
50
51        var checkboxLabelValues = [];
52
53        // Filtres
54
55        // PRODUITS LABELISÉS
56        $("#mapFilter .filterCategory.labels .label-item input").each(function (
57          index,
58          elem
59        ) {
60          $(this).click(function () {
61            var term_val = $(this).val();
62            if (currentRequest !== undefined) {
63              currentRequest.abort();
64            }
65            // On affiche le loader
66            $("#loader").show();
67
68            // Labels
69            if ($(this).is(":checked")) {
70              checkboxLabelValues.push(term_val);
71            } else {
72              checkboxLabelValues = $.grep(
73                checkboxLabelValues,
74                function (value) {
75                  return value != term_val;
76                }
77              );
78            }
79            var data = {
80              action: "getContentsFiltered",
81              labels: checkboxLabelValues,
82            };
83
84            currentRequest = $.post(jsVars.ajaxUrl, data, function (res) {
85              var contentFiltered = res.data;
86
87              if (contentFiltered[0] == "empty") {
88                $("#loader").hide();
89                mainMap.removeLayer(markers);
90              } else {
91                markers.clearLayers();
92
93                var data = getProduitsToDisplay(contentFiltered, idCurrentpage);
94                var contentFilteredDisplay = data.produitsDisplay;
95
96                createProduitsMarkers(contentFilteredDisplay, mainMap);
97                mainMap.setView([46.603354, 1.8883335], 6);
98              }
99            }).done(function () {
100              $("#loader").hide();
101            });
102          });
103        });
104
105        // CONCOURS SAVEURS
106        $("#mapFilter .filterCategory.concours .label-item input").each(
107          function (index, elem) {
108            $(this).click(function () {
109              var term_val = $(this).val();
110              $("#current_year").val(term_val);
111              if (currentRequest !== undefined) {
112                currentRequest.abort();
113              }
114              // On affiche le loader
115              $("#loader").show();
116
117              // Radios
118              var data = {
119                action: "getEntreprises",
120                annee: term_val,
121              };
122
123              currentRequest = $.post(jsVars.ajaxUrl, data, function (res) {
124                var contentFiltered = res.data;
125
126                if (contentFiltered[0] == "empty") {
127                  $("#loader").hide();
128                  mainMap.removeLayer(markers);
129                } else {
130                  markers.clearLayers();
131
132                  var data = getEntreprisesToDisplay(
133                    contentFiltered,
134                    idCurrentpage
135                  );
136                  var contentFilteredDisplay = data.entreprisesDisplay;
137
138                  createEntreprisesMarkers(contentFilteredDisplay, mainMap);
139                  mainMap.setView([46.603354, 1.8883335], 6);
140                }
141              }).done(function () {
142                $("#loader").hide();
143              });
144            });
145          }
146        );
147
148        // PRODUCTEURS
149        $("#mapFilter .filterCategory.producteurs .label-item input").each(
150          function (index, elem) {
151            $(this).click(function () {
152              if (currentRequest !== undefined) {
153                currentRequest.abort();
154              }
155              // On affiche le loader
156              $("#loader").show();
157
158              var data = {
159                action: "getFiches",
160                type: "producteurs",
161              };
162
163              currentRequest = $.post(jsVars.ajaxUrl, data, function (res) {
164                var contentFiltered = res.data;
165
166                if (contentFiltered[0] == "empty") {
167                  $("#loader").hide();
168                  mainMap.removeLayer(markers);
169                } else {
170                  markers.clearLayers();
171
172                  var data = getProducteursToDisplay(
173                    contentFiltered,
174                    idCurrentpage
175                  );
176                  var contentFilteredDisplay = data.producteursDisplay;
177
178                  createProducteursMarkers(contentFilteredDisplay, mainMap);
179                  mainMap.setView([46.603354, 1.8883335], 6);
180                }
181              }).done(function () {
182                $("#loader").hide();
183              });
184            });
185          }
186        );
187
188        // ROUTES
189        $("#mapFilter .filterCategory.routes .label-item input").each(function (
190          index,
191          elem
192        ) {
193          $(this).click(function () {
194            if (currentRequest !== undefined) {
195              currentRequest.abort();
196            }
197            // On affiche le loader
198            $("#loader").show();
199
200            var data = {
201              action: "getFiches",
202              type: "routes",
203              route: $(this).val(),
204            };
205
206            currentRequest = $.post(jsVars.ajaxUrl, data, function (res) {
207              var contentFiltered = res.data;
208
209              if (contentFiltered[0] == "empty") {
210                $("#loader").hide();
211                mainMap.removeLayer(markers);
212              } else {
213                markers.clearLayers();
214
215                var data = getRoutesToDisplay(contentFiltered, idCurrentpage);
216                var contentFilteredDisplay = data.routesDisplay;
217
218                createRoutesMarkers(contentFilteredDisplay, mainMap);
219
220                mainMap.setView([46.603354, 1.8883335], 6);
221              }
222            }).done(function () {
223              $("#loader").hide();
224            });
225          });
226        });
227      }
228      mainMap.invalidateSize();
229
230      // Gestions des préfiltres
231      bindFiltrerClick(mainMap);
232      // bindResetMapClick();
233
234      //   $(".concours h3").click(function () {
235      //     alert("ok");
236      //   });
237    }
238  }); // End Ready
239
240  // PRODUITS
241
242  function getProduitsToDisplay(produits, idCurrentpage) {
243    // console.log(idCurrentpage);
244    var nbreEvenements = produits.length;
245    // console.log(nbreEvenements);
246    var produitsDisplay = [];
247    var arrayCoords = [];
248
249    for (var i = 0; i < nbreEvenements; i++) {
250      var produit = produits[i];
251      // console.log(produit);
252      //Page accueil
253      if ($(".page-id-" + idCurrentpage).length > 0) {
254        if (produit.lat && produit.lng) {
255          // console.log(produit.lat+ ', '+produit.lng);
256          produitsDisplay.push(produit);
257          arrayCoords.push([produit.lat, produit.lng]);
258          arrayCoordsGlobal.push([produit.lat, produit.lng]);
259        }
260      }
261    }
262
263    return { produitsDisplay: produitsDisplay, arrayCoords: arrayCoords };
264  }
265
266  function createProduitsMarkers(produitsDisplay, map) {
267    for (var i = 0; i < produitsDisplay.length; i++) {
268      var produit = produitsDisplay[i];
269      var produitIcon = L.icon({
270        iconUrl:
271          jsVars.pluginUrl +
272          "/lib/leaflet/images/produits/marker-" +
273          produit.type_produit +
274          ".svg",
275        iconSize: [37, 51], // size of the icon
276        iconAnchor: [18, 51], // point of the icon which will correspond to marker's location
277        popupAnchor: [0, -55], // point from which the popup should open relative to the iconAnchor
278        className: "produit-marker-" + produit.id,
279      });
280
281      // specify popup options
282      var customOptions = {
283        className: "produit",
284      };
285
286      // var marker = L.marker(new L.LatLng(produit.lat, produit.lng));
287      var marker = L.marker(new L.LatLng(produit.lat, produit.lng), {
288        icon: produitIcon,
289        id: produit.id,
290      });
291
292      marker.bindPopup(
293        '<div class="spinner" style="display:block;"></div>',
294        customOptions
295      );
296
297      marker.on("click", function (e) {
298        var popup = e.target.getPopup();
299        var markerID = e.target.options.id;
300        map.setView(e.target.getLatLng(), map.getZoom());
301        openPopupAjax(popup, "getProduit", markerID, "produit-produit");
302      });
303
304      markers.addLayer(marker);
305    }
306
307    scrollTo($("#mapBloc"));
308    // console.log(map);
309    map.addLayer(markers);
310
311    //Rencentre la map sur les POIs affichés
312    // var bounds = new L.LatLngBounds(arrayCoordsGlobal);
313    // map.fitBounds(markers.getBounds());
314  }
315
316  // CONCOURS
317  function getEntreprisesToDisplay(entreprises, idCurrentpage) {
318    // console.log(idCurrentpage);
319    var nbreEntreprises = entreprises.length;
320    // console.log(nbreEntreprises);
321    var entreprisesDisplay = [];
322    var arrayCoords = [];
323
324    for (var i = 0; i < nbreEntreprises; i++) {
325      var entreprise = entreprises[i];
326      //Page accueil
327      if ($(".page-id-" + idCurrentpage).length > 0) {
328        if (entreprise.lat && entreprise.lng) {
329          // console.log(entreprise.lat+ ', '+entreprise.lng);
330          entreprisesDisplay.push(entreprise);
331          arrayCoords.push([entreprise.lat, entreprise.lng]);
332          arrayCoordsGlobal.push([entreprise.lat, entreprise.lng]);
333        }
334      }
335    }
336
337    return { entreprisesDisplay: entreprisesDisplay, arrayCoords: arrayCoords };
338  }
339
340  function getProducteursToDisplay(fiche, idCurrentpage) {
341    // console.log(idCurrentpage);
342    var nbreProducteurs = fiche.length;
343    // console.log(nbreProducteurs);
344    var producteursDisplay = [];
345    var arrayCoords = [];
346
347    for (var i = 0; i < nbreProducteurs; i++) {
348      var producteur = fiche[i];
349      //Page accueil
350      if ($(".page-id-" + idCurrentpage).length > 0) {
351        if (producteur.lat && producteur.lng) {
352          // console.log(producteur.lat+ ', '+producteur.lng);
353          producteursDisplay.push(producteur);
354          arrayCoords.push([producteur.lat, producteur.lng]);
355          arrayCoordsGlobal.push([producteur.lat, producteur.lng]);
356        }
357      }
358    }
359
360    return { producteursDisplay: producteursDisplay, arrayCoords: arrayCoords };
361  }
362
363  function getRoutesToDisplay(fiche, idCurrentpage) {
364    // console.log(idCurrentpage);
365    var nbreRoutes = fiche.length;
366    // console.log(nbreRoutes);
367    var routesDisplay = [];
368    var arrayCoords = [];
369
370    for (var i = 0; i < nbreRoutes; i++) {
371      var route = fiche[i];
372      //Page accueil
373      if ($(".page-id-" + idCurrentpage).length > 0) {
374        if (route.lat && route.lng) {
375          // console.log(route.lat+ ', '+route.lng);
376          routesDisplay.push(route);
377          arrayCoords.push([route.lat, route.lng]);
378          arrayCoordsGlobal.push([route.lat, route.lng]);
379        }
380      }
381    }
382
383    return { routesDisplay: routesDisplay, arrayCoords: arrayCoords };
384  }
385
386  function createEntreprisesMarkers(entreprisesDisplay, map) {
387    for (var i = 0; i < entreprisesDisplay.length; i++) {
388      var entreprise = entreprisesDisplay[i];
389      var entrepriseIcon = L.icon({
390        iconUrl:
391          jsVars.pluginUrl +
392          "/lib/leaflet/images/medailles/" +
393          entreprise.year +
394          ".svg",
395        iconSize: [37, 51], // size of the icon
396        iconAnchor: [18, 51], // point of the icon which will correspond to marker's location
397        popupAnchor: [0, -55], // point from which the popup should open relative to the iconAnchor
398        className: "entreprise-marker-" + entreprise.id,
399      });
400
401      // specify popup options
402      var customOptions = {
403        className: "entreprise entreprise-" + entreprise.id,
404      };
405
406      // var marker = L.marker(new L.LatLng(entreprise.lat, entreprise.lng));
407      var marker = L.marker(new L.LatLng(entreprise.lat, entreprise.lng), {
408        icon: entrepriseIcon,
409        id: entreprise.id,
410      });
411
412      marker.bindPopup(
413        '<div class="spinner" style="display:block;"></div>',
414        customOptions
415      );
416
417      marker.on("click", function (e) {
418        var popup = e.target.getPopup();
419        var markerID = e.target.options.id;
420        // map.setView(e.target.getLatLng(), map.getZoom());
421        openPopupAjaxMedailles(popup, "getEntreprise", markerID, "entreprise");
422      });
423
424      markers.addLayer(marker);
425    }
426
427    scrollTo($("#mapBloc"));
428    // console.log(map);
429    map.addLayer(markers);
430
431    //Rencentre la map sur les POIs affichés
432    // var bounds = new L.LatLngBounds(arrayCoordsGlobal);
433    // map.fitBounds(markers.getBounds());
434  }
435
436  function createProducteursMarkers(entreprisesDisplay, map) {
437    // console.log(entreprisesDisplay);
438    for (var i = 0; i < entreprisesDisplay.length; i++) {
439      var entreprise = entreprisesDisplay[i];
440      var entrepriseIcon = L.icon({
441        iconUrl: jsVars.themeurl + "/assets/img/svg/marker-fleur.svg",
442        iconSize: [32, 32], // size of the icon
443        iconAnchor: [16, 16], // point of the icon which will correspond to marker's location
444        popupAnchor: [0, -16], // point from which the popup should open relative to the iconAnchor
445        className: "entreprise-marker-" + entreprise.id,
446      });
447
448      // specify popup options
449      var customOptions = {
450        className: "popupFiche entreprise entreprise-" + entreprise.id,
451      };
452
453      // var marker = L.marker(new L.LatLng(entreprise.lat, entreprise.lng));
454      var marker = L.marker(new L.LatLng(entreprise.lat, entreprise.lng), {
455        icon: entrepriseIcon,
456        id: entreprise.id,
457      });
458
459      marker.bindPopup(
460        '<div class="spinner" style="display:block;"></div>',
461        customOptions
462      );
463
464      marker.on("click", function (e) {
465        var popup = e.target.getPopup();
466        var markerID = e.target.options.id;
467        // map.setView(e.target.getLatLng(), map.getZoom());
468        openPopupAjaxFiche(popup, "getFiche", markerID);
469      });
470
471      markers.addLayer(marker);
472    }
473
474    scrollTo($("#mapBloc"));
475    // console.log(map);
476    map.addLayer(markers);
477
478    //Rencentre la map sur les POIs affichés
479    // var bounds = new L.LatLngBounds(arrayCoordsGlobal);
480    // map.fitBounds(markers.getBounds());
481  }
482
483  function createRoutesMarkers(entreprisesDisplay, map) {
484    // console.log(entreprisesDisplay);
485    for (var i = 0; i < entreprisesDisplay.length; i++) {
486      var entreprise = entreprisesDisplay[i];
487      console.log(entreprise);
488      var entrepriseIcon = L.icon({
489        iconUrl:
490          jsVars.themeurl +
491          "/assets/img/svg/marker-" +
492          entreprise.type +
493          ".svg",
494        iconSize: [32, 32], // size of the icon
495        iconAnchor: [16, 16], // point of the icon which will correspond to marker's location
496        popupAnchor: [0, -16], // point from which the popup should open relative to the iconAnchor
497        className: "entreprise-marker-" + entreprise.id,
498      });
499
500      // specify popup options
501      var customOptions = {
502        className: "popupFiche entreprise entreprise-" + entreprise.id,
503      };
504
505      // var marker = L.marker(new L.LatLng(entreprise.lat, entreprise.lng));
506      var marker = L.marker(new L.LatLng(entreprise.lat, entreprise.lng), {
507        icon: entrepriseIcon,
508        id: entreprise.id,
509      });
510
511      marker.bindPopup(
512        '<div class="spinner" style="display:block;"></div>',
513        customOptions
514      );
515
516      marker.on("click", function (e) {
517        var popup = e.target.getPopup();
518        var markerID = e.target.options.id;
519        // map.setView(e.target.getLatLng(), map.getZoom());
520        openPopupAjaxFiche(popup, "getFiche", markerID, "route");
521      });
522
523      markers.addLayer(marker);
524    }
525
526    scrollTo($("#mapBloc"));
527    // console.log(map);
528    map.addLayer(markers);
529
530    //Rencentre la map sur les POIs affichés
531    // var bounds = new L.LatLngBounds(arrayCoordsGlobal);
532    // map.fitBounds(markers.getBounds());
533  }
534
535  function bindResetMapClick() {
536    /* Reset Map */
537    $(".btn-reset").click(function (e) {
538      // console.log('rest');
539      e.preventDefault();
540      if ($("#bloc-reset-map").hasClass("visible")) {
541        $("#bloc-reset-map").removeClass("visible");
542      } else {
543        $("#bloc-reset-map").addClass("visible");
544      }
545    });
546  }
547
548  function bindFiltrerClick(mainMap) {
549    $(".filterCategory h3").each(function (index, elem) {
550      $(elem).click(function (event) {
551        const self = $(this);
552
553        // Toggle
554
555        if (
556          !self.parent().hasClass("active") &&
557          self.parent().is(".producteurs")
558        ) {
559          $('input[value="bienvenue-a-la-ferme"]')[0].click();
560        }
561
562        // $(this).parent().next('.dc').slideToggle( "slow" );
563        if (
564          !self.parent().hasClass("active") &&
565          !self.parent().is(".producteurs")
566        ) {
567          // Cancel other request
568          if (currentRequest !== undefined) {
569            currentRequest.abort();
570          }
571
572          // On affiche le loader
573          $("#loader").show();
574
575          // Retire la possibilité de cliquer ailleurs pour éviter trop de requête AJAX
576          // $(".pre-filter").unbind("click");
577
578          // if (!$(".filter").hasClass("open")) {
579          //   $(".filter").toggleClass("open");
580          // }
581
582          var type_contenus;
583          var classToActive = $(this).data("target");
584
585          if (self.parent().hasClass("concours")) {
586            type_contenus = "entreprise";
587            var data = {
588              action: "getEntreprises",
589            };
590            self
591              .parent()
592              .find(".filterItems .label-item:first input")
593              .attr("checked", "checked")
594              .click();
595
596            return;
597          } else if (self.parent().hasClass("labels")) {
598            type_contenus = "produit";
599            var data = {
600              action: "getContentsFiltered",
601            };
602          } else if (self.parent().hasClass("routes")) {
603            type_contenus = "route";
604            var data = {
605              action: "getFiches",
606              type: "routes",
607            };
608          }
609
610          // if ($(this).hasClass("active")) {
611          currentRequest = $.post(jsVars.ajaxUrl, data, function (res) {
612            var contentFiltered = res.data;
613            if (contentFiltered[0] && contentFiltered[0] == "empty") {
614              bindFiltrerClick(mainMap);
615              bindResetMapClick();
616              $("#loader").hide();
617              mainMap.removeLayer(markers);
618              self.find(".counter").html(0);
619            } else {
620              self.find(".counter").html(contentFiltered.length);
621              markers.clearLayers();
622
623              if (type_contenus == "entreprise") {
624                var data = getEntreprisesToDisplay(
625                  contentFiltered,
626                  idCurrentpage
627                );
628                var contentFilteredDisplay = data.entreprisesDisplay;
629                var arrayCoords = data.arrayCoords;
630                createEntreprisesMarkers(contentFilteredDisplay, mainMap);
631              }
632
633              if (type_contenus == "produit") {
634                var data = getProduitsToDisplay(contentFiltered, idCurrentpage);
635                var contentFilteredDisplay = data.produitsDisplay;
636                var arrayCoords = data.arrayCoords;
637                createProduitsMarkers(contentFilteredDisplay, mainMap);
638              }
639
640              // if (type_contenus == "producteur") {
641              //   var data = getProducteursToDisplay(
642              //     contentFiltered,
643              //     idCurrentpage
644              //   );
645              //   var contentFilteredDisplay = data.producteursDisplay;
646              //   var arrayCoords = data.arrayCoords;
647              //   createProducteursMarkers(contentFilteredDisplay, mainMap);
648              // }
649
650              if (type_contenus == "route") {
651                var data = getRoutesToDisplay(contentFiltered, idCurrentpage);
652                var contentFilteredDisplay = data.routesDisplay;
653                var arrayCoords = data.arrayCoords;
654                createRoutesMarkers(contentFilteredDisplay, mainMap);
655              }
656            }
657
658            mainMap.setView([46.603354, 1.8883335], 6);
659          }).done(function () {
660            bindFiltrerClick(mainMap);
661            bindResetMapClick();
662            $("#loader").hide();
663          });
664          // }
665        }
666      });
667    });
668  }
669
670  function openPopupAjax(popup, action, markerID, contentType) {
671    var data = {
672      action: action,
673      id: markerID,
674      annee: $("#current_year").val(),
675      lang: jsVars.lang,
676    };
677
678    $.post(jsVars.ajaxUrl, data, function (res) {
679      var content = res.data;
680
681      var labels = content.labels;
682      var labelsDisplay = "";
683
684      $.each(labels, function (k, v) {
685        labelsDisplay += '<img src="' + v.logo + '" alt="' + v.name + '">';
686      });
687
688      var popupHTML =
689        '<div class="top">' +
690        '<div class="produit product-list-item">' +
691        "<div>" +
692        '<div class="product-image">' +
693        '<a class="" href="' +
694        content.link +
695        '">' +
696        '<img src="' +
697        content.image +
698        '">' +
699        '</a>\
700                                </div>\
701                            </div>\
702                            <div class="labels"> ' +
703        labelsDisplay +
704        '</div>\
705                        </div>\
706                        <div class="title"><h2>' +
707        content.title +
708        '</h2></div>\
709                    </div>\
710                    <div class="details-data">\
711                        <span class="etablissement">' +
712        content.entite +
713        '</span>\
714                        <span class="categorie ' +
715        content.type_produit_slug +
716        '">' +
717        content.type_produit +
718        '</span>\
719                        <span class="adresse">' +
720        content.adresse +
721        "</span>\
722            ";
723      if (typeof content.contact_telephone !== "undefined") {
724        popupHTML +=
725          '<span class="tel">' + content.contact_telephone + "</span>";
726      }
727      if (typeof content.contact_email !== "undefined") {
728        popupHTML +=
729          '<span class="email"><a class="button btn-text black yellow-border" href="mailto:' +
730          content.contact_email +
731          '">' +
732          content.contact_email +
733          "</a></span>";
734      }
735      if (typeof content.contact_site_internet !== "undefined") {
736        popupHTML +=
737          '<span class="site_web"><a class="button btn-text black yellow-border" href="' +
738          content.contact_site_internet +
739          '" target="_blank">' +
740          content.contact_site_internet +
741          "</a></span>";
742      }
743
744      popupHTML +=
745        '<div class="url-data">\
746                            <p class="link"><a class="button btn-button bg-red white arrow" href="' +
747        content.link +
748        '">' +
749        "En savoir +" +
750        "</a></p>\
751                        </div>\
752					</div>\
753				";
754
755      popup.setContent(popupHTML);
756      popup.update();
757
758      $(".thematique").css("top", $(".type").outerHeight() + "px");
759    });
760  }
761
762  function openPopupAjaxMedailles(popup, action, markerID, contentType) {
763    var data = {
764      action: action,
765      id: markerID,
766      annee: $("#current_year").val(),
767      lang: jsVars.lang,
768    };
769
770    $.post(jsVars.ajaxUrl, data, function (res) {
771      var content = res.data;
772      var medailles = content.medailles;
773      var medaillesDisplay =
774        '<div class="medailles-list"><div id="loader" class="spinner"></div><div class="items">';
775
776      $.each(medailles, function (k, v) {
777        medaillesDisplay +=
778          '<div class="item"><div class="inner-item"><div class="img-medaille ' +
779          v.couleur +
780          '"></div><h4 class="nom-produit">' +
781          v.nom_produit +
782          '</h4><div class="produit">' +
783          v.produit +
784          "</div></div></div>";
785      });
786      medaillesDisplay += "</div></div>";
787
788      var popupHTML =
789        '<div class="top">' +
790        '<div class="entreprise company-list-item">' +
791        "<div>" +
792        '<div class="title"><h2>' +
793        content.title +
794        "</h2></div>" +
795        '<div class="adresse">' +
796        content.adresse +
797        "</div>";
798
799      if (typeof content.email !== "undefined") {
800        popupHTML +=
801          '<div class="email"><a class="button btn-text black yellow-border" href="mailto:' +
802          content.email +
803          '">Envoyer un email</a></div>';
804      }
805
806      if (typeof content.site_internet !== "undefined") {
807        popupHTML +=
808          '<div class="site_web"><a class="button btn-text black yellow-border" href="' +
809          content.site_internet +
810          '" target="_blank">' +
811          content.site_internet +
812          "</a></div>";
813      }
814
815      popupHTML += medaillesDisplay;
816
817      popup.setContent(popupHTML);
818
819      popup.update();
820
821      if (medailles.length > 3) {
822        setTimeout(function () {
823          $(".entreprise-" + content.id + " .medailles-list .items").slick({
824            slidesToShow: 3,
825            slidesToScroll: 1,
826            arrows: true,
827            fade: false,
828            infinite: false,
829            autoplay: false,
830            dots: false,
831            responsive: [
832              {
833                breakpoint: 800,
834                settings: {
835                  slidesToShow: 1,
836                  slidesToScroll: 1,
837                  infinite: false,
838                },
839              },
840            ],
841          });
842          $(".entreprise-" + content.id + " .medailles-list").addClass(
843            "js-ready"
844          );
845        }, 2000);
846      } else {
847        $(".entreprise-" + content.id + " .medailles-list").addClass(
848          "js-ready not-slick"
849        );
850      }
851
852      $(".thematique").css("top", $(".type").outerHeight() + "px");
853    });
854  }
855
856  function openPopupAjaxFiche(popup, action, markerID, type = "producteur") {
857    var data = {
858      action: action,
859      id: markerID,
860      type: type,
861      lang: jsVars.lang,
862    };
863
864    $.post(jsVars.ajaxUrl, data, function (res) {
865      var content = res.data;
866
867      let contactEmail = "";
868      const contact = Object.keys(content.contactInfos).map(function (key) {
869        if (content.contactInfos[key] != "") {
870          if (key == "Mél") {
871            contactEmail = content.contactInfos[key];
872            return;
873          } else if (key.includes("URL")) {
874            return `<div class="contactItem">
875              <div class="contactTitle">${key}</div>
876              <div class="contactValue">
877                <a href="${content.contactInfos[key]}" target="_blank">${content.contactInfos[key]}</a>
878              </div>
879            </div>`;
880          } else {
881            return `<div class="contactItem">
882              <div class="contactTitle">${key}</div>
883              <div class="contactValue">${content.contactInfos[key]}</div>
884            </div>`;
885          }
886        }
887      });
888
889      const produits = Object.keys(content.produits).map(
890        (key) => `${content.produits[key]}`
891      );
892
893      var popupHTML = `
894        <div class="top">
895          ${
896            type == "producteur"
897              ? '<div class="popupImage"><img src="' +
898                jsVars.themeurl +
899                '/assets/img/svg/logo-balf.svg"></div>'
900              : ""
901          }
902
903          <div class="popupTitle"><h2>${content.title}</h2></div>
904
905          <div class="popupTypeDePoduit">${produits.join(", ")}</div>
906
907          <div class="popupAdresse">${content.adresse}</div>
908
909          <div class="popupContact">
910            ${contact.join("").replace("Mél", "Email")}
911          </div>
912
913          <div class="popupEmail">
914            <a class="button btn-button white arrow" href="${content.link}" target="_blank">
915              Voir la fiche
916              <svg xmlns="http://www.w3.org/2000/svg" width="23" height="10.917" viewBox="0 0 23 10.917">
917                <path data-name="icon flèche" d="M23,4.46C20.694,3.253,14.793.213,13.236,0c-.814.15-1.317.779-1.3,2.149-.121.143,2.025.885,2.89,1.26,1.849.641-1.762.532-2.1.562C8.149,3.95,4.641,4.4.187,3.979c.041,0-.626,2.809.333,2.755-.23-.012-.017,0-.179.08a89.023,89.023,0,0,0,10.173.245,42.822,42.822,0,0,1,4.962-.44c.277.063-1.768,1.38-2.155,1.966.142.111,1.379,2.941,1.23,2.213,1.891-.787,5.778-4.516,8.445-6.339" transform="translate(0 -0.001)" fill="#fff"></path>
918              </svg>
919            </a>
920          </div>
921        </div>
922      `;
923
924      popup.setContent(popupHTML);
925
926      popup.update();
927
928      $(".thematique").css("top", $(".type").outerHeight() + "px");
929    });
930  }
931})(jQuery);

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.