// --------------------------------------------- // cookie handling // --------------------------------------------- function boostiumSetCookie(cname, value, days) { const d = new Date(); d.setTime(d.getTime() + (days * 24 * 60 * 60 * 1000)); let expires = "expires=" + d.toUTCString(); document.cookie = cname + "=" + value + ";" + expires + ";path=/"; } function boostiumDeleteCookie(cname) { document.cookie = cname + "=;" + "expires=Thu, 01 Jan 1970 00:00:00 UTC" + ";path=/"; } function boostiumGetCookie(cname) { let name = cname + "="; let decodedCookie = decodeURIComponent(document.cookie); let ca = decodedCookie.split(';'); for (let i = 0; i < ca.length; i++) { let c = ca[i]; while (c.charAt(0) == ' ') { c = c.substring(1); } if (c.indexOf(name) == 0) { return c.substring(name.length, c.length); } } return false; } // --------------------------------------------- // onscroll scripts // --------------------------------------------- /***************** * navbar *****************/ // navbar color const navbarToggler = document.getElementById('navToggleBtn'); const navbar = document.getElementById('navbar'); const tocFloatButton = document.getElementById('toc_dropdown_btn'); const navbarColor = element => { let y = window.scrollY if ( y < 40 && navbarToggler === null) { element.classList.remove('navbar-onscroll'); } else if (y < 40 && navbarToggler.ariaExpanded === 'false' && navbar !== null && navbar.querySelector(".dropdown-toggle.show") == null) { element.classList.remove('navbar-onscroll'); } else { element.classList.add('navbar-onscroll'); } } // check that both navbarToggler and navbar exist if ( navbar !== null ) { navbar.addEventListener("mouseover", function () { navbar.classList.add('navbar-onscroll'); }); navbar.addEventListener("mouseout", function () { let y = window.scrollY if (y < 40 && navbarToggler === null && navbar.querySelector(".dropdown-toggle.show") == null) { navbar.classList.remove('navbar-onscroll') } else if (y < 40 && navbarToggler.ariaExpanded === 'false' && navbar.querySelector(".dropdown-toggle.show") == null) { navbar.classList.remove('navbar-onscroll') } }); // on hamburger toggle if ( navbarToggler !== null ) { navbarToggler.onclick = function() { if (!navbar.classList.contains('navbar-onscroll') ) { navbar.classList.add('navbar-onscroll') } else if (window.scrollY < 40 && navbarToggler.ariaExpanded === 'false') { navbar.classList.remove('navbar-onscroll') }; }; } } /***************** * TOC sticky top visibility *****************/ if ( tocFloatButton !== null ) { const tocFloatVisibility = element => { let y = window.scrollY if ( y < 40 ) { element.classList.add('faded'); } else { element.classList.remove('faded'); } } window.addEventListener("scroll", function () { tocFloatVisibility(tocFloatButton); }); } /***************** * back to top *****************/ let btnBackToTop = document.getElementById("backToTop"); // When the user clicks on the button, scroll to the top of the document function backToTop() { document.body.scrollTop = 0; // For Safari document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera } function backToTopScroll() { if (document.body.scrollTop > 100 || document.documentElement.scrollTop > 100) { btnBackToTop.style.display = "block"; } else { btnBackToTop.style.display = "none"; } } /***************** * sticky review *****************/ let reviewSticky = document.getElementById("review-sticky"); let mainOffer = document.getElementById("main-offer-container"); function reviewStickyShow() { if (mainOffer.getBoundingClientRect().top < (mainOffer.getBoundingClientRect().height * -1 + 80) ) { reviewSticky.style.display = "inline"; } else { reviewSticky.style.display = "none"; } } /***************** * onscroll event *****************/ function boostiumOnscroll() { if( navbar !== null) { navbarColor(navbar); } if(typeof btnBackToTop !== 'undefined' && btnBackToTop !== null) { backToTopScroll(); } if(typeof reviewSticky !== 'undefined' && reviewSticky !== null) { reviewStickyShow(); } } window.addEventListener("scroll", boostiumOnscroll); // --------------------------------------------- // initialize popovers // --------------------------------------------- var popoverTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="popover"]')) var popoverList = popoverTriggerList.map(function (popoverTriggerEl) { return new bootstrap.Popover(popoverTriggerEl), { trigger: 'focus' } }) // --------------------------------------------- // load more / fetch posts // --------------------------------------------- /** * Load more function */ let boostiumLoadMoreBtns = document.querySelectorAll('button.load-more-button'),// get all load more buttons boostiumLoadMoreUrl = '', boostiumFetchUrl = '', boostiumParser = ''; if (boostiumLoadMoreBtns.length > 0) { // list sections with load more for( let i = 0; i