PageSourceSearch

https://aurora-pack.ru/local/templates/aurora/js/catalog-filter.js?17852435502221

js aurora-pack.ru collected 2026-10-04 13:26:19 UTC 2,221 bytes, 68 lines download raw bytes

1(function () {
2  function attach(form) {
3    if (form.dataset.cfBound) return;
4    form.dataset.cfBound = '1';
5
6    var url = form.dataset.countUrl || '/local/ajax/catalog_count.php';
7    var section = form.dataset.section || '';
8    var countEl = form.querySelector('[data-cf-count]');
9    var timer;
10
11    function buildParams() {
12      var p = new URLSearchParams();
13      form.querySelectorAll('input[type="checkbox"]').forEach(function (cb) {
14        if (cb.checked && cb.name) p.append(cb.name, cb.value);
15      });
16      if (section) p.set('section', section);
17      return p;
18    }
19
20    function refresh() {
21      if (countEl) countEl.classList.add('is-loading');
22      fetch(url + '?' + buildParams().toString(), { headers: { 'X-Requested-With': 'fetch' } })
23        .then(function (r) { return r.json(); })
24        .then(function (d) {
25          if (countEl) {
26            countEl.textContent = (d && typeof d.count === 'number') ? plural(d.count) : '';
27            countEl.classList.remove('is-loading');
28          }
29        })
30        .catch(function () { if (countEl) countEl.classList.remove('is-loading'); });
31    }
32
33    var resetBtn = form.querySelector('[data-cf-reset]');
34    if (resetBtn) {
35      resetBtn.addEventListener('click', function (e) {
36        e.preventDefault();
37        form.querySelectorAll('input[type="checkbox"]').forEach(function (cb) { cb.checked = false; });
38        if (location.search) { location.href = location.pathname; return; }
39        refresh();
40      });
41    }
42
43    form.addEventListener('change', function (e) {
44      if (e.target.matches('input[type="checkbox"]')) {
45        clearTimeout(timer);
46        timer = setTimeout(refresh, 120);
47      }
48    });
49
50    refresh();
51  }
52
53  function plural(n) {
54    var a = Math.abs(n) % 100, b = a % 10, w;
55    if (a > 10 && a < 20) w = 'товаров';
56    else if (b > 1 && b < 5) w = 'товара';
57    else if (b === 1) w = 'товар';
58    else w = 'товаров';
59    return n + ' ' + w;
60  }
61
62  function boot() {
63    document.querySelectorAll('form.catalog-filter, form#catalog-filter').forEach(attach);
64  }
65
66  if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', boot);
67  else boot();
68})();

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.