templates/frontend-eforum/_partials/modules/wcag/wcagInitalScript.html.twig line 1

Open in your IDE?
  1. <script>
  2.     function wcagGetCookie(name) {
  3.         let nameEQ = name + "=";
  4.         let ca = document.cookie.split(';');
  5.         for(let i=0; i < ca.length; i++) {
  6.             let c = ca[i];
  7.             while (c.charAt(0)==' ') c = c.substring(1,c.length);
  8.             if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  9.         }
  10.         return null;
  11.     }
  12.     function wcagApplyInitialState() {
  13.         var fontSizes = ['fsize70','fsize80','fsize90','fsize100','fsize110','fsize120','fsize130'];
  14.         var fontSizeCookie = wcagGetCookie('jm-font-size');
  15.         document.documentElement.classList.remove(...fontSizes);
  16.         if (fontSizeCookie) {
  17.             var count = parseInt(fontSizeCookie, 10);
  18.             if (fontSizes.includes('fsize' + count)) {
  19.                 document.documentElement.classList.add('fsize' + count);
  20.             }
  21.         }
  22.         var contrastClasses = ['night', 'highcontrast', 'highcontrast2', 'highcontrast3'];
  23.         var contrastCookie = wcagGetCookie('contrast');
  24.         document.documentElement.classList.remove(...contrastClasses);
  25.         if (contrastCookie && contrastClasses.includes(contrastCookie)) {
  26.             document.documentElement.classList.add(contrastCookie);
  27.         }
  28.     }
  29.     document.addEventListener('DOMContentLoaded', wcagApplyInitialState);
  30. </script>