PageSourceSearch

https://listwy-kaztor.pl/moduly_stale/wcag/wcag.js

js listwy-kaztor.pl collected 2026-10-08 07:12:28 UTC 13,969 bytes, 554 lines download raw bytes

1function getCookieWcag(name) {
2    //
3    const re = new RegExp('(?:^|; )' + name.replace(/([.$?*|{}()[\]\\/+^])/g, '\\$1') + '=([^;]*)');
4    const match = document.cookie.match(re);
5    return match ? decodeURIComponent(match[1]) : null;
6    //
7}
8
9// tryb adhd
10if (getCookieWcag('wcagc') === '2') {
11    //
12    const stripeH = 120;
13
14    const topMask = document.createElement('div');
15    topMask.id = 'overlay-top';
16    topMask.className = 'overlay';
17    document.body.appendChild(topMask);
18
19    const bottomMask = document.createElement('div');
20    bottomMask.id = 'overlay-bottom';
21    bottomMask.className = 'overlay';
22    document.body.appendChild(bottomMask);
23
24    const adhdGrabber = document.createElement('div');
25    adhdGrabber.id = 'adhd-bar-grabber';
26    adhdGrabber.style.height = stripeH + 'px';
27    adhdGrabber.style.top = '0px'; // tymczasowo
28    document.body.appendChild(adhdGrabber);
29
30    function moveStripe(posY) {
31        const yStart = Math.max(0, posY - stripeH / 2);
32        const yEnd   = Math.min(window.innerHeight, yStart + stripeH);
33
34        topMask.style.height = yStart + 'px';
35        bottomMask.style.top = yEnd + 'px';
36        bottomMask.style.height = (window.innerHeight - yEnd) + 'px';
37        adhdGrabber.style.top = yStart + 'px';
38    }
39
40    moveStripe(window.innerHeight / 2);
41
42    document.addEventListener('mousemove', e => {
43        moveStripe(e.clientY);
44    });
45
46    let movingAdhdStripe = false;
47
48    adhdGrabber.addEventListener('touchstart', function(e) {
49        movingAdhdStripe = true;
50    }, { passive: false });
51
52    adhdGrabber.addEventListener('touchmove', function(e) {
53        if (!movingAdhdStripe) return;
54        if (!e.touches || !e.touches.length) return;
55        e.preventDefault();
56        const touch = e.touches[0];
57        moveStripe(touch.clientY);
58    }, { passive: false });
59
60    document.addEventListener('touchend', function(e) {
61        movingAdhdStripe = false;
62    }, { passive: false });
63
64    window.addEventListener('resize', () => {
65        moveStripe(window.innerHeight / 2);
66    });
67
68}
69
70// wylaczenie animacji
71if (getCookieWcag('wcaga') === '1') {
72    //
73    document.documentElement.classList.add('reduce-motion');
74    //
75    jQuery(function($){
76      $('.slick-slider').each(function(){
77        $(this).slick('slickPause');
78      });
79    });   
80    //
81}
82
83if (getCookieWcag('wcagle') === '1') {
84
85    function wrapInlineBlocks(container) {
86      let node = container.firstChild;
87      let wrapper = null;
88
89      while (node) {
90        const next = node.nextSibling;
91
92        if (
93          node.nodeType === 1 &&
94          (node.tagName === 'BR' || /^H[1-6]$/.test(node.tagName))
95        ) {
96          wrapper = null;
97          if (node.tagName === 'BR') {
98            node.remove();
99          }
100        }
101
102        else if (node.nodeType === 3 && !node.nodeValue.trim()) {
103          node.remove();
104        }
105
106        else {
107          if (!wrapper) {
108
109            wrapper = document.createElement('div');
110            wrapper.className = 'CzytanieHover';
111            container.insertBefore(wrapper, node);
112          }
113
114          wrapper.appendChild(node);
115        }
116
117        node = next;
118      }
119    }
120
121    document.querySelectorAll('.FormatEdytor > div:not(.CzytanieHover)').forEach(wrapInlineBlocks);
122
123    (function(){
124      
125      if (!('speechSynthesis' in window)) return;
126
127      const synth = window.speechSynthesis;
128      let voices = [], selectedVoice = null;
129
130      function loadVoices() {
131        voices = synth.getVoices();
132        selectedVoice =
133          voices.find(v => v.lang.startsWith('pl')) ||
134          voices.find(v => /polski/i.test(v.name)) ||
135          voices[0];
136      }
137      synth.onvoiceschanged = loadVoices;
138      loadVoices();
139
140      function speakText(txt, readEl) {
141        if (readEl && readEl.tagName !== 'A') {
142          readEl._prevCursor = readEl.style.cursor;
143          readEl.style.cursor = 'help';
144        }
145        if (!selectedVoice) return;
146        const u = new SpeechSynthesisUtterance(txt);
147        u.voice = selectedVoice;
148        u.lang  = selectedVoice?.lang || 'pl-PL';
149        synth.cancel();
150        synth.speak(u);
151      }
152
153      function handleMouseOver(e) {
154        let el = e.target; 
155
156        // specjalnie dla IMG: czytaj tylko alt/aria-label/title!
157        if (el.tagName === 'IMG') {
158          let txt = el.getAttribute('aria-label')?.trim() || el.alt?.trim() || el.title?.trim();
159          if (!txt) return;
160          speakText(txt, el);
161          return;
162        }
163
164        const link = el.closest('a');
165        if (link) el = link;
166
167        const allowed = 'p,li,h1,h2,h3,h4,h5,h6,a,button,td,span,em,div,summary,small,strong,b,label,input,select';
168        if (!el.matches(allowed) && !el.closest(allowed)) return;
169        let readEl = el.matches(allowed) ? el : el.closest(allowed);
170
171        const st = getComputedStyle(readEl);
172        if (st.display === 'none' || st.visibility === 'hidden' || +st.opacity === 0) return;
173
174        // SELECT tylko jesli aria-label
175        if (readEl.tagName === 'SELECT') {
176          let label = readEl.getAttribute('aria-label');
177          if (!label || !label.trim()) return;
178        }
179
180        // odrzuc elementy bez tekstu (poza a, label, input, select, img)
181        if (
182          readEl.tagName !== 'A' &&
183          readEl.tagName !== 'LABEL' &&
184          readEl.tagName !== 'INPUT' &&
185          readEl.tagName !== 'SELECT' &&
186          readEl.tagName !== 'IMG'
187        ) {
188          if (!readEl.getAttribute('aria-label')) {
189            const hasTextNode = Array.from(readEl.childNodes).some(n =>
190              n.nodeType === Node.TEXT_NODE && n.nodeValue.trim().length > 0
191            );
192            if (!hasTextNode) return;
193          }
194        }
195
196        // pobierz tekst: aria-label > data-hover > input/textarea/button value > IMG alt > textContent > title
197        let txt =
198          readEl.getAttribute('aria-label')?.trim()
199          || readEl.getAttribute('data-hover')?.trim()
200          || (readEl.matches('input,textarea,button') && (readEl.value || readEl.textContent)?.trim())
201          || (readEl.tagName === 'IMG' && (readEl.alt || '').trim())
202          || readEl.textContent.trim()
203          || (readEl.title || '').trim();
204
205        if (!txt) return;
206
207        // zmien kursor (tylko nie dla <a>)
208        if (readEl.tagName !== 'A') {
209          readEl._prevCursor = readEl.style.cursor;
210          readEl.style.cursor = 'help';
211        }
212
213        speakText(txt, readEl);
214      }
215
216      function handleMouseOut(e) {
217        const el = e.target;
218        if (el._prevCursor !== undefined) {
219          el.style.cursor = el._prevCursor;
220          delete el._prevCursor;
221        }
222        synth.cancel();
223      }
224
225      document.body.addEventListener('mouseover', handleMouseOver);
226      document.body.addEventListener('mouseout',  handleMouseOut);
227      
228      document.body.addEventListener('touchstart', handleMouseOver, {passive: true});
229      document.body.addEventListener('touchend', handleMouseOut, {passive: true});
230      
231      document.body.addEventListener('click', handleMouseOver);
232      document.body.addEventListener('click', handleMouseOut);
233
234    })();
235
236}
237
238$(document).on('keydown', function(e) {
239    if (e.key === 'Escape' || e.keyCode === 27) {
240        $('.PasekDostepnosci').hide();
241        usunCookie('wcag');
242    }
243}); 
244function WlaczOknoDostepnosci() {
245    //
246    $('.PasekDostepnosci').show();
247    ustawCookie('wcag','1',30);
248    //   
249}
250function WylaczOknoDostepnosci() {
251    //
252    $('.PasekDostepnosci').hide();
253    usunCookie('wcag');
254    //
255}
256
257function ResetOknoDostepnosci() {
258    //
259    const allCookies = document.cookie.split('; ');
260    //
261    allCookies.forEach(cookie => {
262      const [name] = cookie.split('=');  
263      if (name.startsWith('wca')) { 
264        document.cookie = name + '=; expires=' + new Date(0).toUTCString() + '; path=/';  
265      }
266    });    
267    //
268    ustawCookie('wcag','1',30);
269    window.location.reload();
270    //
271}
272
273function KontrastSvgTlo() {
274    //
275    $('*').each(function () {
276      //
277      const el = this;
278      const $el = $(el);
279      //
280      if (
281        $el.closest('.PortaleSpolecznoscioweIkony').length > 0 ||
282        $el.is('#KlasaEnergetyczna') ||
283        $el.closest('#KlasaEnergetyczna').length > 0 ||
284        $el.hasClass('DoKoszyka') ||
285        $el.hasClass('przycisk') ||
286        $el.hasClass('DoKoszykaKartaProduktu')
287      ) {
288        return;
289      }
290      //
291      const bg = getComputedStyle(el).getPropertyValue('background-image');
292      let beforeBg = '';
293      try {
294        beforeBg = getComputedStyle(el, '::before').getPropertyValue('background-image');
295      } catch (e) {}
296
297      const hasSvg = (bg && bg.includes('.svg')) || (beforeBg && beforeBg.includes('.svg'));
298
299      if (hasSvg) {
300          //
301          if (
302            !$el.hasClass('OdwroconyInvert') &&
303            $el.parents('.OdwroconyInvert').length === 0
304          ) {
305            $el.addClass('OdwroconyInvert OdwroconyFiltr');
306          }
307          //
308      } else {
309          //
310          if ($el.hasClass('OdwroconyInvert') && $el.parents('.OdwroconyInvert').length === 0) {
311            $el.removeClass('OdwroconyInvert OdwroconyFiltr');
312          }
313          //
314      }
315      //
316    });
317    //
318}
319
320function UstawKontrast() {
321    //
322    ustawCookie('wcagk','1',30);  
323    $('body').addClass('Kontrast');
324    //
325    $(function () {
326        //
327        if ($('body').hasClass('Kontrast')) {
328            KontrastSvgTlo();
329        }
330        //
331    });
332    //
333    let resizeTimer;
334    //
335    $(window).on('resize', function () {
336        //
337        if ($('body').hasClass('Kontrast')) {
338          clearTimeout(resizeTimer);
339
340          resizeTimer = setTimeout(function () {
341            KontrastSvgTlo(); 
342          }, 300); 
343        }
344        //
345    });
346    
347}
348    
349function zmianaKontrastu(kontrast) {
350  if ( parseInt(kontrast) == 0 ) {
351       //
352       usunCookie('wcagk');
353       window.location.reload();
354       //
355  }
356  if ( parseInt(kontrast) == 1 ) {
357       //
358       ustawCookie('wcagk','1',30);
359       window.location.reload();
360       //
361  }
362}
363
364function rozmiarFont(rozmiar) {
365    //
366    ustawCookie('wcagf',rozmiar,30);
367    window.location.reload();
368    //
369}
370
371function rozmiarInterlinia(rozmiar) {
372    //
373    ustawCookie('wcagl',rozmiar,30);
374    window.location.reload();
375    //
376}
377
378function rozmiarOdstepliter(rozmiar) {
379    //
380    ustawCookie('wcago',rozmiar,30);
381    window.location.reload();
382    //
383}
384
385function rozmiarKursor(rozmiar) {
386    //
387    ustawCookie('wcagc',rozmiar,30);
388    window.location.reload();
389    //
390}
391
392function zmianaSzarosci(tryb) {
393    //
394    ustawCookie('wcags',tryb,30);
395    window.location.reload();
396    //
397}
398
399function zmianaObrazki(tryb) {
400    //
401    ustawCookie('wcagi',tryb,30);
402    window.location.reload();
403    //
404}
405
406function zmianaRodzajuCzcionki(tryb) {
407    //
408    ustawCookie('wcagcz',tryb,30);
409    window.location.reload();
410    //
411}
412
413function zmianaAnimacji(tryb) {
414    //
415    ustawCookie('wcaga',tryb,30);
416    window.location.reload();
417    //
418}
419
420function zmianaWyrownanieTekstu(tryb) {
421    //
422    ustawCookie('wcagw',tryb,30);
423    window.location.reload();
424    //
425}
426
427function zmianaNasycenie(tryb) {
428    //
429    ustawCookie('wcagn',tryb,30);
430    window.location.reload();
431    //
432}
433
434function zmianaOdnosniki(tryb) {
435    //
436    ustawCookie('wcagod',tryb,30);
437    window.location.reload();
438    //
439}
440
441function zmianaCzytnikEkranu(tryb) {
442    //
443    ustawCookie('wcagle',tryb,30);
444    window.location.reload();
445    //
446}
447
448// restet funkcji
449function aktualizujStickyMenu() {
450    //
451    return
452    //
453}
454
455// sprawdzanie polozenia ikonki dostepnosci
456$(function(){
457  
458    var $icon     = $('.IkonaDostepnosci');
459    var iconEl    = $icon[0];
460
461    var origBottomRaw = window.getComputedStyle(iconEl).getPropertyValue('bottom');
462    var origBottom    = parseFloat(origBottomRaw) || 0;
463    var offset        = 60;  // o ile px podnosimy ikonę
464
465    function shouldLiftIcon(){
466      
467        var sticky = document.querySelector('.MenuSticky') !== null;
468
469        var header = document.querySelector('.MenuStickyAnimacja');
470        if (!header) return false;
471        var bottom = window.getComputedStyle(header).getPropertyValue('bottom');
472        return sticky && bottom.trim() === '0px';
473      
474    }
475
476    function adjustIcon(){
477      
478        if ( shouldLiftIcon() ){
479          
480            $icon.css({
481              bottom: (origBottom + offset) + 'px',
482            });
483          
484        } else {
485          
486            $icon.css({
487              bottom: origBottom + 'px',
488              zIndex: ''
489            });
490          
491        }
492      
493    }
494
495    var ticking = false;
496    
497    function onScrollOrResize(){
498      
499        if (!ticking){
500          
501            window.requestAnimationFrame(function(){
502              adjustIcon();
503              ticking = false;
504            });
505            ticking = true;
506            
507        }
508      
509    }
510
511    var headerEl = document.querySelector('.MenuStickyAnimacja');
512    
513    if (headerEl){
514      new MutationObserver(onScrollOrResize)
515        .observe(headerEl, { attributes: true, attributeFilter: ['class'] });
516    }
517
518    adjustIcon();
519    $(window).on('scroll resize', onScrollOrResize);
520    
521});
522
523/* przywrocenie oryginalnych kolorow dla klasy energetycznej */
524
525(function(){
526
527  setTimeout(() => {
528
529    if (!document.body.classList.contains('Kontrast')) {
530      return;
531    }
532
533    if (!document.querySelector('.KlasaEnergetyczna')) {
534      return;
535    }
536
537    const items = Array.from(document.querySelectorAll('[class*="KlasaEnergetyczna-"]'));
538
539    document.body.classList.remove('Kontrast');
540
541    requestAnimationFrame(() => {
542      items.forEach(el => {
543        const bg = getComputedStyle(el).backgroundColor;
544        el.style.setProperty('background-color',  bg, 'important');
545        el.style.setProperty('border-left-color', bg, 'important');
546      });
547
548      document.body.classList.add('Kontrast');
549    });
550
551  }, 500);
552})();
553
554

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.