const gaId = 'G-PG44K22BMW'; const getCookieValue = (cookieName) => { const cookies = document.cookie; if (!cookies) return null; const cookiesArray = cookies.split(';').map(cookie => cookie.trim()); const cookieRegex = new RegExp(`^${cookieName}=`); const cookie = cookiesArray.find(cookie => cookieRegex.test(cookie)); if (cookie) { return decodeURIComponent(cookie.substring(cookieName.length + 1)); } return null; } const setCookie = (name, value, days) => { const expirationDate = new Date(); expirationDate.setDate(expirationDate.getDate() + days); const encodedValue = encodeURIComponent(value); let cookieString = `${name}=${encodedValue}; expires=${expirationDate.toUTCString()}; path=/`; if (window.location.protocol === 'https:') { cookieString += '; Secure'; } cookieString += '; SameSite=Lax'; document.cookie = cookieString; } const deleteCookie = (prefix) => { const cookies = document.cookie.split(';'); const domain = window.location.hostname; const possiblePaths = ['/', '/path', '']; const possibleDomains = [domain, `.${domain}`, '']; cookies.forEach(cookie => { const [name, ] = cookie.trim().split('='); if (name.startsWith(prefix)) { possiblePaths.forEach(path => { possibleDomains.forEach(dom => { document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=${path}; domain=${dom}; max-age=-99999999;`; document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=${path}; domain=${dom}; max-age=-99999999; Secure; SameSite=None;`; document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=${path}; domain=${dom}; max-age=-99999999; Secure; SameSite=Lax;`; }); }); } }); }; const addPaddingToFooter = () => { const footer = document.querySelector('footer'); const cookiesBox = document.querySelector('.cookies'); const footerBottomPadding = cookiesBox.clientHeight + 10; footer.setAttribute('style', `padding-bottom: ${footerBottomPadding}px`); } const removePaddingFromFooter = () => document.querySelector('footer').removeAttribute('style'); const enableAnalytics = () => { document.querySelector('#analyticsCookies').setAttribute('checked', 'checked'); const script = document.createElement('script'); script.src = `https://www.googletagmanager.com/gtag/js?id=${gaId}`; document.head.appendChild(script); setTimeout(() => { window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('consent', 'default', { 'ad_user_data': 'denied', 'ad_personalization': 'denied', 'ad_storage': 'denied', 'analytics_storage': 'granted', 'wait_for_update': 500, }); gtag('js', new Date()); gtag('config', gaId); }, 1000); } function googleTranslateElementInit() { new google.translate.TranslateElement({ pageLanguage: 'pl', layout: google.translate.TranslateElement.InlineLayout.SIMPLE, autoDisplay: false }, 'google_translate_element'); } const enableFunctional = () => { document.querySelector('#functionalCookies').setAttribute('checked', 'checked'); document.querySelector('#disabilities').innerHTML += `| `; const script = document.createElement('script'); script.src = `https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit`; document.head.appendChild(script); } window.addEventListener('load', function() { if (getCookieValue('cookies-reviewed') === 'T') { if (getCookieValue('analytics-accepted') === 'T') { enableAnalytics(); } if (getCookieValue('functional-accepted') === 'T') { enableFunctional(); } } else { document.querySelector('.cookies').hidden = false; addPaddingToFooter(); } document.querySelectorAll('.accept-cookies').forEach(el => el.addEventListener('click', () => { setCookie('cookies-reviewed', 'T', 365); setCookie('analytics-accepted', 'T', 365); setCookie('functional-accepted', 'T', 365); location.reload(); })); document.querySelectorAll('.disable-cookies').forEach(el => el.addEventListener('click', () => { setCookie('cookies-reviewed', 'T', 365); deleteCookie('_ga'); deleteCookie('analytics-accepted'); deleteCookie('functional-accepted'); location.reload(); })); document.querySelectorAll('.open-cookies-settings').forEach(el => el.addEventListener('click', () => { openCookiesSettings(); })); const openCookiesSettings = () => { const dialog = new A11yDialog(document.querySelector('#cookies-settings')); dialog.on('show', () => (document.documentElement.style.overflowY = 'hidden')).on('hide', () => (document.documentElement.style.overflowY = '')); dialog.show(); } document.querySelector('.save-cookies-settings').addEventListener('click', () => { setCookie('cookies-reviewed', 'T', 365); if (document.querySelector('#analyticsCookies').checked) { setCookie('analytics-accepted', 'T', 365); enableAnalytics(); } else { deleteCookie('_ga'); deleteCookie('analytics-accepted'); } if (document.querySelector('#functionalCookies').checked) { setCookie('functional-accepted', 'T', 365); enableFunctional(); } else { deleteCookie('functional-accepted'); } location.reload(); }); }); jQuery(document).ready(function() { disabilities(); var wapoMainWindowWidth = $(window).width(); $(".sf-menu ul li").mouseover(function() { // checks if third level menu exist var subMenuExist = $(this).find(".dropdown").length; if (subMenuExist > 0) { var subMenuWidth = $(this) .find(".dropdown") .width(); var subMenuOffset = $(this) .find(".dropdown") .parent() .offset().left + subMenuWidth; // if sub menu is off screen, give new position if (subMenuOffset + subMenuWidth > wapoMainWindowWidth) { var newSubMenuPosition = subMenuWidth + 3; $(this) .find(".dropdown") .css({ left: -newSubMenuPosition, top: "0" }); } } }); enquire.register("screen and (min-width: 768px)", function() { $(".sf-menu").superfish(); }); enquire.register("screen and (max-width: 992px)", function() { $(".position-side-left") .detach() .insertAfter(".content"); }); enquire.register("screen and (min-width: 992px)", function() { $(".position-side-left") .detach() .insertBefore(".content"); }); }); $(window).bind("load", function() { if(getCookieValue('return') !== 'T') { setCookie('return', 'T', 1); $.ajax({url: "//" + window.location.hostname + "/addviewer"}) } $(".go-to-search").click(function() { $("#search-input").focus(); }); $(".sf-menu li a").focusin(function() { $(this) .parent("li") .addClass("focused"); }); $(".sf-menu li a").focusout(function() { $(this) .parent("li") .removeClass("focused"); }); var $container = $(".masonry"); $container.imagesLoaded(function() { $container.masonry(); }); $.each($(".addon-box .sf-menu li a"), function(index, value) { if ($(this).attr("href") == window.location.pathname) { $(this).css("text-decoration", "underline"); $(this).css("font-weight", "bold"); $(this) .parent() .parent() .css("display", "block"); $(this) .parent() .parent() .parent() .parent() .css("display", "block"); $(this) .parent("li") .children("ul") .css("display", "block"); $(this) .parent("li") .children("ul li ul") .css("display", "block"); } }); if (document.querySelector('.lightbox')) { new Tobii({ //captionsSelector: 'self', //captionAttribute: 'title', navLabel: ['Poprzednie zdjęcie', 'Następne zdjęcie'], closeLabel: 'Zamknij galerię', }); } const getFilesize = (url, callback) => { const xhr = new XMLHttpRequest(); xhr.open("HEAD", url, true); xhr.onreadystatechange = () => { if (xhr.readyState === XMLHttpRequest.DONE) { const status = xhr.status; if (status === 0 || (status >= 200 && status < 400)) { callback(parseInt(xhr.getResponseHeader("Content-Length"))); } } }; xhr.send(); } document.querySelectorAll('.attachments_list-item-title').forEach(el => { getFilesize(el.href, (size) => { const parent = el.parentElement; parent.querySelector('.attachments_list-item-type').innerHTML = el.href.split(".").pop().toUpperCase(); parent.querySelector('.attachments_list-item-size').innerHTML = `${(size / (1024 * 1024)).toFixed(2)}MB`; }); }); if (document.querySelector('#popup') && !WHReadCookie('interPop')) { const dialog = new A11yDialog(document.querySelector('#popup')); WHCreateCookie('interPop', 'popup', 1); dialog.on('show', () => (document.documentElement.style.overflowY = 'hidden')).on('hide', () => (document.documentElement.style.overflowY = '')); dialog.show(); } }); function WHCreateCookie(name, value, days) { var now = new Date(); var expire = new Date(); expire.setFullYear(now.getFullYear()); expire.setMonth(now.getMonth()); expire.setDate(now.getDate() + days); expire.setHours(0); expire.setMinutes(0); document.cookie = name + "=" + value + "; expires=" + expire.toString() + "; path=/"; } function WHReadCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(";"); for (var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == " ") c = c.substring(1, c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); } return null; } const updateCalendar = (curmonth, curyear) => { const eventscalendar = document.getElementById('eventscalendar'); $.ajax({ url: "//" + window.location.hostname + "/eventsajax?month=" + curmonth + "&year=" + curyear }).done(function (data) { eventscalendar.innerHTML = data; }); } function getSlidePauseTime() { // if( $('.slider-wrapper span').length > 1 ) { return 4000; // } else { // return 9999999999999; // } } function disabilities() { // $('body .go-to-content:eq(1)').after(createDisabilitiesContainer()); makeContrast(); makeFont(); $("body").css("background-position", "center 28px"); $("body").css("padding-top", "28px"); $(".bg-top").css("top", "28px"); $(".header-bg").css("background-position", "center 28px"); } function createDisabilitiesContainer() { return ( '
' + 'Rozmiar czcionek: AA+A++' + '|' + '' + contrastTypeText() + "" + "
" ); } function makeContrast() { if (isContrastSet()) { $("body").addClass("contrast"); $("head").append( '' ); } } function isContrastSet() { if (WHReadCookie("contrast") != null) { return true; } return false; } function contrastTypeText() { if (isContrastSet()) { return "Ustaw standardowy kontrast"; } return "Zwiększ kontrast"; } $(document).on("click", "#contrast", function(e) { e.preventDefault(); if (isContrastSet()) { document.cookie = "contrast" + "=;expires=Thu, 01 Jan 1970 00:00:01 GMT;"; location.reload(); } else { WHCreateCookie("contrast", "T", 365); location.reload(); } }); function makeFont() { if (isFontSet()) { $("body").addClass("font" + WHReadCookie("font")); $("head").append( '' ); } } function isFontSet() { if (WHReadCookie("font") != null) { return true; } return false; } $(document).on("click", "#fonta", function(e) { e.preventDefault(); document.cookie = "font" + "=;expires=Thu, 01 Jan 1970 00:00:01 GMT; path=/"; location.reload(); }); $(document).on("click", "#fontaa", function(e) { e.preventDefault(); document.cookie = "font" + "=;expires=Thu, 01 Jan 1970 00:00:01 GMT; path=/"; WHCreateCookie("font", "aa", 365); location.reload(); }); $(document).on("click", "#fontaaa", function(e) { e.preventDefault(); document.cookie = "font" + "=;expires=Thu, 01 Jan 1970 00:00:01 GMT; path=/"; WHCreateCookie("font", "aaa", 365); location.reload(); });