function doNotTrackMe() { if (window.doNotTrack || navigator.doNotTrack || navigator.msDoNotTrack || (typeof window.external !== "undefined" && 'msTrackingProtectionEnabled' in window.external) ) { if (window.doNotTrack == "1" || navigator.doNotTrack == "yes" || navigator.doNotTrack == "1" || navigator.msDoNotTrack == "1" || (typeof window.external.msTrackingProtectionEnabled === "function" && window.external.msTrackingProtectionEnabled()) ) { return true; //enabled } else { return false;//disabled } } else { return false;//not supported } } if (typeof is_ajax_data === 'undefined') { var is_ajax_data = {}; } $(document).ready(function() { //interaction event $('a, button').on("click",function(event){ secure_ssl = ' Secure;'; if (location.protocol !== 'https:') { secure_ssl = ''; } document.cookie = "sm_i=1; path=/; SameSite=Lax;"+secure_ssl; }); //api custom consents ONLY OC4 const api_consents = document.querySelectorAll('#is-api-consents input'); api_consents.forEach(function (element) { element.addEventListener('change', (event) => { sm_custom_consents(api_consents); }); }); is_ajax_data.url = window.location.href; $.ajax({ async: true, cache: false, type: 'post', url: 'index.php?route=extension/analytics/script_manager/ajaxScripts&v='+(new Date()).getTime()+"&title="+encodeURIComponent(document.title), dataType: 'json', data: is_ajax_data, success: function(result) { if ((typeof doNotTrackMe !== "function" || !doNotTrackMe())) { var i; if (result !== null) { for (i = 0; i < result.length; i++) { if (result[i] != '') { (new Function(result[i]))() } } } } } }); }); $(document).ajaxSuccess(function( event, jqxhr, settings ) { if (typeof jqxhr.responseText !== 'undefined' && jqxhr.responseText !== null && jqxhr.responseText !== '') { try { if (typeof JSON.parse(jqxhr.responseText).error !== 'undefined') { return; } } catch (e) {} if (typeof settings !== 'undefined' && typeof settings.url !== 'undefined' && typeof settings.data !== 'undefined') { type = null; if (settings.url.includes("/cart|add") || settings.url.includes("/cart/add")) { type = 'cartadd'; } else if (settings.url.includes("/cart|edit") || settings.url.includes("/cart/edit")) { type = 'cartedit'; } else if (settings.url.includes("/cart|remove") || settings.url.includes("/cart/remove")) { type = 'cartremove'; } else if (settings.url.includes("/wishlist|add") || settings.url.includes("/wishlist/add")) { type = 'wishlist'; } else if (settings.url.includes("/compare|add") || settings.url.includes("/compare/add")) { type = 'compare'; } else if (settings.url.includes("/shipping_method|save")) { //OC4 ONLY - Executing Ajax causes confirmation errors urlParams = new URLSearchParams(settings.data); content_name = "shipping"; if (urlParams.has('shipping_method')) { content_name = urlParams.get('shipping_method'); } if (is_cmethod !== null) { for (i = 0; i < is_cmethod["shipping_method"].length; i++) { if (is_cmethod["shipping_method"][i] != '') { (new Function(is_cmethod["shipping_method"][i].replace('#shipping#',content_name)))() } } } } else if (settings.url.includes("/payment_method|save")) {//causes order confirm error //OC4 ONLY - Executing Ajax causes confirmation errors urlParams = new URLSearchParams(settings.data); content_name = "payment"; if (urlParams.has('payment_method')) { content_name = urlParams.get('payment_method'); } if (is_cmethod !== null) { for (i = 0; i < is_cmethod["payment_method"].length; i++) { if (is_cmethod["payment_method"][i] != '') { (new Function(is_cmethod["payment_method"][i].replace('#payment#',content_name)))() } } } } else if (settings.url.includes("/shipping_method/save") || settings.url.includes("/shipping_method/validate")) { //OC3,OC2,OC1 ONLY type = "shipping"; } else if (settings.url.includes("/payment_method/save") || settings.url.includes("/payment_method/validate")) { //OC3,OC2,OC1 ONLY type = "payment"; } else if (settings.url.includes("/superquickcheckout/submit") || settings.url.includes("/superquickcheckout|submit") || settings.url.includes("/buyoneclick/submit") || settings.url.includes("/buyoneclick|submit")) {//module support type = "purchase"; } if (type != null) { $.ajax({ async: true, cache: false, type: 'get', url: 'index.php?route=extension/analytics/script_manager/ajaxSuccess&v='+(new Date()).getTime(), data: settings.data+"&type="+type, dataType: 'json', success: function(result) { if ((typeof doNotTrackMe !== "function" || !doNotTrackMe()) && result !== null && result != '') { (new Function(result))() } } }); } } } }); function sm_consent(accept, suffix, duration) { $('#ism-consent-box').hide(); $('#ism-consent-modal').hide(); var now = new Date(); now.setTime(now.getTime()+duration*86400000); secure_ssl = ' Secure;'; if (location.protocol !== 'https:') { secure_ssl = ''; } document.cookie = 'sm_consent'+suffix+'='+accept+'; expires='+now.toUTCString()+'; path=/; domain=.'+document.domain+'; SameSite=Lax;'+secure_ssl; } function sm_has_consent(consent_add, consent_require, cookie_suffix) { cookie_consent = isGetCookie('sm_consent'+cookie_suffix); if (cookie_consent === '1') { return 1; } if (consent_add && (cookie_consent === '0' || (cookie_consent === '' && consent_require))) { return 0;//cookie not accepted } return 2;//cookie not set and not required } function sm_custom_consents(api_consents) { consents = {}; api_consents.forEach(function (consent) { var is_checked = 0; var is_name = consent.attributes.name.value; if (consent.checked) { is_checked = 1; } consents[is_name]=is_checked; }); secure_ssl = ' Secure;'; if (location.protocol !== 'https:') { secure_ssl = ''; } document.cookie = "sm_api_consents="+JSON.stringify(consents)+"; path=/; SameSite=Lax;"+secure_ssl; } function sm_clear_cookies(cookieList) { var cookieNames = document.cookie.split(/=[^;]*(?:;\s*|$)/); for (var i = 0; i < cookieNames.length; i++) { cookieList.forEach(pattern => {//cookieList must be defined! if (cookieNames[i].includes(pattern)) { root_domain = document.domain.split('.').slice(-2).join('.'); document.cookie = cookieNames[i]+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/; domain=."+root_domain+";"; if (root_domain != document.domain) { document.cookie = cookieNames[i]+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/; domain=."+document.domain+";"; } } }); } } function isGetCookie(cname) { let name = cname + "="; let decodedCookie = decodeURIComponent(document.cookie); let ca = decodedCookie.split(';'); for(let i = 0; i