Advertisement
Guest User

Untitled

a guest
Dec 13th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.61 KB | None | 0 0
  1. window.SV = {"sva": "LE-000001-001"};/* -- */
  2. window.SV_JSON = JSON;/* -- */
  3.  
  4. (function(){if(!('indexOf'in Array.prototype)){Array.prototype.indexOf=function(elm){for(var key in this){if(this[key]==elm)return key;}
  5. return-1;};}
  6. var sess=null;if(window.name&&window.name.length==38){sess=window.name.substring(2);}
  7. if(!sess){var m=(/sv=@@([0-9a-f-]{36})/i).exec(document.cookie);if(m){sess=m[1];}}
  8. window.SV=window.SV||{};var q=new Array();for(var key in window.SV){q.push(encodeURIComponent(key)+'='+encodeURIComponent(window.SV[key]));}
  9. q.push('a=gt');if(sess){q.push('svs='+sess);}
  10. q.push('u='+encodeURIComponent(''+window.location));q.push('r='+encodeURIComponent(''+(document.referrer||'')));q.push('t='+1*(new Date()));window.SV_XHR_O=window.SV_XHR(q.join('&'));})();
  11.  
  12. 'use strict';var SalesViewer;(function(SalesViewer){var Tracker=(function(){var svCkRgx=/sv=@@([0-9a-f-]{36})/i;function Tracker(acc,sessionId,visitId,features,endpoint){this.features=[];this.socketIoFound=false;this.isConnected=false;this.endpoint='https://www.salesviewer.com/tracker/track';this.eventQueue=[];if(features.length<1){for(var k in Tracker.installedTrackers){features.push(k);}}
  13. this.features=features;this.setSessionIdPersistent(sessionId);if(endpoint){this.endpoint=endpoint;}
  14. this.visitId=visitId;this.account=acc;this.startTracking();}
  15. Tracker.prototype.setSessionIdPersistent=function(sessId){sessId=sessId||this.sessionId;if(typeof window.unblu!=='undefined'){this.debug('[session] persist id using cookies: '+sessId);document.cookie='sv='+escape('@@'+sessId);this.debug(document.cookie);}
  16. else{window.name='@@'+sessId;this.debug('[session] persist id using JS-session: '+sessId);}
  17. return this.sessionId=sessId;};Tracker.prototype.debug=function(){var args=[];for(var _i=0;_i<(arguments.length-0);_i++){args[_i]=arguments[_i+0];}
  18. try{if(window&&window.location&&window.location.search&&window.location.search.indexOf('debug')>-1&&console&&'log'in console){if(typeof console.log=='function')console.log.apply(console,args);else console.log(args);}}catch(e){}};Tracker.prototype.startTracking=function(){var _this=this;this.debug('start tracking');for(var k in this.features){if(typeof k=="string"&&typeof this.features[k]=="string"){this.activateDataTracker(this.features[k]);}}
  19. this.debug('activation done');this.addListener(window,'unload',function(){return _this._doTrackSendLoop(true);});this._doTrackSendLoop();};Tracker.prototype._doTrackSendLoop=function(kill){var _this=this;if(typeof kill==="undefined"){kill=false;}
  20. var timeout=1000;if(this.eventQueue.length){var evtQueue=[];var c=0;while(this.eventQueue.length&&c++<99){evtQueue.push(this.eventQueue.shift());}
  21. if(c>99){timeout=100;}
  22. var data=this.getDataObject();data.a='t';var now=+new Date();for(var key in evtQueue){evtQueue[key]['delta']=now-evtQueue[key]['ts'];delete evtQueue[key]['ts'];}
  23. data['events']=evtQueue.sort(function(a,b){return a['ts']-b['ts'];});Tracker.xhrRequest(this.endpoint,data,function(){_this.debug('[XHR] done');kill||setTimeout(function(){return _this._doTrackSendLoop();},timeout);});}else{kill||setTimeout(function(){return _this._doTrackSendLoop();},timeout);}};Tracker.prototype.getObjectScalarData=function(obj){if(typeof obj!=='object'){return obj;}
  24. var ret={};for(var k in obj){if(typeof obj[k]==='object'){continue;}
  25. ret[k]=obj[k];}
  26. return ret;};Tracker.prototype.getDataObject=function(){var args=[];for(var _i=0;_i<(arguments.length-0);_i++){args[_i]=arguments[_i+0];}
  27. var d=this.sessionId?{svs:this.sessionId}:{};if(this.account){d['sva']=this.account;}
  28. if(this.visitId){d['svv']=this.visitId;}
  29. for(var i in args){for(var k in args[i]){d[k]=this.getObjectScalarData(args[i][k]);}}
  30. return d;};Tracker.prototype.getScreenData=function(){var w=window,d=document.documentElement,b=document.body;return{w:w.innerWidth||d.clientWidth||b.clientWidth||0,h:w.innerHeight||d.clientHeight||b.clientHeight||0,x:(w['scrollLeft']||d.scrollLeft||b.scrollLeft||0)-(d.clientLeft||0),y:(w['scrollTop']||d.scrollTop||b.scrollTop||0)-(d.clientTop||0)};};Tracker.prototype.aquireSessionData=function(){return{userAgent:navigator.userAgent,language:navigator.language,screen:this.getScreenData()};};Tracker.prototype.aquireVisitData=function(){return{url:document.location.href,referrer:document.referrer};};Tracker.installDataTracker=function(dt){Tracker.installedTrackers[dt.featureName]=dt;};Tracker.prototype.activateDataTracker=function(featureName){var _this=this;if(!(featureName in Tracker.installedTrackers)){throw'Tracker "'+featureName+'" not installed!';}
  31. var dt=Tracker.installedTrackers[featureName];dt.bind.call(this,(function(args,delta){try{_this.trackEvent(dt.featureName,args,delta);}catch(e){}}));this.debug('[Tracker] DataTracker "'+featureName+'" activated...');};Tracker.setXHR=function(xhr){Tracker._xhr=xhr;};Tracker.load=function(lex){try{}catch(e){console&&console.log&&console.log(e);}
  32. var tracker=new Tracker(lex.sva||'',lex.svs||'',lex.svv||-1,[],lex.endpoint||undefined);return tracker;};Tracker.prototype.trackEvent=function(eventType,evtArgs,timeDelta){this.debug('emit visit_event',eventType,evtArgs);timeDelta=timeDelta||0;this.eventQueue.push({type:eventType,args:evtArgs,ts:(+new Date())-timeDelta});};Tracker.getIndex=function(node){var parent=node.parentElement||node.parentNode,i=-1,child;while(parent&&(child=parent.childNodes[++i])){if(child==node){return i;}}
  33. return-1;};Tracker.getPath=function(node){var parent,path=[],index=Tracker.getIndex(node);(parent=node.parentElement||node.parentNode)&&(path=Tracker.getPath(parent));index>-1&&path.push(index);return path;};Tracker.getCursor=function(e){e=e||window.event;var cursor={x:0,y:0};cursor.x=e.pageX?e.pageX:e.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft)-(document.documentElement.clientLeft||0);cursor.y=e.pageY?e.pageY:e.clientY+(document.documentElement.scrollTop||document.body.scrollTop)-(document.documentElement.clientTop||0);return cursor;};Tracker.xhrRequest=function(url,data,callback){if(Tracker._xhr===null){throw'xhr not supported :(';}
  34. var pairs=[];for(var key in data){pairs.push(encodeURIComponent(key)+'='+(typeof data[key]=='string'?encodeURIComponent(data[key]):window.SV_JSON.stringify(data[key])));}
  35. var queryString=pairs.join('&');try{Tracker._xhr=Tracker.getXhr();Tracker._xhr.open('POST',url,true);if(data&&'setRequestHeader'in Tracker._xhr){Tracker._xhr.setRequestHeader('Content-type','application/x-www-form-urlencoded');}
  36. Tracker._xhr.onload=function(){(callback?callback:function(){})(Tracker._xhr);};Tracker._xhr.onerror=function(){throw'Tracker._xhr.onerror';}
  37. Tracker._xhr.send(queryString);}catch(e){throw e;}
  38. return true;};Tracker.getXhr=function(){var o=(window['XDomainRequest']||window['XMLHttpRequest']||false);if(!o)throw'no_xhr';o.timeout=2000;return new o();};Tracker.prototype.addListener=function(elm,name,cb){if(typeof elm.addEventListener!="undefined"){return elm.addEventListener(name,cb);}
  39. if(typeof elm.attachEvent!="undefined"){return elm.attachEvent('on'+name,cb);}
  40. return null;};Tracker.installedTrackers={};Tracker.body=document.body;Tracker._xhr=null;return Tracker;})();SalesViewer.Tracker=Tracker;})(SalesViewer||(SalesViewer={}));/* -- */
  41.  
  42. SalesViewer.Tracker.installDataTracker({featureName:'mc',bind:function(cb){return this.addListener(document.body,'mouseup',function(e){var data=SalesViewer.Tracker.getCursor(e);var elem=e.target||event.srcElement;if(elem){data.path=(SalesViewer.Tracker.getPath(e.target||event.srcElement)||[]).join(',');data.tagName=elem.tagName.toLowerCase();if(['a','button'].indexOf(data.tagName)>-1){data.text=elem.innerText;}}
  43. return cb(data);});}});/* -- */
  44.  
  45. SalesViewer.Tracker.installDataTracker({featureName:'mp',bind:function(cb){var throttleTime=10;var _to=null;return this.addListener(document.body,'mousemove',function(e){clearTimeout(_to);var data=SalesViewer.Tracker.getCursor(e);_to=setTimeout(function(){return cb(data,throttleTime);},throttleTime);});}});/* -- */
  46.  
  47. SalesViewer.Tracker.installDataTracker({featureName:'nav',bind:function(cb){this.addListener(window,'load',function(e){return cb({load:true});});this.addListener(window,'unload',function(e){return cb({unload:true});});return this.addListener(window,'beforeunload',function(e){return cb({unload:true});});}});/* -- */
  48.  
  49. SalesViewer.Tracker.installDataTracker({featureName:'rv',bind:function(cb){var throttleTime=100;var _to=null;var trkr=this;var func=function(){if(_to===null){cb(trkr.getScreenData());}
  50. clearTimeout(_to);_to=setTimeout(function(){_to=null;return cb(trkr.getScreenData(),throttleTime);},throttleTime);};this.addListener(window,'resize',func);this.addListener(window,'scroll',func);this.addListener(window,'beforeunload',function(e){cb(trkr.getScreenData());});this.addListener(window,'unload',function(e){cb(trkr.getScreenData());});cb(trkr.getScreenData());}});/* -- */
  51.  
  52. SalesViewer.Tracker.installDataTracker({featureName:'tc',bind:function(cb){return this.addListener(document.body,'touchend',function(e){var data=SalesViewer.Tracker.getCursor(e.changedTouches[0]);var elem=e.target||event.srcElement;if(elem){data.path=(SalesViewer.Tracker.getPath(e.target||event.srcElement)||[]).join(',');data.tagName=elem.tagName.toLowerCase();if(['a','button'].indexOf(data.tagName)>-1){data.text=elem.innerText;}}
  53. return cb(data);});}});/* -- */
  54.  
  55. SalesViewer.Tracker.installDataTracker({featureName:'tp',bind:function(cb){return this.addListener(document.body,'touchmove',function(e){var data=SalesViewer.Tracker.getCursor(e.changedTouches[0]);return cb(data);});}});/* -- */
  56. window.SV_XHR_O.onload = function(){}; SalesViewer.Tracker.setXHR(window.SV_XHR_O);/* -- */
  57. SalesViewer.Tracker.load({"sva":"LE-000001-001","svs":"711e6c42-5887-46d7-9280-cc602b956e31","svv":"5329552","endpoint":"https:\/\/salesviewer.org"})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement