var count = 0; var interval; function getCookie(name) { var value = "; " + document.cookie; var parts = value.split("; " + name + "="); if (parts.length == 2) { return true; } } function reloadOnRedirect(name) { count = 0; if(document.cookie.indexOf('OptanonAlertBoxClosed=') != -1){ initReloadOtBanner(); } } function initReloadOtBanner() { var otConsentSdk = document.getElementById("onetrust-consent-sdk"); if (otConsentSdk) { otConsentSdk.remove(); } if (window.OneTrust != null) { OneTrust.Init(); setTimeout(function() { executeReloadOtBanner(); }, 1000); } else { retryBannerReload(); } } function executeReloadOtBanner() { OneTrust.LoadBanner(); var toggleDisplay = document.getElementsByClassName("ot-sdk-show-settings"); for (var i = 0; toggleDisplay.length > i; i++) { toggleDisplay[i].onclick = function(event) { event.stopImmediatePropagation(); window.OneTrust.ToggleInfoDisplay(); }; } } function retryBannerReload() { count++; if(10 > count){ setTimeout(initReloadOtBanner, 1000); } } function reloadOnBoxClose() { let oldCookie = getCookie('OptanonAlertBoxClosed'); if(oldCookie){ return; } interval = setInterval(()=> { let newCookie = getCookie('OptanonAlertBoxClosed'); if (!oldCookie && newCookie) { initReloadOtBanner(); clearInterval(interval); } }, 1000); } function getCookie(name) { const value = '; ' + document.cookie; const parts = value.split('; ' + name + '='); if (parts.length === 2) { return parts.pop().split(';').shift(); } return null; } document.addEventListener("reloadotbanner", reloadOnRedirect); reloadOnBoxClose();