window.cookieConsent = {}; // Set window var which dependend scripts can register a listener to window.cookieConsent.tagmanager = { stateInternal: 'awaiting_approval', fallbackText: '', FallbackTextCssClass: '', stateListeners: [], set state(val) { this.stateInternal = val; this.stateListeners.forEach(function(listener){ listener(val); }); }, get state() { return this.stateInternal; }, registerListener: function (listener) { this.stateListeners.push(listener); } } // Set window var which dependend scripts can register a listener to window.cookieConsent.adn = { stateInternal: 'awaiting_approval', fallbackText: '', FallbackTextCssClass: '', stateListeners: [], set state(val) { this.stateInternal = val; this.stateListeners.forEach(function(listener){ listener(val); }); }, get state() { return this.stateInternal; }, registerListener: function (listener) { this.stateListeners.push(listener); } } // Set window var which dependend scripts can register a listener to window.cookieConsent.gpt = { stateInternal: 'awaiting_approval', fallbackText: '', FallbackTextCssClass: '', stateListeners: [], set state(val) { this.stateInternal = val; this.stateListeners.forEach(function(listener){ listener(val); }); }, get state() { return this.stateInternal; }, registerListener: function (listener) { this.stateListeners.push(listener); } } // Set window var which dependend scripts can register a listener to window.cookieConsent.prebid = { stateInternal: 'awaiting_approval', fallbackText: '', FallbackTextCssClass: '', stateListeners: [], set state(val) { this.stateInternal = val; this.stateListeners.forEach(function(listener){ listener(val); }); }, get state() { return this.stateInternal; }, registerListener: function (listener) { this.stateListeners.push(listener); } } window.addEventListener('CookieInformationConsentGiven', function(event) { // Handle the allways execute - these are not wrapped in event listener // Set script in to DOM var script = document.createElement('script'); script.src = '/js/tagmanager.js?bv=1'; document.head.append(script); // When we are sure script are loaded - we can set state var to approved which will trigger scripts // Dependend on this to execute script.onload = function() { window.cookieConsent.tagmanager.state = 'approved'; }; // Handle the allways execute - these are not wrapped in event listener // Set script in to DOM var script = document.createElement('script'); script.src = 'https://cdn.adnuntius.com/adn.js?bv=1'; document.head.append(script); // When we are sure script are loaded - we can set state var to approved which will trigger scripts // Dependend on this to execute script.onload = function() { window.cookieConsent.adn.state = 'approved'; }; // Handle the allways execute - these are not wrapped in event listener // Add a listener for when a consent is given // Execute if consent is given for this group or group is set to always_execute if (CookieInformation.getConsentGivenFor('cookie_cat_marketing')) { // Set script in to DOM var script = document.createElement('script'); script.src = 'https://www.googletagservices.com/tag/js/gpt.js?bv=1'; document.head.append(script); // When we are sure script are loaded - we can set state var to approved which will trigger scripts // Dependend on this to execute script.onload = function() { window.cookieConsent.gpt.state = 'approved'; }; } else { window.cookieConsent.gpt.state = 'disapproved'; } // Handle the allways execute - these are not wrapped in event listener // Add a listener for when a consent is given // Execute if consent is given for this group or group is set to always_execute if (CookieInformation.getConsentGivenFor('cookie_cat_marketing')) { // Set script in to DOM var script = document.createElement('script'); script.src = '//cdn.borsen.cloud/scripts/dfp/prebid2.8.0.js?bv=1'; document.head.append(script); // When we are sure script are loaded - we can set state var to approved which will trigger scripts // Dependend on this to execute script.onload = function() { window.cookieConsent.prebid.state = 'approved'; }; } else { window.cookieConsent.prebid.state = 'disapproved'; } }, false);