let cookiesConsentTransactionArticleContainer = []; let cookiesConstenCartArticleContainer = []; 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); // domain=site.com } function cookieConsentGetCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); //console.log(ca); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); //console.log(c); //console.log(c.indexOf(nameEQ)); 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 cookieConsetToolMoreInfo() { $('#cookie-content-proto-info-body').removeClass('cookie-content-proto-hiddenclass'); } function cookieConsetToolAccepted() { cookieConsentSetCookie("ConsentDone","all",14); cookiesSaveDecision('all'); cookieConsentDoCookies(); } function cookieConsetToolCheckSelected() { consentIDs = ''; inputElements = $('.cookie-content-proto-info-partner'); inputElements.each(function() { if(cookieConsentDebug) { console.log("Checking Checkbox for Partner-ID:" + $(this).val()); } if($(this).prop("checked") == true){ if(cookieConsentDebug) { console.log("Checking Checkbox for Partner-ID:" + $(this).val() + " - YEHAW it's checked"); } consentIDs = ""+ consentIDs + $(this).val() + "-"; } }); if(consentIDs.length > 1) { consentIDs = consentIDs.substring(0,consentIDs.length - 1); }else{ consentIDs = '0'; // if no cookies selected } cookieConsentSetCookie("ConsentDone",consentIDs,14); $('#cookie-content-proto-info-body').addClass('cookie-content-proto-hiddenclass'); cookieConsentDoCookies(); cookiesSaveDecision(consentIDs); } function cookieConsentDoCookies() { if(cookieConsentDebug) { console.log('cookieConsentDoCookies.called() with: ' + cookieConsentGetCookie("ConsentDone")); } if(cookieConsentGetCookie("ConsentDone") == "all" || cookieConsentGetCookie("ConsentDone") != "") { $('.cookie-content-proto-cookie-details').addClass('cookie-content-proto-hiddenclass'); var request_cct2 = new XMLHttpRequest(); request_cct2.open("GET","https://cookies.msqln.com/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 ); $.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.addEventListener('load', () => { if(cookieConsentDebug) { console.log('cookieConsentDoCookies() element loaded'); } }); window.document.body.appendChild(script); }); // Loading done. noe init... var request_cct3 = new XMLHttpRequest(); request_cct3.open("GET","https://cookies.msqln.com/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 ); $.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.addEventListener('load', () => {console.log('loaded');}); 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.msqln.com/css/public/cookie-content-proto-paragraph-style-msqln.css'; // Append link element to HTML head head.appendChild(link); if(!paragraphElement){ var url = $(location).attr("href"); var checkLeaseback = new RegExp("leaseback"); if(checkLeaseback.test(url)){ var paragraph_element = ''; }else{ var paragraph_element = ''; } $('body').append(paragraph_element); this.paragraphElement = true; } if(cookieConsentDebug) { console.log(paragraphElement); } $('body').on('click', 'div.cookie-content-proto-cookie-resuse-icon', function () { $('body').css('overflow-y','hidden'); //$('html').css('overflow-y','hidden'); if(cookieConsentDebug) { console.log('div.cookie-content-proto-cookie-resuse-icon: clicked!'); } window.scrollTo(0, 0); if($('.cookie-content-proto-cookie-details').hasClass('cookie-content-proto-hiddenclass')){ $('.cookie-content-proto-info-body').removeClass('cookie-content-proto-hiddenclass'); $('.cookie-content-proto-cookie-details').removeClass('cookie-content-proto-hiddenclass'); } if ($('.cookie-content-proto-cookie-details')[0]){ $('.cookie-content-proto-info-body').removeClass('cookie-content-proto-hiddenclass'); $('.cookie-content-proto-cookie-details').removeClass('cookie-content-proto-hiddenclass'); } else { cookieConsentDisplayModal(); } }); } var cookieConsentLanguage = 'de'; function cookieConsentDisplayModal() { $('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.msqln.com/css/public/cookie-content-proto-style-msqln.css'; head.appendChild(link); var request_cct = new XMLHttpRequest(); request_cct.open("GET","https://cookies.msqln.com/dom/v1/" + cookieConsentLanguage); request_cct.addEventListener('load', function(event) { if (request_cct.status >= 200 && request_cct.status < 300) { $('body').append(request_cct.responseText); $('body').on('click', '#cookie-content-proto-info-btn-save', function () { cookieConsetToolCheckSelected(); $('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 cookieConsentAddArticleToTransaction(articlenumber, articlequantity, articlenettoprice, articlename) { let newTransactionElement = {}; newTransactionElement.articlenumber = articlenumber; newTransactionElement.articlequantity = articlequantity; newTransactionElement.articlenettoprice = articlenettoprice; newTransactionElement.articlename = articlename; cookiesConsentTransactionArticleContainer.push(newTransactionElement); } function cookieConsentAddArticleToTransaction(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.msqln.com/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 ); $.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 cookieConsentDoTransaction( 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.msqln.com/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 ); $.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.msqln.com/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 länge: ' + split2.length); } if(split2.length == 2) { let foreachLine = split2[0]; let injection = ''; if(cookiesConsentTransactionArticleContainer.length > 0) { $.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) { 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) { 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 (neu): '+ searchKeyword); } var request_cct5 = new XMLHttpRequest(); request_cct5.open("GET","https://cookies.msqln.com/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 ); $.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.msqln.com/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 ); $.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.msqln.com/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 ); $.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('cookieConsentDoEMail() 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.msqln.com/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 ); $.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.msqln.com/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 ); $.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); //console.log(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.msqln.com/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 ); $.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; cookiesConstenCartArticleContainer.push(newCartElement); } function cookieConsentEnhanceWithArticleListDataSplitHelper(splitTest_before, splitTest_after) { let split2 = splitTest_after.split('{/foreach-articles}'); if(cookieConsentDebug) { console.log('replaceArticles() split2 länge: ' + split2.length); } if(split2.length == 2) { let foreachLine = split2[0]; let injection = ''; if(typeof coookieConsentArticleList !== 'undefined') { if(coookieConsentArticleList.length > 0) { $.each( coookieConsentArticleList, 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 : ' + coookieConsentArticleList.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) { tempCode = cookieConsentEnhanceWithArticleListDataSplitHelper(splitTest[0],splitTest[1]); splitTest.shift(); splitTest[0] = tempCode; returnSnippet = splitTest.join('{foreach-articles}'); splitTest = returnSnippet.split('{foreach-articles}'); } } } return snippet; }