PageSourceSearch

https://marchegare.fr/modules/supersoniks/js/supersoniks_views.js?v=1

js marchegare.fr collected 2026-09-26 02:35:00 UTC 2,750 bytes, 86 lines download raw bytes

1(function ($) {
2  Drupal.behaviors.supersoniks_views = {
3    attach: function (context, settings) {
4      initFilters(settings);
5    },
6  };
7
8  // CACHE LES OPTIONS qui n'ont pas de résultat dans la liste
9  function initFilters(settings) {
10    $(once("initSelectFilters", ".views-exposed-form")).each(function () {
11
12
13      // If target filter is a select
14      setSelectOptions('select', $(this), settings);
15
16      // if target filter is a Better Exposed Filters link
17      setBefLinkOptions('.bef-links', $(this), settings);
18    });
19
20  }
21
22  function setSelectOptions(selector, $form, settings) {
23    const userAgent = navigator.userAgent;
24    const isSafari =
25      userAgent.includes("Safari") && !userAgent.includes("Chrome");
26
27    $form.find(selector).each(function () {
28      const allowedData = getAllowedData($(this).attr("name"), settings);
29      if (allowedData) {
30        $(once("initOptions", $(this).children("option"))).each(function () {
31          if (!isNaN($(this).val()) && !allowedData[$(this).val()]) {
32            // Pas un remove car il peut y avoir un lien vers un filtre caché depuis le node
33            $(this).hide();
34            // Si c'est Safari, on retire l'option car le display: none ne fonctionne pas sur les options
35            if (isSafari) {
36              $(this).remove();
37            }
38          } else if (
39            isNaN($(this).val()) &&
40            $(this).val() !== "All" &&
41            !allowedData[$(this).val()]
42          ) {
43            $(this).remove();
44          }
45        });
46      }
47    });
48  }
49
50  function setBefLinkOptions(selector, $form, settings) {
51    $form.find(selector).each(function () {
52      const allowedData = getAllowedData($(this).attr("data-name"), settings);
53      if (allowedData) {
54        $(once("initBefLinkOptions", $(this).find(".bef-link"))).each(function () {
55          // Extract the id between square brackets, e.g., bef_cat[95] -> 95
56          let tid = $(this).attr("data-bef-value");
57          if (!tid) {
58            // LEGACY - If no tid, extract it from the name attribute
59            let nameAttr = $(this).attr("name");
60            const match = nameAttr && nameAttr.match(/\[(\d+)\]/);
61            if (match) {
62              tid = match[1];
63            }
64          }
65
66          tid = tid?.toLowerCase();
67          if (tid === 'all') return;
68
69          if (tid && !allowedData[tid]) {
70            if ($(this).parent()[0].tagName === "LI") {
71              $(this).parent().hide();
72            } else {
73              $(this).hide();
74            }
75          }
76        });
77      }
78    });
79  }
80
81  function getAllowedData(name, settings) {
82    return settings.filterOptions
83      ? settings.filterOptions[name]
84      : null;
85  }
86})(jQuery, Drupal, drupalSettings);

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.