forked from docker/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmunchkin.js
20 lines (20 loc) · 7.59 KB
/
munchkin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*
* Copyright (c) 2007-2015, Marketo, Inc. All rights reserved.
* Marketo marketing automation web activity tracking script
* Version: 151 r601
*/
(function(l){if(!l.MunchkinTracker){var k=l.document,p=k.location,w=encodeURIComponent,x=[],r=function(b,a,c,d){try{var f=function(){try{c.apply(this,arguments)}catch(a){}};b.addEventListener?b.addEventListener(a,f,d||!1):b.attachEvent&&b.attachEvent("on"+a,f);x.push([b,a,f,d])}catch(g){}},L=function(b,a,c,d){try{b.removeEventListener?b.removeEventListener(a,c,d||!1):b.detachEvent&&b.detachEvent("on"+a,c)}catch(f){}},e=function(b){return"undefined"!==typeof b&&null!==b},y=function(b,a){return b.className.match(RegExp("(\\s|^)"+
a+"(\\s|$)"))},M=e(l.XMLHttpRequest)&&e((new l.XMLHttpRequest).withCredentials),q=function(b){var a=null,c;if(e(b))if(0===b.length)a="";else try{a=decodeURIComponent(b)}catch(d){c=b.indexOf("?");if(-1!==c)try{a=decodeURIComponent(b.substr(0,c))+b.substr(c)}catch(f){}e(a)||(a=String(b))}return a},z=function(b,a){var c={},d=e(a)?a:"=",f=b.split("&"),g=f.length,h,m,k;for(h=0;h<g;h+=1)m=f[h].split(d),e(m)&&1<m.length&&(k=m.shift(),m=m.join(d),c[q(k)]=q(m));return c},A=function(b){try{var a=k.createElement("a");
a.href=b;return z(a.search.substr(1))}catch(c){return null}},B=function(b,a){var c=null,d=[];if(e(b))for(c in b)b.hasOwnProperty(c)&&"function"!==typeof b[c]&&d.push(w(c)+(e(a)?a:"=")+w(b[c]));return d.join("&")},C=function(b,a){var c=null;if(e(a)&&e(b))for(c in b)b.hasOwnProperty(c)&&e(a[c])&&(b[c]=a[c])},G=function(b){var a=k.cookie,c,d,f={id:null,token:null};b=w(b);f.store=function(a,c,d,f){var e=b+"="+B(this,":"),h=new Date;0<a&&(h.setTime(h.getTime()+864E5*a),e+="; expires="+h.toGMTString());
c&&(e+="; path="+c);d&&-1!==d.indexOf(".")&&(e+="; domain="+d);f&&(e+="; secure");k.cookie=e};if(""!==a)for(a=a.split(";"),c=0;c<a.length;c+=1)if(d=a[c].replace(/^\s+|\s+$/g,""),0===d.indexOf(b+"=")){a=d.substring(b.length+1);c=z(a);e(c.id)&&e(c.token)?C(f,c):C(f,z(a,":"));break}return f},h={customName:null,notifyPrefix:null,wsInfo:null,altIds:[],visitorToken:null,cookieLifeDays:730,clickTime:350,cookieAnon:!0,mkt_tok:null,domainLevel:null,replayDetectLimit:5E3,httpsOnly:!1,asyncOnly:!1},D=null,n=
null,N=l.navigator.cookieEnabled||k.hasOwnProperty("cookie")&&(0<k.cookie.length||-1<(k.cookie="testcookie=test; max-age=10000").indexOf.call(k.cookie,"testcookie=test;")),u=!1,v=[],E=null,O=function(b,a,c){var d=new l.XMLHttpRequest;d.open("GET",b,!0!==a);d.onreadystatechange=function(){2<=d.readyState&&d.abort()};if(a)try{d.timeout=c}catch(f){}try{d.send()}catch(e){}},H=function(b,a,c,d,e){b=b+a+"&"+B(c)+"&"+B(d);c=(new Date).getTime();e=!e&&!h.asyncOnly;0===a.indexOf("webevents/visitWebPage?")&&
(e=!1);M?O(b,e,h.clickTime):(new l.Image(1,1)).src=b;E=c+h.clickTime},P=function(){var b;return function(a,c){var d={x:a.clientX,y:a.clientY,el:c,time:(new Date).getTime()};if(e(b)&&d.x===b.x&&d.y===b.y&&d.el===b.el&&d.time<b.time+h.replayDetectLimit)return!0;b=d;return!1}}(),I=function(){var b=k.getElementsByName("_mkt_trk"),a=0,c="";e(n)&&(c="id:"+n.id+"&token:"+n.token);for(a=0;a<b.length;a+=1)"hidden"===b[a].type&&(b[a].value=c)},s=function(b,a,c,d){var f=null,g;g=p.hostname;var k=p.protocol,
m="webevents/"+b;if(!u)v.push(["post",arguments]);else if(e(n)&&(a._mchId=n.id,a._mchTk=n.token,e(h.mkt_tok)&&(a.mkt_tok=h.mkt_tok),e(h.wsInfo)&&(a._mchWs=h.wsInfo),"clickLink"===b&&(a._mchCn=e(h.customName)?h.customName:""),a._mchHo=g,a._mchPo=p.port,e(a._mchRu)||(a._mchRu=q(p.pathname)),a._mchPc=k,a._mchVr="151",e(g)&&0!==g.length&&"file:"!==k))for(f in m+="?_mchNc="+(new Date).getTime(),H(h.notifyPrefix,m,a,c,d),h.altIds)h.altIds.hasOwnProperty(f)&&(g=h.altIds[f],a._mchId=g,H(h.notifyPrefix.replace(/\w{3}\-\w{3}\-\w{3}\.mktoresp\.com/i,
g+".mktoresp.com"),m,a,c,d))},J=function(b){var a=b||l.event,c=a.target||a.srcElement,d={},f;f=a.which;var g=a.button;f=e(f)&&(1===f||2===f)||e(g)&&(0===g||1===g||4===g)?!0:!1;if(f&&!a._mchDone){a._mchDone=!0;a=c;f=p.href||p;for(-1<f.indexOf("#")&&(f=f.substring(0,f.indexOf("#")));"A"!==a.tagName&&"AREA"!==a.tagName&&e(a.parentNode);)a=a.parentNode;a===k||a===l||"A"!==a.tagName&&"AREA"!==a.tagName?a=null:(c=a.href.replace(/^\s+|\s+$/g,""),a=e(c)&&0<c.length&&0!==c.indexOf("#")&&0!==c.indexOf(f+"#")&&
0!==c.indexOf("javascript")&&0!==c.indexOf("mailto")&&!y(a,"mchNoDecorate")?a:null);e(a)&&!P(b,a)&&(d._mchHr=q(a.href),s("clickLink",d))}},t=function(b){if(u){if(null!==n)return n;var a;a:{a=p.hostname;var c=h.domainLevel,d=a.split("."),f=d.length,g=2;if(e(c))g=c;else if(2<d[f-1].length)g=2;else if(2===d[f-1].length)g=3;else break a;for(;d.length>g&&2<d.length;)d.shift();a=d.join(".")}c=G("_mkto_trk");d=!1!==h.httpsOnly;if(e(c.id)||h.cookieAnon||b){if(c.id=D,e(c.token)||(e(h.visitorToken)&&"VISITOR_MKTTOK_REPLACE"!==
h.visitorToken?c.token=h.visitorToken:c.token="_mch-"+a+"-"+(new Date).getTime()+"-"+(Math.floor(9E4*Math.random())+1E4)),c.store(h.cookieLifeDays,"/",a,d),d&&(c=G("_mkto_trk")),!d||e(c.id))return n=c,I(),c}else return null}else v.push(["createTrackingCookie",arguments])},K=function(){t(!0)},Q=function(b){var a=b.onclick;b.onclick="function"===typeof a?function(){K.apply(b,arguments);return a.apply(b,arguments)}:K},F={ASSOCIATE_LEAD:"associateLead",CLICK_LINK:"clickLink",VISIT_WEB_PAGE:"visitWebPage",
init:function(b,a){if(N&&e(b)&&0!==b.length){D=b;var c="",d,f,g;d=A(l.location.toString());h.notifyPrefix=p.protocol+"//"+D+".mktoresp.com/";e(a)&&C(h,a);e(d)&&(e(d.mkt_tok)&&(h.mkt_tok=d.mkt_tok),e(d.lpview)&&(c=d.lpview));if(!e(h.mkt_tok))if(d=A(k.referrer),e(d.mkt_tok))h.mkt_tok=d.mkt_tok;else if(e(d.enid)&&e(d.type))for(g in d)d.hasOwnProperty(g)&&"enid"!==g&&"type"!==g&&(-1<g.indexOf("mkt_tok")||-1<d[g].indexOf("mkt_tok"))&&(f=A(g+"="+d[g]),e(f.mkt_tok)&&(h.mkt_tok=f.mkt_tok));if(!("preview"===
c&&/\/lpeditor\/preview$/.test(p.pathname)||u)){u=!0;c=t(e(h.mkt_tok));d={};for(f={};0<v.length;)switch(g=v.shift(),g[0]){case "createTrackingCookie":c=t.apply(k,g[1]);break;case "post":s.apply(k,g[1])}if(e(c))d._mchCn=e(h.customName)?h.customName:"",f._mchHa=q(p.hash),f._mchRe=q(k.referrer),f._mchQp=q(p.search.substr(1).replace(/&/g,"__-__")),s("visitWebPage",d,f,!0);else if(!(h.cookieAnon||e(l.Mkto)&&e(l.Mkto.formSubmit))){c=[];g=k.forms;d=g.length;var n,m,r;for(f=0;f<d;f+=1)if(y(g[f],"lpeRegForm"))for(m=
g[f].elements,r=m.length,n=0;n<r;n+=1)"submit"!==m[n].type||y(m[n],"mchNoDecorate")||c.push(m[n]);for(g=0;g<c.length;g+=1)Q(c[g])}}}},munchkinFunction:function(b,a,c){var d={},f={},g=null;e(c)&&(d._mchKy=c);switch(b){case "associateLead":for(g in a)a.hasOwnProperty(g)&&(d["_mchAt"+g]=a[g]);t(!0);s("associateLead",d);break;case "clickLink":e(a.href)&&(d._mchHr=d._mchLr=q(a.href));s("clickLink",d);break;case "visitWebPage":e(a.url)&&(d._mchRu=q(a.url)),e(a.params)&&(d._mchQp=q(a.params.replace(/&/g,
"__-__"))),e(a.name)&&(d._mchCn=a.name),f._mchRe=q(p.href),s("visitWebPage",d,f)}},createTrackingCookie:function(b){t(b)}};Date.prototype.getTimeAlias=Date.prototype.getTime;r(l,"beforeunload",function(){for(var b;0<x.length;)b=x.shift(),L.apply(this,b);if(e(E)){do b=new Date;while(b.getTimeAlias()<E)}});r(k,"click",J,!0);(function(b){var a=!1,c=!0,d=k.documentElement,e=function(c){"readystatechange"===c.type&&"complete"!==k.readyState||a||(a=!0,b.call(l,c.type||c))},g=null,g=function(){try{d.doScroll("left")}catch(a){l.setTimeout(g,
50);return}e("poll")};if("complete"===k.readyState)b.call(l,"lazy");else{if(k.createEventObject&&d.doScroll){try{c=!l.frameElement}catch(h){}c&&g()}r(k,"DOMContentLoaded",e);r(k,"readystatechange",e);r(l,"load",e)}})(function(){I();var b=0;if(e(k.links))for(b=0;b<k.links.length;b+=1)r(k.links[b],"click",J,!0)});l.MunchkinTracker=l.Munchkin=F;l.mktoMunchkin=F.init;l.mktoMunchkinFunction=F.munchkinFunction}})(window);