(function f(){ var d = document, w = window, debug = false, q=w.location.search; function gp(name) { name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), results = regex.exec(q); return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); } if (typeof q === "string") { debug = gp('statdebug'); } if (debug) { console.time("statDebugTime"); } var pix = new Image(), pix2 = new Image(), pix3 = new Image(), SSO_ID = 0, DS_ID = 0, MOS_ID; function getCookie(name) { var matches = document.cookie.match(new RegExp( "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)" )); return matches ? decodeURIComponent(matches[1]) : undefined; } var c = function c(p, a) { var s = d.createElement('SCRIPT'); s.type = "text/javascript"; s.async = (!a)?true:false; s.src = p; return s; } var a = function a(s){ d.getElementsByTagName('BODY')[0].appendChild(s); } var Mcnt = 0; function setM(){ if (debug) { console.info("setM: search MOS_ID"); } MOS_ID = getCookie('mos_id'); if (debug) { console.info("MOS_ID "+MOS_ID); } if (MOS_ID) { Mcnt=6; MOS_ID = escape(MOS_ID); if (debug) { console.info("MOS_ID "+MOS_ID); } pix2.src = 'https://stats.mos.ru/ewa/log/go/dsup?mosid=' + MOS_ID + '&dsid=' + DS_ID; pix3.src = 'https://stats.mos.ru/ewa/log/go/dsup?mosid=' + MOS_ID + '&sso=' + SSO_ID; if (debug) { console.info("loadFacetzCollector"); } (function(i,s,o,g,r,a,m){i["FCTz"]=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments);},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m);})(window, document, "script", "//front.facetz.net/collect.js","fcz");fcz("loadFacetzCollector", "dit_mos", MOS_ID); } else { setTimeout(function(){ Mcnt++; if (Mcnt<6) { setM(); } }, 500); } } var cnt = 0; function metr(){ if (debug) { console.info("metric load start"); } var m = c("https://stats.mos.ru/stats/js/metric.js?ts="+(new Date()).getTime()); m.onload = function(){ if (debug) { console.info("metric loaded"); } setM(); m.onerror = function(){ setTimeout(function(){ if (debug) { console.error("metric load error"); } cnt++; if (cnt<6) { metr(); } }, 100); } }; a(m); } function elkf(){ if (debug) { console.info("xdm loaded"); } if (debug) { console.info("elk load start"); } var elks = c("https://my.mos.ru/static/js/elk-api-0.3.js"); elks.onload = function() { if (debug) { console.info("elk loaded"); } setTimeout(function(){ try { // ELK.ready(function() { if (debug) { console.info(ELK); } if (debug) { console.info("loadUserProfileData"); } if (ELK) { ELK.loadUserProfileData({ blocks: 'REG_DATA', done: function(data) { if (debug) { console.info("done loadUserProfileData"); } if (data.REG_DATA.EMAIL) { SSO_ID = data.REG_DATA.EMAIL; } else { SSO_ID = data.REG_DATA.PHONE_MP; } if (debug) { console.info("SSO_ID "+SSO_ID); } } }); } // }); } catch (e) { if (debug) { console.warn("ELK load exception"); } } }, 10); metr(); }; a(elks); } var xdmc = 0; function xdmf() { var xdm = c("https://my.mos.ru/static/js/easyXDM-2.4.17.1.min.js"); xdm.onload = elkf; if (debug) { console.info("xdm load start"); } xdm.onerror = function(){ if (debug) { console.error("xdm load error"); } xdmc++; if (xdmc<6) { xdmf(); } }; a(xdm); } xdmf(); if (d.all && !d.querySelector) { // ie7- var j = c("https://my.mos.ru/static/js/json2.min.js"); a(j); } if (debug) { console.timeEnd("statDebugTime"); } })();