PageSourceSearch

https://superumysl.eu/s/js/ruch.js?v=67c89fd8fa

js superumysl.eu collected 2026-10-09 23:59:43 UTC 12,679 bytes, 368 lines download raw bytes

1
2(function () {
3  'use strict';
4
5  var ograniczRuch = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
6
7  function belka() {
8    var pas = document.querySelector('.sxBelka');
9    if (!pas) return;
10    var guzik = pas.querySelector('.sxBelkaPrzelacz');
11    var menu  = guzik ? document.getElementById(guzik.getAttribute('aria-controls')) : null;
12    if (!guzik || !menu) return;
13
14    function ustaw(otwarte) {
15      if (otwarte) pas.setAttribute('data-sx-otwarte', '');
16      else pas.removeAttribute('data-sx-otwarte');
17      guzik.setAttribute('aria-expanded', otwarte ? 'true' : 'false');
18    }
19
20    guzik.addEventListener('click', function () {
21      ustaw(guzik.getAttribute('aria-expanded') !== 'true');
22    });
23
24    menu.addEventListener('click', function (zdarzenie) {
25      if (zdarzenie.target.closest('a')) ustaw(false);
26    });
27
28    document.addEventListener('keydown', function (zdarzenie) {
29      if (zdarzenie.key !== 'Escape') return;
30      if (guzik.getAttribute('aria-expanded') !== 'true') return;
31      ustaw(false);
32      guzik.focus();
33    });
34
35    var szeroko = window.matchMedia('(min-width: 75rem)');
36    var przy = function (m) { if (m.matches) ustaw(false); };
37    if (szeroko.addEventListener) szeroko.addEventListener('change', przy);
38    else if (szeroko.addListener) szeroko.addListener(przy);
39  }
40
41  function ujawnij() {
42    var elementy = document.querySelectorAll('.sxUjawnij');
43    if (!elementy.length) return;
44
45    if (ograniczRuch || !('IntersectionObserver' in window)) {
46      elementy.forEach(function (el) { el.setAttribute('data-sx-ujawnij', 'gotowe'); });
47      return;
48    }
49
50    elementy.forEach(function (el) { el.setAttribute('data-sx-ujawnij', ''); });
51
52    var wyzwalaczDziala = false;
53
54    var obserwator = new IntersectionObserver(function (wpisy) {
55      wyzwalaczDziala = true;
56      wpisy.forEach(function (wpis) {
57        if (!wpis.isIntersecting) return;
58        var el = wpis.target;
59        var zwloka = parseInt(el.getAttribute('data-sx-zwloka') || '0', 10);
60        window.setTimeout(function () {
61          el.setAttribute('data-sx-ujawnij', 'gotowe');
62        }, zwloka);
63        obserwator.unobserve(el);
64      });
65    }, { rootMargin: '0px 0px -12% 0px', threshold: 0.08 });
66
67    elementy.forEach(function (el) { obserwator.observe(el); });
68
69    var BEZPIECZNIK_MS = 4000;
70    var licznik = null;
71
72    var odpalBezpiecznik = function () {
73      if (licznik !== null) return;
74      licznik = window.setTimeout(function () {
75        if (wyzwalaczDziala) return;
76        elementy.forEach(function (el) {
77          el.setAttribute('data-sx-ujawnij', 'gotowe');
78        });
79        obserwator.disconnect();
80      }, BEZPIECZNIK_MS);
81    };
82
83    if (document.visibilityState === 'visible') {
84      odpalBezpiecznik();
85    } else {
86      document.addEventListener('visibilitychange', function przy() {
87        if (document.visibilityState !== 'visible') return;
88        document.removeEventListener('visibilitychange', przy);
89        odpalBezpiecznik();
90      });
91    }
92  }
93
94  function portrety() {
95    var wiersze = document.querySelectorAll('.sxPortret');
96    if (!wiersze.length) return;
97
98    wiersze.forEach(function (wiersz) {
99      var wlacz  = function () { wiersz.setAttribute('data-sx-portret', 'widoczny'); };
100      var wylacz = function () { wiersz.removeAttribute('data-sx-portret'); };
101
102      wiersz.addEventListener('mouseenter', wlacz);
103      wiersz.addEventListener('mouseleave', wylacz);
104      wiersz.addEventListener('focusin', wlacz);
105      wiersz.addEventListener('focusout', wylacz);
106    });
107  }
108
109  function karuzele() {
110    var tory = document.querySelectorAll('.sxKaruzela');
111    if (!tory.length) return;
112
113    tory.forEach(function (tor) {
114      var blok = tor.closest('.sx-blok');
115      var ster = blok ? blok.querySelector('.sxKaruzelaSter') : null;
116      if (!ster) return;
117
118      var STRZALKA_W_LEWO  = 'M15 5 L 8 12 L 15 19';
119      var STRZALKA_W_PRAWO = 'M9 5 L 16 12 L 9 19';
120
121      function zrobPrzycisk(nazwa, sciezka) {
122        var b = document.createElement('button');
123        b.type = 'button';
124        b.className = 'sx-karuzela__krok';
125        b.setAttribute('aria-label', nazwa);
126        b.innerHTML = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor"'
127                    + ' stroke-width="1.8" stroke-linecap="round"'
128                    + ' stroke-linejoin="round" aria-hidden="true">'
129                    + '<path d="' + sciezka + '"/></svg>';
130        return b;
131      }
132
133      var wstecz = zrobPrzycisk('Poprzednia opinia', STRZALKA_W_LEWO);
134      var naprzod = zrobPrzycisk('Następna opinia', STRZALKA_W_PRAWO);
135      ster.appendChild(wstecz);
136      ster.appendChild(naprzod);
137
138      function krok() {
139        var karta = tor.firstElementChild;
140        if (!karta) return tor.clientWidth;
141        var przerwa = parseFloat(getComputedStyle(tor).columnGap
141) || 0;
142        return karta.getBoundingClientRect().width + przerwa;
143      }
144
145      function odswiez() {
146        var maks = tor.scrollWidth - tor.clientWidth;
147        wstecz.disabled  = tor.scrollLeft <= 1;
148        naprzod.disabled = tor.scrollLeft >= maks - 1;
149      }
150
151      wstecz.addEventListener('click', function () {
152        tor.scrollBy({ left: -krok(), behavior: ograniczRuch ? 'auto' : 'smooth' });
153      });
154
155      naprzod.addEventListener('click', function () {
156        tor.scrollBy({ left: krok(), behavior: ograniczRuch ? 'auto' : 'smooth' });
157      });
158
159      tor.addEventListener('scroll', odswiez, { passive: true });
160      window.addEventListener('resize', odswiez);
161      odswiez();
162    });
163  }
164
165  var ADRES_ZAPISU = '/s/zapis.php';
166
167  function zapisy() {
168    var formularz = document.getElementById('sx-zapisy-formularz');
169    if (!formularz) return;
170
171    var mail       = document.getElementById('sx-zapisy-mail');
172    var zgoda      = document.getElementById('sx-zapisy-zgoda');
173    var wybor      = document.getElementById('sx-zapisy-modul');
174    var poleMail   = document.getElementById('sx-zapisy-pole-mail');
175    var poleZgoda  = document.getElementById('sx-zapisy-pole-zgoda');
176    var bladMail   = document.getElementById('sx-zapisy-blad-mail');
177    var bladZgoda  = document.getElementById('sx-zapisy-blad-zgoda');
178    var dziekujemy = document.getElementById('sx-zapisy-dziekujemy');
179    var echo       = document.getElementById('sx-zapisy-echo');
180    var newsletter = document.getElementById('sx-zapisy-newsletter');
181    var echoNews   = document.getElementById('sx-zapisy-dziekujemy-newsletter');
182
183    if (wybor) {
184      var pytanie = window.location.search;
185      var szukane = null;
186      pytanie.replace(/^\?/, '').split('&').forEach(function (para) {
187        var pol = para.split('=');
188        if (decodeURIComponent(pol[0]) === 'modul') {
189          szukane = decodeURIComponent((pol[1] || '').replace(/\+/g, ' '));
190        }
191      });
192      if (szukane) {
193        Array.prototype.forEach.call(wybor.options, function (poz) {
194          if (poz.value === szukane) wybor.value = szukane;
195        });
196      }
197    }
198
199    function pokazBlad(pole, blad, czy) {
200      if (blad) blad.hidden = !czy;
201      if (!pole) return;
202      if (czy) pole.setAttribute('data-sx-zle', '');
203      else pole.removeAttribute('data-sx-zle');
204    }
205
206    if (mail) {
207      mail.addEventListener('input', function () {
208        if (mail.checkValidity()) pokazBlad(poleMail, bladMail, false);
209      });
210    }
211    if (zgoda) {
212      zgoda.addEventListener('change', function () {
213        if (zgoda.checked) pokazBlad(poleZgoda, bladZgoda, false);
214      });
215    }
216
217    formularz.addEventListener('submit', function (zdarzenie) {
218      zdarzenie.preventDefault();
219
220      var mailZly  = !mail || !mail.value.trim() || !mail.checkValidity();
221      var zgodaZla = !zgoda || !zgoda.checked;
222
223      pokazBlad(poleMail, bladMail, mailZly);
224      pokazBlad(poleZgoda, bladZgoda, zgodaZla);
225
226      if (mailZly)  { mail.focus();  return; }
227      if (zgodaZla) { zgoda.focus(); return; }
228
229      if (!ADRES_ZAPISU) {
230        pokazBlad(poleZgoda, bladZgoda, false);
231        bladMail.hidden = false;
232        bladMail.textContent = 'Zapis nie jest jeszcze podłączony — '
233          + 'adres NIE został wysłany';
234        poleMail.setAttribute('data-sx-zle', '');
235        return;
236      }
237
238      var dane = new FormData(formularz);
239      window.fetch(ADRES_ZAPISU, { method: 'POST', body: dane })
240        .then(function (odpowiedz) {
241          if (!odpowiedz.ok) throw new Error('odmowa serwera');
242          udalo();
243        })
244        .catch(function () {
245          bladMail.hidden = false;
246          bladMail.textContent = 'Zapis się nie udał — spróbuj jeszcze raz';
247          poleMail.setAttribute('data-sx-zle', '');
248        });
249
250      function udalo() {
251        if (echo && mail) echo.textContent = mail.value.trim();
252        if (echoNews) echoNews.hidden = !(newsletter && newsletter.checked);
253        formularz.hidden = true;
254        document.querySelectorAll('.sxZapisyZFormularzem')
255          .forEach(function (el) { el.hidden = true; });
256        if (dziekujemy) dziekujemy.hidden = false;
257      }
258    });
259  }
260
261  function zapisStopka() {
262    var formularz = document.getElementById('sx-stopka-formularz');
263    if (!formularz) return;
264    var mail = document.getElementById('sx-stopka-mail');
265    var zgoda = document.getElementById('sx-stopka-zgoda');
266    var blad = document.getElementById('sx-stopka-blad');
267    var dziekujemy = document.getElementById('sx-stopka-dziekujemy');
268    var echo = document.getElementById('sx-stopka-echo');
269
270    function pokaz(tekst) {
271      blad.textContent = tekst;
272      blad.hidden = !tekst;
273    }
274
275    mail.addEventListener('input', function () { if (mail.checkValidity()) pokaz(''); });
276    zgoda.addEventListener('change', function () { if (zgoda.checked) pokaz(''); });
277
278    formularz.addEventListener('submit', function (zdarzenie) {
279      zdarzenie.preventDefault();
280      if (!mail.value.trim() || !mail.checkValidity()) {
281        pokaz('Wpisz adres e-mail, na który mamy pisać.');
282        mail.focus();
283        return;
284      }
285      if (!zgoda.checked) {
286        pokaz('Zaznacz zgodę — bez niej nie możemy wysyłać wiadomości.');
287        zgoda.focus();
288        return;
289      }
290      window.fetch(ADRES_ZAPISU, { method: 'POST', body: new FormData(formularz) })
291        .then(function (odpowiedz) {
292          if (!odpowiedz.ok) throw new Error('odmowa serwera');
293          if (echo) echo.textContent = mail.value.trim();
294          formularz.hidden = true;
295          dziekujemy.hidden = false;
296        })
297        .catch(function () {
298          pokaz('Zapis się nie udał — spróbuj jeszcze raz.');
299        });
300    });
301  }
302
303  function pasekOgloszen() {
304    var pasek = document.querySelector('.sx-hero__pasek');
305    if (!pasek) return;
306    var PROG = 80;
307
308    function sprawdz() {
309      if (window.scrollY > PROG) pasek.setAttribute('data-sx-schowany', '');
310      else pasek.removeAttribute('data-sx-schowany');
311    }
312
313    window.addEventListener('scroll', sprawdz, { passive: true });
314    sprawdz();
315  }
316
317  function zwijanie() {
318    var bloki = document.querySelectorAll('.sx-zwin');
319    if (!bloki.length || !window.matchMedia) return;
320    var waski = window.matchMedia('(max-width: 54rem)');
321
322    function ustaw() {
323      Array.prototype.forEach.call(bloki, function (blok) {
324        if (blok.hasAttribute('data-sx-rozwiniete')) return;
325        if (!waski.matches) { blok.removeAttribute('data-sx-zwin'); return; }
326        blok.setAttribute('data-sx-zwin', 'zwiniete');
327        var tresc = blok.querySelector('.sx-zwin__tresc');
328        if (tresc && tresc.scrollHeight <= tresc.clientHeight + 4) {
329          blok.removeAttribute('data-sx-zwin');
330        }
331      });
332    }
333
334    Array.prototype.forEach.call(bloki, function (blok) {
335      var guzik = blok.querySelector('.sx-zwin__przycisk');
336      var tresc = blok.querySelector('.sx-zwin__tresc');
337      if (!guzik || !tresc) return;
338      guzik.addEventListener('click', function () {
339        blok.setAttribute('data-sx-rozwiniete', '');
340        blok.removeAttribute('data-sx-zwin');
341        guzik.setAttribute('aria-expanded', 'true');
342        tresc.setAttribute('tabindex', '-1');
343        tresc.focus({ preventScroll: true });
344      });
345    });
346
347    if (waski.addEventListener) waski.addEventListener('change', ustaw);
348    else if (waski.addListener) waski.addListener(ustaw);
349    ustaw();
350  }
351
352  function start() {
353    belka();
354    ujawnij();
355    portrety();
356    karuzele();
357    zapisy();
358    zapisStopka();
359    pasekOgloszen();
360    zwijanie();
361  }
362
363  if (document.readyState === 'loading') {
364    document.addEventListener('DOMContentLoaded', start);
365  } else {
366    start();
367  }
368})();

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.