let cookiesConsentTransactionArticleContainer = []; let cookiesConsentCartArticleContainer = []; let cookieConsentDebug = false; function cookieConsentStringReplaceAll(str, find, replace) { return str.replace(new RegExp(find, 'g'), replace); } function cookieConsentGetDomainWithoutSubdomain(url) { if (cookieConsentDebug) { console.log(url); } var urlInstance = new URL('https://' + url); var urlParts = urlInstance.hostname.split('.'); return urlParts .slice(0) .slice(-(urlParts.length === 4 ? 3 : 2)) .join('.'); } function cookieConsentSetCookie(name, value, days) { var expires = ""; if (days) { var date = new Date(); date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); expires = "; expires=" + date.toUTCString(); } document.cookie = name + "=" + (value || "") + expires + "; path=/; domain=" + cookieConsentGetDomainWithoutSubdomain(window.location.hostname); } function cookieConsentGetCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for (var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') c = c.substring(1, c.length); if (c.indexOf(nameEQ) == 0) { return c.substring(nameEQ.length, c.length); }; } return null; } function cookieConsentEraseCookie(name) { document.cookie = name + '=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;'; } function cookieConsentToolMoreInfo() { jQuery('#cookie-content-proto-info-body').removeClass('cookie-content-proto-hiddenclass'); } function cookieConsentToolAccepted() { cookieConsentSetCookie("ConsentDone", "all", 180); cookiesSaveDecision('all'); cookieConsentDoCookies(); } // new function for instagram stuff.. function cookieConsentAddConsentForOneId(id_to_add) { checkIfCookies = ""+ cookieConsentGetCookie("ConsentDone"); new_consent_id = ""; if(checkIfCookies == "") { // No cookie so fare, or empty new_consent_id = id_to_add; } else { if(checkIfCookies == 'all') { // consent already given.... } else { if(checkIfCookies == "0") { new_consent_id = id_to_add; } else { // check if the id_to_add is already there splitCheck = checkIfCookies.split("-"); isInSplitCheck = false; jQuery.each(splitCheck, function (index, value) { if(value == id_to_add) { isInSplitCheck = true; } }); if(!isInSplitCheck) { if(checkIfCookies == "") { new_consent_id = id_to_add; } else { new_consent_id = checkIfCookies + "-" + id_to_add; } } else { new_consent_id = checkIfCookies; } } } } if(checkIfCookies != new_consent_id) { console.log('cookieConsentAddConsentForOneId.called() id_to_add:' + id_to_add + ' checkIfCookies:' + checkIfCookies + ' new_consent_id:' + new_consent_id ); cookieConsentSetCookie("ConsentDone",new_consent_id, 180); cookiesSaveDecision(new_consent_id); cookieConsentDoCookies(); cookieConsentRecalculateAfterExternalAction(); } } function cookieConsentToolCheckSelected() { let consentIDs = ''; let inputElements = jQuery('.cookie-content-proto-info-partner'); inputElements.each(function () { if (cookieConsentDebug) { console.log("Checking Checkbox for Partner-ID:" + jQuery(this).val()); } if (jQuery(this).prop("checked") == true) { if (cookieConsentDebug) { console.log("Checking Checkbox for Partner-ID:" + jQuery(this).val() + " - YEHAW it's checked"); } consentIDs = "" + consentIDs + jQuery(this).val() + "-"; } }); if (consentIDs.length > 1) { consentIDs = consentIDs.substring(0, consentIDs.length - 1); } else { consentIDs = '0'; // if no cookies selected } cookieConsentSetCookie("ConsentDone", consentIDs, 180); jQuery('#cookie-content-proto-info-body').addClass('cookie-content-proto-hiddenclass'); cookieConsentDoCookies(); cookiesSaveDecision(consentIDs); } function cookieConsentElementExists(id) { return document.getElementById(id) !== null; } function cookieConsentMakeIdFromString(inputString) { return inputString.trim().replace(/\s+/g, '-').toLowerCase(); } function cookieConsentDoCookies() { if (cookieConsentDebug) { console.log('cookieConsentDoCookies.called() with: ' + cookieConsentGetCookie("ConsentDone")); } if (cookieConsentGetCookie("ConsentDone") == "all" || cookieConsentGetCookie("ConsentDone") != "") { jQuery('.cookie-content-proto-cookie-details').addClass('cookie-content-proto-hiddenclass'); var request_cct2 = new XMLHttpRequest(); request_cct2.open("GET", "https://cookies.odernichtoderdoch.de/script-files/v1/" + cookieConsentGetCookie("ConsentDone")); request_cct2.addEventListener('load', function (event) { if (request_cct2.status >= 200 && request_cct2.status < 300) { var scriptTags = jQuery.parseJSON(request_cct2.responseText); jQuery.each(scriptTags, function (index, value) { var script = document.createElement('script'); if (cookieConsentDebug) { console.log('Cookie-Consent-Activating-Scripts for ' + value.name); } script.type = 'text/javascript'; script.src = value.embedlink; script.id = 'cookieconsent-files-' + cookieConsentMakeIdFromString(value.name); script.addEventListener('load', () => { if (cookieConsentDebug) { console.log('cookieConsentDoCookies() element loaded'); } }); if(cookieConsentElementExists('cookieconsent-files-' + cookieConsentMakeIdFromString(value.name)) == false) { window.document.body.appendChild(script); } }); // Loading done. now init... var request_cct3 = new XMLHttpRequest(); request_cct3.open("GET", "https://cookies.odernichtoderdoch.de/script-codes/v1/" + cookieConsentGetCookie("ConsentDone")); request_cct3.addEventListener('load', function (event) { if (request_cct3.status >= 200 && request_cct3.status < 300) { var scriptTags = jQuery.parseJSON(request_cct3.responseText); jQuery.each(scriptTags, function (index, value) { var script = document.createElement('script'); if (cookieConsentDebug) { console.log('Cookie-Consent-Activating-Codes for ' + value.name); } script.type = 'text/javascript'; script.innerHTML = value.embedcode; script.id = 'cookieconsent-codes-' + cookieConsentMakeIdFromString(value.name); script.addEventListener('load', () => { console.log('loaded'); }); if(cookieConsentElementExists('cookieconsent-codes-' + cookieConsentMakeIdFromString(value.name)) == false) { window.document.body.appendChild(script); } }); cookieConsentShowParagraph(); // create and dispatch the event var cookieConsentLoadEvent = new CustomEvent("cookieConsentLoadEvent", {}); window.dispatchEvent(cookieConsentLoadEvent); } else { console.warn(request_cct3.statusText, request_cct3.responseText); } }); request_cct3.send(); } else { console.warn(request_cct2.statusText, request_cct2.responseText); } }); request_cct2.send(); } else { if (cookieConsentDebug) { console.log('Cookie Consent: ' + cookieConsentGetCookie("ConsentDone")); } } } var paragraphElement = false; function cookieConsentShowParagraph() { var head = document.getElementsByTagName('HEAD')[0]; // Create new link Element var link = document.createElement('link'); // set the attributes for link element link.rel = 'stylesheet'; link.type = 'text/css'; link.href = 'https://cookies.odernichtoderdoch.de/css/public/cookie-content-proto-paragraph-style-onod.css'; // Append link element to HTML head head.appendChild(link); if (!paragraphElement) { var url = jQuery(location).attr("href"); var checkLeaseback = new RegExp("leaseback"); var paragraph_element; if (checkLeaseback.test(url)) { paragraph_element = '
'; } else { paragraph_element = ''; } jQuery('body').append(paragraph_element); this.paragraphElement = true; } if (cookieConsentDebug) { console.log(paragraphElement); } jQuery('body').on('click', '.cookie-content-proto-cookie-resuse-icon', function () { jQuery('body').css('overflow-y', 'hidden'); if (cookieConsentDebug) { console.log('.cookie-content-proto-cookie-resuse-icon: clicked!'); } window.scrollTo(0, 0); if (jQuery('.cookie-content-proto-cookie-details').hasClass('cookie-content-proto-hiddenclass')) { jQuery('.cookie-content-proto-info-body').removeClass('cookie-content-proto-hiddenclass'); jQuery('.cookie-content-proto-cookie-details').removeClass('cookie-content-proto-hiddenclass'); } if (jQuery('.cookie-content-proto-cookie-details')[0]) { jQuery('.cookie-content-proto-info-body').removeClass('cookie-content-proto-hiddenclass'); jQuery('.cookie-content-proto-cookie-details').removeClass('cookie-content-proto-hiddenclass'); } else { cookieConsentDisplayModal(); } }); } var cookieConsentLanguage = 'de'; function cookieConsentRecalculateAfterExternalAction() { console.log('cookieConsentRecalculateAfterExternalAction().called()'); if (document.cookie.indexOf("ConsentDone") < 0) { console.log('pre-select'); var groups = jQuery('.cookie-content-proto-info-input').not(":disabled"); //Google Analytics,Facebook,Pinterest,Instagram,PopExit //var preSelectValues = new Array (9,7,8,36,14); var preSelectValues = new Array (2); for(var i = 0; i< groups.length; i++) { for(var u = 0; u < preSelectValues.length; u++){ if(groups[i].value == preSelectValues[u]){ groups[i].click(); groups[i].setAttribute('checked',"checked"); } } } }else{ var nameEQ = "ConsentDone" + "="; var ca = document.cookie.split(';'); var cookieString = "" for (var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') c = c.substring(1, c.length); if (c.indexOf(nameEQ) == 0) { cookieString = c.substring(nameEQ.length, c.length); } } var groups = jQuery('.cookie-content-proto-info-input'); //Check for existing cookies var preSelectValues = cookieString.split("-"); for(var i = 0; i< groups.length; i++) { for(var u = 0; u < preSelectValues.length; u++){ if(groups[i].value == preSelectValues[u]){ groups[i].click(); groups[i].setAttribute('checked',"checked"); } } } } } function cookieConsentDisplayModalExternalTrigger() { console.log('cookieConsentDisplayModalExternalTrigger.called()'); if (window.jQuery) { cookieConsentRecalculateAfterExternalAction(); jQuery('body').css('overflow-y', 'hidden'); if (cookieConsentDebug) { console.log('.cookie-content-proto-cookie-resuse-icon: clicked!'); } window.scrollTo(0, 0); if (jQuery('.cookie-content-proto-cookie-details').hasClass('cookie-content-proto-hiddenclass')) { jQuery('.cookie-content-proto-info-body').removeClass('cookie-content-proto-hiddenclass'); jQuery('.cookie-content-proto-cookie-details').removeClass('cookie-content-proto-hiddenclass'); } if (jQuery('.cookie-content-proto-cookie-details')[0]) { jQuery('.cookie-content-proto-info-body').removeClass('cookie-content-proto-hiddenclass'); jQuery('.cookie-content-proto-cookie-details').removeClass('cookie-content-proto-hiddenclass'); } else { cookieConsentDisplayModal(); } } else { console.log('cookieConsentDisplayModalExternalTrigger: jQuery not found!'); } } function cookieConsentDisplayModal() { if (window.jQuery) { jQuery('body').css('overflow-y', 'hidden'); } var head = document.getElementsByTagName('HEAD')[0]; var link = document.createElement('link'); link.rel = 'stylesheet'; link.type = 'text/css'; link.href = 'https://cookies.odernichtoderdoch.de/css/public/cookie-content-proto-style-onod.css'; head.appendChild(link); var request_cct = new XMLHttpRequest(); request_cct.open("GET", "https://cookies.odernichtoderdoch.de/dom/v1/" + cookieConsentLanguage); request_cct.addEventListener('load', function (event) { if (request_cct.status >= 200 && request_cct.status < 300) { jQuery('body').append(request_cct.responseText); jQuery('body').on('click', '#cookie-content-proto-info-btn-save', function () { cookieConsentToolCheckSelected(); jQuery('body').css('overflow-y', 'auto'); }); } else { console.warn(request_cct.statusText, request_cct.responseText); } }); request_cct.send(); } window.onload = function () { if (window.jQuery) { if (window.cookies_content_language != undefined) { cookieConsentLanguage = cookies_content_language; } if ("" + cookieConsentGetCookie("ConsentDone") == "" || "" + cookieConsentGetCookie("ConsentDone") == "null") { cookieConsentDisplayModal(); } else { if (cookieConsentDebug) { console.log('CookieConsent-Already decided:' + "" + cookieConsentGetCookie("ConsentDone")); } cookieConsentDoCookies(); } } else { console.log('CookieConsent: No jQuery found!'); } } function cookieConsnetReshowModel() { window.scrollTo(0, 0); jQuery('body').css('overflow-y', 'hidden'); if (jQuery('.cookie-content-proto-cookie-details').hasClass('cookie-content-proto-hiddenclass')) { jQuery('.cookie-content-proto-info-body').removeClass('cookie-content-proto-hiddenclass'); jQuery('.cookie-content-proto-cookie-details').removeClass('cookie-content-proto-hiddenclass'); } if (jQuery('.cookie-content-proto-cookie-details')[0]) { jQuery('.cookie-content-proto-info-body').removeClass('cookie-content-proto-hiddenclass'); jQuery('.cookie-content-proto-cookie-details').removeClass('cookie-content-proto-hiddenclass'); } else { cookieConsentDisplayModal(); } } function cookieConsentAddArticleToTransaction(articlenumber, articlequantity, articlenettoprice, articlename) { let newTransactionElement = {}; newTransactionElement.articlenumber = articlenumber; newTransactionElement.articlequantity = articlequantity; newTransactionElement.articlenettoprice = articlenettoprice; newTransactionElement.articlename = articlename; cookiesConsentTransactionArticleContainer.push(newTransactionElement); } function cookieConsentAddArticleToTransactionExtended(articlenumber, articlequantity, articlenettoprice, articlebruttoprice, articlename, primaryCategoryId, primaryCategoryName) { let newTransactionElement = {}; newTransactionElement.articlenumber = articlenumber; newTransactionElement.articlequantity = articlequantity; newTransactionElement.articlenettoprice = articlenettoprice; newTransactionElement.articlebruttoprice = articlebruttoprice; newTransactionElement.articlename = articlename; newTransactionElement.primaryCategoryId = primaryCategoryId; newTransactionElement.primaryCategoryName = primaryCategoryName; cookiesConsentTransactionArticleContainer.push(newTransactionElement); } function cookieConsentDoTransaction(transactionIdentifier, transactionType, transactionAmount) { if (cookieConsentDebug) { console.log('cookieConsentDoTransaction() called'); console.log('cookieConsentDoTransaction() transactionIdentifier: ' + transactionIdentifier); console.log('cookieConsentDoTransaction() transactionType: ' + transactionType); console.log('cookieConsentDoTransaction() transactionAmount: ' + transactionAmount); } var request_cct4 = new XMLHttpRequest(); request_cct4.open("GET", "https://cookies.odernichtoderdoch.de/track-transactions/v1/" + cookieConsentGetCookie("ConsentDone")); request_cct4.addEventListener('load', function (event) { if (request_cct4.status >= 200 && request_cct4.status < 300) { var scriptTags = jQuery.parseJSON(request_cct4.responseText); jQuery.each(scriptTags, function (index, value) { var script = document.createElement('script'); if (cookieConsentDebug) { console.log('Cookie-Consent-Tracking-Transactions for ' + value.name); } script.type = 'text/javascript'; var code = value.embedcode; code = cookieConsentStringReplaceAll(code, "{transactionIdentifier}", transactionIdentifier); code = cookieConsentStringReplaceAll(code, "{transactionType}", transactionType); code = cookieConsentStringReplaceAll(code, "{transactionAmount}", transactionAmount); code = cookieConsentDoTransactionReplaceArticles(code); code = cookieConsentEnhanceWithArticleListData(code); script.innerHTML = code; script.addEventListener('load', () => { if (cookieConsentDebug) { console.log('cookieConsentDoTransaction() element loaded'); } }); window.document.body.appendChild(script); }); } }); request_cct4.send(); } function cookieConsentDoTransactionExtended(transactionIdentifier, transactionType, transactionAmount, transactionAmountNetto, transactionShipping, transactionShippingNetto, transactionShippingType, transactionPaymentType) { if (cookieConsentDebug) { console.log('cookieConsentDoTransaction() (ext) called'); console.log('cookieConsentDoTransaction() (ext) transactionIdentifier: ' + transactionIdentifier); console.log('cookieConsentDoTransaction() (ext) transactionType: ' + transactionType); console.log('cookieConsentDoTransaction() (ext) transactionAmount: ' + transactionAmount); console.log('cookieConsentDoTransaction() (ext) transactionAmountNetto: ' + transactionAmountNetto); console.log('cookieConsentDoTransaction() (ext) transactionShipping: ' + transactionShippingNetto); console.log('cookieConsentDoTransaction() (ext) transactionShippingNetto: ' + transactionShipping); console.log('cookieConsentDoTransaction() (ext) transactionShippingType: ' + transactionShippingType); console.log('cookieConsentDoTransaction() (ext) transactionPaymentType: ' + transactionPaymentType); } var request_cct4 = new XMLHttpRequest(); request_cct4.open("GET", "https://cookies.odernichtoderdoch.de/track-transactions/v1/" + cookieConsentGetCookie("ConsentDone")); request_cct4.addEventListener('load', function (event) { if (request_cct4.status >= 200 && request_cct4.status < 300) { var scriptTags = jQuery.parseJSON(request_cct4.responseText); jQuery.each(scriptTags, function (index, value) { var script = document.createElement('script'); if (cookieConsentDebug) { console.log('Cookie-Consent-Tracking-Transactions for ' + value.name); } script.type = 'text/javascript'; var code = value.embedcode; code = cookieConsentStringReplaceAll(code, "{transactionIdentifier}", transactionIdentifier); code = cookieConsentStringReplaceAll(code, "{transactionType}", transactionType); code = cookieConsentStringReplaceAll(code, "{transactionAmount}", transactionAmount); code = cookieConsentStringReplaceAll(code, "{transactionAmountNetto}", transactionAmountNetto); code = cookieConsentStringReplaceAll(code, "{transactionShipping}", transactionShipping); code = cookieConsentStringReplaceAll(code, "{transactionShippingNetto}", transactionShippingNetto); code = cookieConsentStringReplaceAll(code, "{transactionShippingType}", transactionShippingType); code = cookieConsentStringReplaceAll(code, "{transactionPaymentType}", transactionPaymentType); code = cookieConsentDoTransactionReplaceArticles(code); code = cookieConsentEnhanceWithArticleListData(code); script.innerHTML = code; script.addEventListener('load', () => { if (cookieConsentDebug) { console.log('cookieConsentDoTransaction() element loaded'); } }); window.document.body.appendChild(script); }); } }); request_cct4.send(); } function cookiesSaveDecision(consentIDs) { if (cookieConsentDebug) { console.log('Saving decision... ' + consentIDs); } var request_cct5 = new XMLHttpRequest(); request_cct5.open("GET", "https://cookies.odernichtoderdoch.de/save-decision/v1/" + consentIDs); request_cct5.addEventListener('load', function (event) { if (request_cct5.status >= 200 && request_cct5.status < 300) { if (cookieConsentDebug) { console.log('Decision saved'); } } }); request_cct5.send(); } function cookieConsentDoTransactionReplaceArticlesSplitHelper(splitTest_before, splitTest_after) { let split2 = splitTest_after.split('{/foreach-article}'); if (cookieConsentDebug) { console.log('replaceArticles() split2 length: ' + split2.length); } if (split2.length == 2) { let foreachLine = split2[0]; let injection = ''; if (cookiesConsentTransactionArticleContainer.length > 0) { jQuery.each(cookiesConsentTransactionArticleContainer, function (index, value) { let line = foreachLine; line = line.replace("{articlenumber}", value.articlenumber); line = line.replace("{articlequantity}", value.articlequantity); line = line.replace("{articlenettoprice}", value.articlenettoprice); line = line.replace("{articlebruttoprice}", value.articlebruttoprice); line = line.replace("{primaryCategoryId}", value.primaryCategoryId); line = line.replace("{primaryCategoryName}", value.primaryCategoryName); line = line.replace("{articlename}", value.articlename); injection = injection + line; }); } return splitTest_before + injection + split2[1]; } else { return splitTest_after; } } function cookieConsentDoTransactionReplaceArticles(snippet) { if (cookieConsentDebug) { console.log('cookieConsentDoTransaction() cookieConsentDoTransactionReplaceArticles.subprocess called!'); } if (cookiesConsentTransactionArticleContainer.length > 0) { console.log('cookieConsentDoTransaction() cookieConsentDoTransactionReplaceArticles.subprocess called! : ' + cookiesConsentTransactionArticleContainer.length + ' items found!'); let returnSnippet = snippet; let splitTest = snippet.split('{foreach-article}'); let splitTracker = true; if (splitTest.length > 1) { while (splitTracker) { if (splitTest.length == 2) { splitTracker = false; return cookieConsentDoTransactionReplaceArticlesSplitHelper(splitTest[0], splitTest[1]); } else if (splitTest.length > 2) { let tempCode = cookieConsentDoTransactionReplaceArticlesSplitHelper(splitTest[0], splitTest[1]); splitTest.shift(); splitTest[0] = tempCode; returnSnippet = splitTest.join('{foreach-article}'); splitTest = returnSnippet.split('{foreach-article}'); } } } else { return snippet; } } else { let returnSnippet = snippet; let splitTest = snippet.split('{foreach-article}'); let splitTracker = true; if (splitTest.length > 1) { while (splitTracker) { if (splitTest.length == 2) { splitTracker = false; return cookieConsentDoTransactionReplaceArticlesSplitHelper(splitTest[0], splitTest[1]); } else if (splitTest.length > 2) { let tempCode = cookieConsentDoTransactionReplaceArticlesSplitHelper(splitTest[0], splitTest[1]); splitTest.shift(); splitTest[0] = tempCode; returnSnippet = splitTest.join('{foreach-article}'); splitTest = returnSnippet.split('{foreach-article}'); } } } else { return snippet; } console.log('cookieConsentDoTransaction() cookieConsentDoTransactionReplaceArticles.subprocess called! : no items found!'); return snippet; } } function cookieConsentDoSearch(searchKeyword) { if (cookieConsentDebug) { console.log('cookieConsentDoSearch() called'); console.log('cookieConsentDoSearch() searchKeyword (new): ' + searchKeyword); } var request_cct5 = new XMLHttpRequest(); request_cct5.open("GET", "https://cookies.odernichtoderdoch.de/track-search/v1/" + cookieConsentGetCookie("ConsentDone")); request_cct5.addEventListener('load', function (event) { if (request_cct5.status >= 200 && request_cct5.status < 300) { var scriptTags = jQuery.parseJSON(request_cct5.responseText); jQuery.each(scriptTags, function (index, value) { var script = document.createElement('script'); if (cookieConsentDebug) { console.log('Cookie-Consent-Track Search for ' + value.name); } script.type = 'text/javascript'; var code = value.embedcode; code = cookieConsentStringReplaceAll(code, "{searchKeyword}", searchKeyword); // new Article-Code Extension code = cookieConsentEnhanceWithArticleListData(code); script.innerHTML = code; script.addEventListener('load', () => { console.log('cookieConsentDoSearch() element loaded'); }); window.document.body.appendChild(script); }); } }); request_cct5.send(); } function cookieConsentDoEMail(emalAdr) { if (cookieConsentDebug) { console.log('cookieConsentDoEMail() called'); console.log('cookieConsentDoEMail() emalAdr: ' + emalAdr); } var request_cct6 = new XMLHttpRequest(); request_cct6.open("GET", "https://cookies.odernichtoderdoch.de/track-email/v1/" + cookieConsentGetCookie("ConsentDone")); request_cct6.addEventListener('load', function (event) { if (request_cct6.status >= 200 && request_cct6.status < 300) { var scriptTags = jQuery.parseJSON(request_cct6.responseText); jQuery.each(scriptTags, function (index, value) { var script = document.createElement('script'); console.log('Cookie-Consent-Track EMail for ' + value.name); script.type = 'text/javascript'; var code = value.embedcode; code = cookieConsentStringReplaceAll(code, "{emalAdr}", emalAdr); script.innerHTML = code; script.addEventListener('load', () => { console.log('cookieConsentDoEMail() element loaded'); }); window.document.body.appendChild(script); }); } }); request_cct6.send(); } function cookieConsentDoCheckout(checkoutPageType, checkoutShippingTypeSelected, checkoutPaymentTypeSelected) { if (cookieConsentDebug) { console.log('cookieConsentDoCheckout() called'); } var request_cct6 = new XMLHttpRequest(); request_cct6.open("GET", "https://cookies.odernichtoderdoch.de/track-checkout/v1/" + cookieConsentGetCookie("ConsentDone")); request_cct6.addEventListener('load', function (event) { if (request_cct6.status >= 200 && request_cct6.status < 300) { var scriptTags = jQuery.parseJSON(request_cct6.responseText); jQuery.each(scriptTags, function (index, value) { var script = document.createElement('script'); console.log('Cookie-Consent-Track Checkout for ' + value.name); script.type = 'text/javascript'; var code = value.embedcode; code = cookieConsentStringReplaceAll(code, "{pageType}", checkoutPageType); if (checkoutShippingTypeSelected != undefined) { if ("" + checkoutShippingTypeSelected != "") { code = cookieConsentStringReplaceAll(code, "{shippingTypeSelected}", checkoutShippingTypeSelected); } else { code = cookieConsentStringReplaceAll(code, "{shippingTypeSelected}", ''); } } else { code = cookieConsentStringReplaceAll(code, "{shippingTypeSelected}", ''); } if (checkoutPaymentTypeSelected != undefined) { if ("" + checkoutPaymentTypeSelected != "") { code = cookieConsentStringReplaceAll(code, "{paymentTypeSelected}", checkoutPaymentTypeSelected); } else { code = cookieConsentStringReplaceAll(code, "{paymentTypeSelected}", ''); } } else { code = cookieConsentStringReplaceAll(code, "{paymentTypeSelected}", ''); } code = cookieConsentDoTransactionReplaceArticles(code); script.innerHTML = code; script.addEventListener('load', () => { console.log('cookieConsentDoCheckout() element loaded'); }); window.document.body.appendChild(script); }); } }); request_cct6.send(); } function cookieConsentDoAddToCart(articleNumber, articleName, price, quantity) { if (cookieConsentDebug) { console.log('cookieConsentDoAddToCart() called'); console.log('cookieConsentDoAddToCart() articleNumber: ' + articleNumber); console.log('cookieConsentDoAddToCart() articleName: ' + articleName); console.log('cookieConsentDoAddToCart() price: ' + price); console.log('cookieConsentDoAddToCart() quantity: ' + quantity); } var request_cct6 = new XMLHttpRequest(); request_cct6.open("GET", "https://cookies.odernichtoderdoch.de/track-addtocart/v1/" + cookieConsentGetCookie("ConsentDone")); request_cct6.addEventListener('load', function (event) { if (request_cct6.status >= 200 && request_cct6.status < 300) { var scriptTags = jQuery.parseJSON(request_cct6.responseText); jQuery.each(scriptTags, function (index, value) { var script = document.createElement('script'); console.log('Cookie-Consent-Track AddtoCart for ' + value.name); script.type = 'text/javascript'; var code = value.embedcode; // Replacement code = cookieConsentStringReplaceAll(code, "{articleNumber}", articleNumber); code = cookieConsentStringReplaceAll(code, "{articleName}", articleName); code = cookieConsentStringReplaceAll(code, "{price}", price); code = cookieConsentStringReplaceAll(code, "{quantity}", quantity); script.innerHTML = code; script.addEventListener('load', () => { console.log('cookieConsentDoAddToCart() element loaded'); }); window.document.body.appendChild(script); }); } }); request_cct6.send(); } function cookieConsentDoPageType(pageType, pageName, identifier) { if (cookieConsentDebug) { console.log('cookieConsentDoPageType() called'); console.log('cookieConsentDoPageType() pageType: ' + pageType); console.log('cookieConsentDoPageType() pageName: ' + pageName); console.log('cookieConsentDoPageType() identifier: ' + identifier); } var request_cct7 = new XMLHttpRequest(); request_cct7.open("GET", "https://cookies.odernichtoderdoch.de/track-pagetype/v1/" + cookieConsentGetCookie("ConsentDone")); request_cct7.addEventListener('load', function (event) { if (request_cct7.status >= 200 && request_cct7.status < 300) { var scriptTags = jQuery.parseJSON(request_cct7.responseText); jQuery.each(scriptTags, function (index, value) { var script = document.createElement('script'); console.log('Cookie-Consent-Track PageType for ' + value.name); script.type = 'text/javascript'; var code = value.embedcode; // Replacement code = cookieConsentStringReplaceAll(code, "{pageType}", pageType); code = cookieConsentStringReplaceAll(code, "{pageName}", pageName); code = cookieConsentStringReplaceAll(code, "{identifier}", identifier); code = cookieConsentEnhanceWithArticleListData(code); script.innerHTML = code; script.addEventListener('load', () => { console.log('cookieConsentDoPageType() element loaded'); }); window.document.body.appendChild(script); }); } }); request_cct7.send(); } function cookieConsentDoCart(cartIdentifier, cartAmount) { if (cookieConsentDebug) { console.log('cookieConsentDoCart() called'); console.log('cookieConsentDoCart() cartIdentifier: ' + cartIdentifier); console.log('cookieConsentDoCart() cartAmount: ' + cartAmount); } var request_cct8 = new XMLHttpRequest(); request_cct8.open("GET", "https://cookies.odernichtoderdoch.de/track-cart/v1/" + cookieConsentGetCookie("ConsentDone")); request_cct8.addEventListener('load', function (event) { if (request_cct8.status >= 200 && request_cct8.status < 300) { var scriptTags = jQuery.parseJSON(request_cct8.responseText); jQuery.each(scriptTags, function (index, value) { var script = document.createElement('script'); console.log('Cookie-Consent-Tracking-Cart for ' + value.name); script.type = 'text/javascript'; var code = value.embedcode; code = cookieConsentStringReplaceAll(code, "{cartIdentifier}", cartIdentifier); code = cookieConsentStringReplaceAll(code, "{cartAmount}", cartAmount); code = cookieConsentDoTransactionReplaceArticles(code); code = cookieConsentEnhanceWithArticleListData(code); script.innerHTML = code; script.addEventListener('load', () => { console.log('cookieConsentDoCart() element loaded'); }); window.document.body.appendChild(script); }); } }); request_cct8.send(); } function cookieConsentAddArticleToCart(articlenumber, articlequantity, articlenettoprice, articlename) { let newCartElement = {}; newCartElement.articlenumber = articlenumber; newCartElement.articlequantity = articlequantity; newCartElement.articlenettoprice = articlenettoprice; newCartElement.articlename = articlename; cookiesConsentCartArticleContainer.push(newCartElement); } function cookieConsentEnhanceWithArticleListDataSplitHelper(splitTest_before, splitTest_after) { let split2 = splitTest_after.split('{/foreach-articles}'); if (cookieConsentDebug) { console.log('replaceArticles() split2 length: ' + split2.length); } if (split2.length == 2) { let foreachLine = split2[0]; let injection = ''; if (typeof cookieConsentArticleList !== 'undefined') { if (cookieConsentArticleList.length > 0) { jQuery.each(cookieConsentArticleList, function (index, value) { let line = foreachLine; line = line.replace("{articleName}", value.articleName); line = line.replace("{articleNumber}", value.articleNumber); line = line.replace("{priceBrutto}", value.priceBrutto); line = line.replace("{priceNetto}", value.priceNetto); line = line.replace("{primaryCategoryId}", value.primaryCategoryId); line = line.replace("{primaryCategoryName}", value.primaryCategoryName); injection = injection + line; }); } } return splitTest_before + injection + split2[1]; } else { return splitTest_after; } } function cookieConsentEnhanceWithArticleListData(snippet) { if (cookieConsentDebug) { console.log('cookieConsentEnhanceWithArticleListData() called'); } if (cookieConsentDebug) { console.log('cookieConsentEnhanceWithArticleListData : ' + cookieConsentArticleList.length + ' items found!'); } let returnSnippet = snippet; let splitTest = snippet.split('{foreach-articles}'); let splitTracker = true; if (splitTest.length > 1) { while (splitTracker) { if (splitTest.length == 2) { splitTracker = false; return cookieConsentEnhanceWithArticleListDataSplitHelper(splitTest[0], splitTest[1]); } else if (splitTest.length > 2) { let tempCode = cookieConsentEnhanceWithArticleListDataSplitHelper(splitTest[0], splitTest[1]); splitTest.shift(); splitTest[0] = tempCode; returnSnippet = splitTest.join('{foreach-articles}'); splitTest = returnSnippet.split('{foreach-articles}'); } } } return snippet; } function cookieConsentCheckConsentGiven(id_to_check) { consentCheck = ""+ cookieConsentGetCookie("ConsentDone"); if(consentCheck == 'all') { return true; } else { if(consentCheck.length > 0) { splitCheck = consentCheck.split("-"); valueCheck = splitCheck.includes(id_to_check); if(valueCheck) { return true; } else { return false; } } } }