core/skin/p009.yurecnt.ru/js/tilda-events-1.0.min.js

1 line
14 KiB
JavaScript
Raw Normal View History

2023-04-09 19:52:26 +05:00
window.Tilda=window.Tilda||{},function(){function e(){var e=navigator.userAgent.toLowerCase(),t=-1!==e.indexOf("msie")&&parseInt(e.split("msie")[1]);if(8===t||9===t){var r=document.querySelectorAll(".t-btn");Array.prototype.forEach.call(r,(function(e){var t=e.getAttribute("href");e.querySelector("table")&&t&&-1===t.indexOf("#popup:")&&-1===t.indexOf("#price:")&&e.addEventListener("click",(function(e){var t=e.target.getAttribute("href");e.preventDefault(),window.location.href=t}))}))}try{var a=document.getElementById("allrecords"),i=a?a.getAttribute("data-tilda-cookie"):null;a&&"no"===i||Tilda.saveUTM()}catch(e){}var o=document.querySelectorAll(".r");function d(e){var t=e.target.closest("a.js-click-stat")||e.target.closest(".js-click-zero-stat");if(e.target&&t){var r=t.getAttribute("data-tilda-event-name"),a=t.textContent,i=t.getAttribute("href")||"",o=t.getAttribute("target");if(!r){var d=t.closest(".r"),c;r="/tilda/click/"+(d?d.getAttribute("id"):"")+"/?url="+i}if(Tilda.sendEventToStatistics(r,a),"http"===i.substring(0,4)&&-1===i.indexOf(".typeform.com/"))return window.setTimeout((function(){var e="",t="";if("_blank"===o){if(-1!==i.indexOf("?")&&(e=i.split("?"),i=e[0],-1!==(e=e[1]).indexOf("#")&&(e=e.split("#"),i=i+"#"+e[1],e=e[0]),e=e.split("&")),document.getElementById("tildaredirectform")?(document.getElementById("tildaredirectform").setAttribute("method","GET"),document.getElementById("tildaredirectform").setAttribute("action",i)):document.body.insertAdjacentHTML("beforeend",'<form id="tildaredirectform" target="_blank" method="GET" action="'+i+'" style="display:none;"></form>'),t="",e.length>0)for(var r in e){var a=e[r].indexOf("=");if(a>-1){var d=e[r].substring(0,a),c=e[r].substring(a+1);d&&(t+='<input type="hidden" name="'+d+'" value="'+c+'">')}}if(""===t)window.open(i,"_blank");else{var n=document.getElementById("tildaredirectform");n&&(n.innerHTML=t,n.submit())}}else window.location.href=i}),300),e.preventDefault(),!1}}Array.prototype.forEach.call(o,(function(e){e.removeEventListener("click",d),e.addEventListener("click",d)}));var c=document.querySelectorAll("input.js-amount");Array.prototype.forEach.call(c,(function(e){var t=e.value;t=t.replace(/,/g,"."),t=parseFloat(t.replace(/[^0-9\.]/g,"")),e.value=t}))}Tilda.sendEcommerceEvent=function(e,t){if(void 0===t||0===t.length)return!1;if(void 0===e||"add"!==e&&"remove"!==e&&"purchase"!==e&&"detail"!==e)return!1;for(var r,a="",i=0,o=[],d,c,n="",m="",l="",u=0;u<t.length;u++){a>""&&(a+=", "),a+=(c=t[u]).name,i+=c.price,d="",void 0!==c.options&&c.options.length>0&&Array.prototype.forEach.call(c.options,(function(e){d+=e.option+": "+e.variant+"; "}));var p={name:c.name,price:c.price,variant:d,quantity:1};c.id&&c.id>0&&(id=c.id,p.id=c.id),c.uid&&c.uid>0&&(m=c.uid,p.uid=c.uid),c.recid&&c.recid>0&&(n=c.recid,p.recid=c.recid),c.lid&&c.lid>0&&(l=c.lid,p.lid=c.lid),c.sku&&c.sku>0&&(p.sku=c.sku),o[o.length]=p}var p;"add"!==e&&"remove"!==e||(r="/tilda/cart/"+e+"/",n>0&&(r+=""+n),m>0?r+="-u"+m:l>0&&(r+="-"+l)),"detail"===e&&(r="/tilda/product/detail/",m>0?r+=m+"/":(n>0&&(r+="r"+n),l>0&&(r+="-l"+l))),"purchase"===e&&(r="/tilda/rec"+n+"/payment/"),(p={ecommerce:{}}).ecommerce[e]={products:o},Tilda.sendEventToStatistics(r,a,p,i)},Tilda.sendEventToStatistics=function(e,t,r,a){var i="/"===e.substring(0,1),o=[],d,c;(d=document.getElementById("allrecords"))&&(c=null!==d.getAttribute("data-fb-event")?d.getAttribute("data-fb-event"):window.jQuery&&void 0!==$("#allrecords").data("fb-event")?$("#allrecords").data("fb-event"):null);var n=!(!c||"nosend"!==c),m=d?d.getAttribute("data-vk-event"):null;d&&(m=null!==d.getAttribute("data-vk-event")?d.getAttribute("data-vk-event"):window.jQuery&&void 0!==$("#allrecords").data("vk-event")?$("#allrecords").data("vk-event"):null);var l=!(!m||"nosend"!==m),u="",p=document.querySelector(".t706");if(u=d.getAttribute("data-tilda-currency")?d.getAttribute("data-tilda-currency"):p&&p.getAttribute("data-project-currency-code")?p.getAttribute("data-project-currency-code"):"RUB",r||(r=window.location.href),(a=a?parseFloat(a):0)>0)if(window.dataLayer||(window