1/* -------------------------------------------------------------- 2 GxCookieConsent.js 2019-12-19 3 Gambio GmbH 4 http://www.gambio.de 5 Copyright (c) 2019 Gambio GmbH 6 Released under the GNU General Public License (Version 2) 7 [http://www.gnu.org/licenses/gpl-2.0.html] 8 --------------------------------------------------------------*/ 9 10/* -------------------------------------------------------------- 11 * Event listener for storing cookie selection in GXConsents 12 * -------------------------------------------------------------- */ 13 14(function() { 15 16 let eventMethod = window.addEventListener ? 'addEventListener' : 'attachEvent', 17 messageEvent = eventMethod === 'attachEvent' ? 'onmessage' : 'message', 18 eventer = window[eventMethod]; 19 20 let handleOptIn = function(event) { 21 22 let eventDataContains = function(str) { 23 return JSON.stringify(event.data).indexOf(str) !== -1; 24 } 25 26 let storeOilDataInCookie = function(data) { 27 28 let cookieDate = new Date; 29 // the oil.js cookie expires after 1 month 30 cookieDate.setMonth(cookieDate.getMonth() + 1); 31 32 let cookieString = 'GXConsents=' + JSON.stringify(data) + ';'; 33 cookieString += 'expires=' + cookieDate.toUTCString() + ';'; 34 cookieString += 'path=/;SameSite=Lax;' 35 document.cookie = cookieString; 36 }; 37 38 if (event && event.data && (eventDataContains('oil_optin_done') || eventDataContains('oil_has_optedin'))) { 39 40 // [8, 12, 28] enables vendor ids in the response 41 __cmp('getVendorConsents', [8, 12, 28], storeOilDataInCookie); 42 } 43 } 44 45 eventer(messageEvent, handleOptIn, false); 46 47 $(document).on('click', '[trigger-cookie-consent-panel]', function () { 48 49 window.AS_OIL.showPreferenceCenter(); 50 51 if (!$('.as-oil.light').length) { 52 $('body').append( 53 $('<div/>') 54 .addClass('as-oil light') 55 .append( 56 $('<div/>') 57 .attr('id', 'oil-preference-center') 58 .addClass('as-oil-content-overlay cpc-dynamic-panel') 59 ) 60 ); 61 } 62 }); 63})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.