yastat.js 1.6 KB

1
  1. window._adstat_||(window._adstat_={ya:null,loadScrit:function(t,e){var a=document.createElement("script");a.type="text/javascript",a.src=t,+[1]?a.onload=e:a.onreadystatechange=function(){var t=a.readyState;("loaded"===t||"complete"===t)&&(a.onreadystatechange=null,e())},document.getElementsByTagName("head")[0].appendChild(a)},listenEvent:function(t,e,a){"undefined"!=typeof t.addEventListener?(t.removeEventListener(e,a,!1),t.addEventListener(e,a,!1)):(t.detachEvent("on"+e,a),t.attachEvent("on"+e,a))},reportEvent:function(t,e,a){_adstat_.ya||(_adstat_.ya=new YA.report.YYAnalytics("resource")),_adstat_.ya.reportProductEvent({eid:t+"/"+e,adid:a})},traverse:function(t){if(!t._lsf_){for(var e=null,a=null,n=null,d=0;d<t.attributes.length&&(!e&&!a||!n);d++){var o=t.attributes[d];"dw_adid"==o.nodeName||"adid"==o.nodeName?e=o.nodeValue:"dw_fadid"==o.nodeName||"fadid"==o.nodeName?a=o.nodeValue:("dw_rsid"==o.nodeName||"rsid"==o.nodeName)&&(n=o.nodeValue)}if(e&&n)_adstat_.reportEvent("load",n,e),t._lsf_=t._lsf_||function(){_adstat_.reportEvent("click",n,e)},_adstat_.listenEvent(t,"click",t._lsf_);else if(a&&n)_adstat_.reportEvent("load",n,a),t._lsf_=t._lsf_||function(){_adstat_.reportEvent("click",n,a)},_adstat_.listenEvent(t,"mousedown",t._lsf_);else if(t.childNodes.length)for(var i=0;i<t.childNodes.length;i++){var s=t.childNodes[i];1==s.nodeType&&_adstat_.traverse(s)}}},init:function(){"undefined"==typeof YA?_adstat_.loadScrit(location.protocol+"//pub.dwstatic.com/common/js/ya.js",_adstat_.init):_adstat_.traverse(document.body)}},window._lsf_=window._lsf_||function(){_adstat_.init()},_adstat_.listenEvent(window,"load",window._lsf_));