mirror of
https://github.com/netz39/www.netz39.de.git
synced 2025-01-19 04:20:10 +01:00
5 lines
No EOL
2.7 KiB
JavaScript
5 lines
No EOL
2.7 KiB
JavaScript
/* @preserve Cookie Consent Init */
|
|
function createCookie(e,t,o){var n="";if(o){var i=new Date;i.setTime(i.getTime()+24*o*60*60*1e3),n="; expires="+i.toUTCString()}document.cookie=`${e}=${t}${n}; path=/`}function readCookie(e){for(var t=e+"=",o=document.cookie.split(";"),n=0;n<o.length;n++){for(var i=o[n];" "===i.charAt(0);)i=i.substring(1,i.length);if(0===i.indexOf(t))return i.substring(t.length,i.length)}return null}function addCookieConsentListener(){document.getElementById("cookie-notice-accept").addEventListener("click",(function(){createCookie(cookieName,"true",31),document.getElementById("cookie-notice").style.display="none",location.reload()}))}function googleAnalytics(){if(""!==analyticsName.toLowerCase()){function e(){dataLayer.push(arguments)}window.dataLayer=window.dataLayer||[],e("js",new Date),e("config",analyticsName,{anonymize_ip:!0}),analyticsNameGA4&&e("config",analyticsNameGA4,{anonymize_ip:!0})}}"true"===isCookieConsent.toLowerCase()?(addCookieConsentListener(),"true"===readCookie(cookieName)?googleAnalytics():document.getElementById("cookie-notice").style.display="block"):googleAnalytics()
|
|
/* @preserve Dark mode Init */;const themeButton={light:'<i class="fas fa-adjust" aria-hidden="true"></i>',dark:'<i class="fas fa-adjust fa-rotate-180" aria-hidden="true"></i>'},currentTheme=()=>sessionStorage.getItem("theme");function setMode(e){document.documentElement.setAttribute("data-theme",e),sessionStorage.setItem("theme",e);const t=document.getElementById("theme-toggle");t&&(t.innerHTML=themeButton[e])}function themeToggle(){setMode("light"===currentTheme()?"dark":"light")}window.onload=function(){if(isAutoTheme){if(!currentTheme()){let e=window.matchMedia("(prefers-color-scheme: dark)");if(e.matches){sessionStorage.setItem("theme","dark");} e.addEventListener("change",(()=>{e.matches&&sessionStorage.setItem("theme","dark")}))}let e=currentTheme();setMode(e||"light")}}
|
|
/* @preserve Masonry Init */;try{var elem=document.querySelector(".grid"),msnry=new Masonry(elem,{itemSelector:".grid-item",columnWidth:".grid-sizer",gutter:".gutter-sizer",percentPosition:!0}),imgLoad=imagesLoaded(elem);imgLoad.on("progress",(function(e,t){msnry.layout()}))}catch(e){if(!(e instanceof ReferenceError))throw e}
|
|
/* @preserve Navbar */document.addEventListener("DOMContentLoaded",(function(e){const t=document.getElementById("pull"),o=document.querySelector("nav ul");["click","touch"].forEach((function(e){t?.addEventListener(e,(function(){o.classList.toggle("hide")}),!1)})),window.addEventListener("scroll",(function(){const e=-(window.scrollY||window.pageYOffset||document.body.scrollTop)/3,t=document.getElementById("main");t&&(t.style.backgroundPosition="100% "+(e-50)+"px, 0%, center top")}))})); |