Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function(win, doc, value) {
- /**
- * @param {string} allBindingsAccessor
- * @param {string} depMaps
- * @param {?} rootjQuery
- * @param {?} deepDataAndEvents
- * @return {?}
- */
- function init(allBindingsAccessor, depMaps, rootjQuery, deepDataAndEvents) {
- /**
- * @param {number} val1
- * @return {undefined}
- */
- function tick(val1) {
- /** @type {number} */
- var val2 = (new Date).getTime();
- if (val1) {
- if (val2 < val1) {
- ROOM_SIZE += val1 - val2 + 20;
- }
- }
- self.setTimeout(function() {
- tick(val2);
- }, 20, "timeCorrector");
- }
- /**
- * @return {?}
- */
- function remove() {
- var maxY = (new Date).getTime() + ROOM_SIZE;
- if (maxY < y) {
- maxY = y + 10;
- }
- return y = maxY;
- }
- /**
- * @return {?}
- */
- function get() {
- return Math.round((remove() - newMethods) / 50);
- }
- /**
- * @param {Array} err
- * @param {number} val
- * @return {undefined}
- */
- function cb(err, val) {
- /** @type {number} */
- val = Math.max(0, Math.min(val, 65535));
- self.mergeArrays(err, [val >> 8, val & 255]);
- }
- /**
- * @param {Array} arg
- * @param {number} opt_attributes
- * @return {undefined}
- */
- function fail(arg, opt_attributes) {
- self.mergeArrays(arg, [opt_attributes & 255]);
- }
- /**
- * @param {Array} arg
- * @param {number} value
- * @return {undefined}
- */
- function debug(arg, value) {
- /** @type {number} */
- value = Math.max(0, value | 0);
- for (;127 < value;) {
- self.mergeArrays(arg, [value & 127 | 128]);
- value >>= 7;
- }
- self.mergeArrays(arg, [value]);
- }
- /**
- * @param {Array} err
- * @param {string} key
- * @return {undefined}
- */
- function next(err, key) {
- if (255 < key.length) {
- key = key.substr(0, 255);
- }
- self.mergeArrays(err, [key.length]);
- /** @type {number} */
- var characterPosition = 0;
- for (;characterPosition < key.length;characterPosition++) {
- cb(err, key.charCodeAt(characterPosition));
- }
- }
- /**
- * @param {Array} e
- * @param {string} d
- * @return {undefined}
- */
- function complete(e, d) {
- debug(e, d.length);
- /** @type {number} */
- var i = 0;
- for (;i < d.length;i++) {
- debug(e, d.charCodeAt(i));
- }
- }
- /**
- * @param {number} id
- * @param {string} filename
- * @param {Array} result
- * @param {Array} loadingLang
- * @param {boolean} key
- * @param {boolean} callback
- * @return {?}
- */
- function load(id, filename, result, loadingLang, key, callback) {
- var header;
- for (;result && ((header = dom.getElementSize(result)) && (!header[0] || !header[1]));) {
- result = dom.getElementParent(result);
- }
- if (!result) {
- return null;
- }
- header = result[name];
- if (!header || 0 > header) {
- return null;
- }
- var attributes = {
- mousemove : 2,
- click : 32,
- dblclick : 33,
- mousedown : 4,
- mouseup : 30,
- touch : 12
- }[filename];
- if (!attributes) {
- return null;
- }
- var dependentResult = dom.getElementXY(result);
- /** @type {Array} */
- result = [];
- fail(result, attributes);
- debug(result, id);
- debug(result, header);
- debug(result, Math.max(0, loadingLang[0] - dependentResult[0]));
- debug(result, Math.max(0, loadingLang[1] - dependentResult[1]));
- if (/^mouse(up|down)|click$/.test(filename)) {
- id = key || callback;
- fail(result, 2 > id ? 1 : id == (key ? 2 : 4) ? 4 : 2);
- }
- return result;
- }
- /**
- * @param {number} id
- * @param {number} json
- * @param {Array} chunk
- * @param {number} opt_attributes
- * @return {?}
- */
- function parser(id, json, chunk, opt_attributes) {
- json = json[name];
- if (!json || 0 > json) {
- return null;
- }
- /** @type {Array} */
- var ex = [];
- fail(ex, 31);
- debug(ex, id);
- debug(ex, json);
- debug(ex, chunk[0]);
- debug(ex, chunk[1]);
- fail(ex, 0);
- fail(ex, 0);
- fail(ex, opt_attributes);
- return ex;
- }
- /**
- * @param {number} id
- * @param {Array} item
- * @return {?}
- */
- function text(id, item) {
- /** @type {Array} */
- var ex = [];
- fail(ex, 3);
- debug(ex, id);
- debug(ex, item[0]);
- debug(ex, item[1]);
- return ex;
- }
- /**
- * @param {number} val
- * @param {Array} captures
- * @param {number} template
- * @return {?}
- */
- function include(val, captures, template) {
- /** @type {Array} */
- var ex = [];
- template = template[name];
- if (!template || 0 > template) {
- return null;
- }
- fail(ex, 16);
- debug(ex, val);
- debug(ex, captures[0]);
- debug(ex, captures[1]);
- debug(ex, template);
- return ex;
- }
- /**
- * @param {number} d
- * @param {Array} data
- * @param {Array} start1
- * @return {?}
- */
- function change(d, data, start1) {
- /** @type {Array} */
- var ex = [];
- fail(ex, 28);
- debug(ex, d);
- debug(ex, data[0]);
- debug(ex, data[1]);
- debug(ex, start1[0]);
- debug(ex, start1[1]);
- return ex;
- }
- /**
- * @param {number} val
- * @param {number} res
- * @param {number} attributes
- * @param {Object} map
- * @return {?}
- */
- function save(val, res, attributes, map) {
- /** @type {Array} */
- var ex = [];
- fail(ex, 5);
- debug(ex, val);
- cb(ex, res);
- fail(ex, attributes);
- val = map[name];
- if (!val || 0 > val) {
- /** @type {number} */
- val = 0;
- }
- debug(ex, val);
- return ex;
- }
- /**
- * @param {number} d
- * @param {string} values
- * @return {?}
- */
- function success(d, values) {
- var resp;
- var val;
- if (0 == values.length) {
- /** @type {string} */
- val = resp = "";
- } else {
- if (100 >= values.length) {
- /** @type {string} */
- resp = values;
- /** @type {string} */
- val = "";
- } else {
- if (200 >= values.length) {
- resp = values.substr(0, 100);
- val = values.substr(100);
- } else {
- resp = values.substr(0, 97);
- val = values.substr(values.length - 97);
- }
- }
- }
- /** @type {Array} */
- var e = [];
- fail(e, 29);
- debug(e, d);
- complete(e, resp);
- complete(e, val);
- return e;
- }
- /**
- * @param {number} object
- * @return {?}
- */
- function clone(object) {
- /** @type {Array} */
- var e = [];
- fail(e, 27);
- debug(e, object);
- return e;
- }
- /**
- * @param {number} er
- * @return {?}
- */
- function onerror(er) {
- /** @type {Array} */
- var ex = [];
- fail(ex, 14);
- debug(ex, er);
- return ex;
- }
- /**
- * @param {number} desc
- * @return {?}
- */
- function ok(desc) {
- /** @type {Array} */
- var ex = [];
- fail(ex, 15);
- debug(ex, desc);
- return ex;
- }
- /**
- * @param {number} ms
- * @param {Object} data
- * @return {?}
- */
- function timeout(ms, data) {
- /** @type {Array} */
- var ex = [];
- fail(ex, 17);
- debug(ex, ms);
- debug(ex, data[name]);
- return ex;
- }
- /**
- * @param {number} path
- * @param {Object} data
- * @return {?}
- */
- function destroy(path, data) {
- /** @type {Array} */
- var ex = [];
- fail(ex, 18);
- debug(ex, path);
- debug(ex, data[name]);
- return ex;
- }
- /**
- * @param {number} er
- * @param {Object} data
- * @param {?} str
- * @return {?}
- */
- function done(er, data, str) {
- /** @type {Array} */
- var ex = [];
- fail(ex, 19);
- debug(ex, er);
- debug(ex, data[name]);
- next(ex, String(str));
- return ex;
- }
- /**
- * @param {Object} node
- * @return {?}
- */
- function check(node) {
- var val = node[name];
- if (!val || (0 > val || (!/^INPUT|SELECT|TEXTAREA$/.test(node.nodeName) || (!node.form || $(node.form))))) {
- return null;
- }
- var pdataOld = dom.getFormNumber(node.form);
- if (0 > pdataOld) {
- return null;
- }
- var udataCur;
- udataCur = "INPUT" == node.nodeName ? {
- text : 0,
- color : 0,
- date : 0,
- datetime : 0,
- "datetime-local" : 0,
- email : 0,
- number : 0,
- range : 0,
- search : 0,
- tel : 0,
- time : 0,
- url : 0,
- month : 0,
- week : 0,
- password : 2,
- radio : 3,
- checkbox : 4,
- file : 6,
- image : 7
- }[node.type] : {
- SELECT : 1,
- TEXTAREA : 5
- }[node.nodeName];
- if ("number" != typeof udataCur) {
- return null;
- }
- /** @type {number} */
- var n = -1;
- var result = node.form.elements;
- var iLength = result.length;
- /** @type {number} */
- var i = 0;
- /** @type {number} */
- var step = 0;
- for (;i < iLength;i++) {
- if (result[i].name == node.name) {
- if (result[i] == node) {
- /** @type {number} */
- n = step;
- break;
- }
- step++;
- }
- }
- if (0 > n) {
- return null;
- }
- /** @type {Array} */
- result = [];
- fail(result, 7);
- debug(result, val);
- debug(result, pdataOld);
- debug(result, udataCur);
- complete(result, node.name || "");
- debug(result, n);
- return result;
- }
- /**
- * @param {number} reason
- * @param {HTMLFormElement} node
- * @return {?}
- */
- function error(reason, node) {
- var i = dom.getFormNumber(node);
- if (0 > i) {
- return null;
- }
- var result = node.elements;
- var iLength = result.length;
- /** @type {Array} */
- var conf = [];
- /** @type {number} */
- var j = 0;
- for (;j < iLength;j++) {
- if (!dom.isEmptyField(result[j])) {
- var params = result[j][name];
- if (params) {
- if (0 < params) {
- self.mergeArrays(conf, [params]);
- }
- }
- }
- }
- /** @type {Array} */
- result = [];
- fail(result, 11);
- debug(result, reason);
- debug(result, i);
- debug(result, conf.length);
- /** @type {number} */
- i = 0;
- for (;i < conf.length;i++) {
- debug(result, conf[i]);
- }
- return result;
- }
- /**
- * @return {?}
- */
- function exec() {
- /** @type {Array} */
- var ex = [];
- fail(ex, 13);
- return ex;
- }
- /**
- * @param {Function} name
- * @param {Array} value
- * @param {boolean} expectedNumberOfNonCommentArgs
- * @return {undefined}
- */
- function emit(name, value, expectedNumberOfNonCommentArgs) {
- name = name.apply(win, value);
- context.append(name, expectedNumberOfNonCommentArgs);
- }
- /**
- * @param {Object} node
- * @return {undefined}
- */
- function init(node) {
- if (node[name]) {
- a: {
- var res = get();
- var i = node[name];
- if (0 < i) {
- /** @type {Array} */
- var expected = [];
- node = dom.getElementRegion(node);
- var e = data[i];
- var pos = node[0] + "x" + node[1];
- var key = node[2] + "x" + node[3];
- if (pos != e.pos) {
- e.pos = pos;
- fail(expected, 9);
- debug(expected, res);
- debug(expected, i);
- debug(expected, node[0]);
- debug(expected, node[1]);
- }
- if (key != e.size) {
- e.size = key;
- fail(expected, 10);
- debug(expected, res);
- debug(expected, i);
- debug(expected, node[2]);
- debug(expected, node[3]);
- }
- if (expected.length) {
- /** @type {Array} */
- node = expected;
- break a;
- }
- }
- /** @type {null} */
- node = null;
- }
- } else {
- if (i = dom.getElementParent(node)) {
- init(i);
- }
- node[name] = func;
- data[func] = {};
- func++;
- if (node.nodeName) {
- if (i = +node[name], !isFinite(i) || 0 >= i) {
- /** @type {null} */
- res = null;
- } else {
- /** @type {number} */
- expected = 64;
- /** @type {number} */
- e = 0;
- var elements = dom.getElementParent(node);
- pos = elements && elements[name] ? elements[name] : 0;
- if (0 > pos) {
- /** @type {number} */
- pos = 0;
- }
- key = node.nodeName.toUpperCase();
- var value = $cookies[key];
- if (!value) {
- expected |= 2;
- }
- var now = dom.getElementNeighborPosition(node);
- if (!now) {
- expected |= 4;
- }
- var current = dom.getElementRegion(node);
- if (elements = elements ? dom.getElementRegion(elements) : null) {
- if (current[0] == elements[0]) {
- if (current[1] == elements[1]) {
- if (current[2] == elements[2]) {
- if (current[3] == elements[3]) {
- expected |= 8;
- }
- }
- }
- }
- }
- data[i].pos = current[0] + "x" + current[1];
- data[i].size = current[2] + "x" + current[3];
- if (node.id) {
- if ("string" == typeof node.id) {
- expected |= 32;
- }
- }
- if (elements = dom.calcTextChecksum(node)) {
- expected |= 16;
- }
- var n = dom.calcAttribChecksum(node);
- if (n) {
- e |= 2;
- }
- var ex;
- b: {
- ex = dom.getElementChildren(dom.getElementParent(node), node.tagName);
- /** @type {number} */
- var ii = 0;
- for (;ii < ex.length;ii++) {
- if ((!ex[ii].id || "string" != typeof ex[ii].id) && (dom.calcAttribChecksum(ex[ii]) == n && dom.calcTextChecksum(ex[ii]) == elements)) {
- /** @type {boolean} */
- ex = true;
- break b;
- }
- }
- /** @type {boolean} */
- ex = false;
- }
- if (ex) {
- expected |= 1;
- res = dom.calcChildrenChecksum(node);
- }
- /** @type {Array} */
- ex = [];
- fail(ex, 1);
- debug(ex, i);
- fail(ex, expected);
- debug(ex, pos);
- if (value) {
- fail(ex, value);
- } else {
- next(ex, key);
- }
- if (now) {
- debug(ex, now);
- }
- if (!(expected & 8)) {
- debug(ex, current[0]);
- debug(ex, current[1]);
- debug(ex, current[2]);
- debug(ex, current[3]);
- }
- if (expected & 32) {
- next(ex, node.id);
- }
- if (elements) {
- cb(ex, elements);
- }
- if (expected & 1) {
- cb(ex, res);
- }
- fail(ex, e);
- if (n) {
- cb(ex, n);
- }
- /** @type {Array} */
- res = ex;
- }
- } else {
- /** @type {number} */
- node[name] = -1;
- /** @type {null} */
- res = null;
- }
- context.append(res, void 0);
- node = check(node);
- }
- context.append(node, void 0);
- }
- /**
- * @param {?} a
- * @param {boolean} dataAndEvents
- * @return {?}
- */
- function jQuery(a, dataAndEvents) {
- var ret = a && dom.classNameExists(a, "(ym-disable-keys|-metrika-nokeys)");
- if (dataAndEvents) {
- if (a) {
- ret = ret || !!dom.getElementsByClassName("(ym-disable-keys|-metrika-nokeys)", a).length;
- }
- }
- return ret;
- }
- /**
- * @param {Object} a
- * @return {?}
- */
- function $(a) {
- return a && dom.classNameExists(a, "(ym-disable-submit|-metrika-noform)");
- }
- /**
- * @param {Object} e
- * @return {undefined}
- */
- function listener(e) {
- var el = that.getTarget(e);
- if (el && "SCROLLBAR" != el.nodeName) {
- if (/^INPUT|SELECT|TEXTAREA|BUTTON$/.test(el.tagName)) {
- if (el[name]) {
- init(el);
- } else {
- var data = el.form;
- if (data) {
- data = data.elements;
- var iLen = data.length;
- /** @type {number} */
- var i = 0;
- for (;i < iLen;i++) {
- if (/^INPUT|SELECT|TEXTAREA|BUTTON$/.test(data[i].tagName)) {
- if (!data[i][name]) {
- init(data[i]);
- }
- }
- }
- } else {
- init(el);
- }
- }
- } else {
- init(el);
- }
- emit(load, [get(), e.type, el, that.getPos(e), e.which, e.button]);
- }
- }
- /**
- * @param {Object} e
- * @return {undefined}
- */
- function select(e) {
- listener(e);
- a: {
- var val;
- var n;
- if (win.getSelection) {
- try {
- /** @type {(Selection|null)} */
- var sel = win.getSelection();
- } catch (jb) {
- break a;
- }
- /** @type {string} */
- val = sel.toString();
- /** @type {(Node|null)} */
- n = sel.anchorNode;
- } else {
- if (doc.selection) {
- if (doc.selection.createRange) {
- /** @type {(ControlRange|TextRange|null)} */
- e = doc.selection.createRange();
- val = e.text;
- n = e.parentElement();
- }
- }
- }
- if ("string" == typeof val) {
- try {
- for (;n && 1 != n.nodeType;) {
- n = n.parentNode;
- }
- } catch (jb) {
- break a;
- }
- if (!(n && filter(n))) {
- if (!jQuery(n, true)) {
- if (!(val == out)) {
- /** @type {string} */
- out = val;
- emit(success, [get(), val]);
- }
- }
- }
- }
- }
- }
- /**
- * @param {Object} e
- * @return {undefined}
- */
- function handler(e) {
- var max = remove();
- /** @type {number} */
- var range = max - min;
- if (!(10 > range)) {
- var vec = that.getPos(e);
- /** @type {number} */
- var z0 = dest[0] - vec[0];
- /** @type {number} */
- var z1 = dest[1] - vec[1];
- /** @type {number} */
- z0 = z0 * z0 + z1 * z1;
- if (!(0 >= z0)) {
- if (!(16 > z0 && 100 > range)) {
- if (!(20 > range && 256 > z0)) {
- min = max;
- dest = vec;
- listener(e);
- }
- }
- }
- }
- }
- /**
- * @return {undefined}
- */
- function close() {
- var cur = dom.getDocumentScroll();
- var max = remove();
- if (!(10 > max - aux)) {
- if (!(10 > Math.abs(cur[0] - prev[0]) && 10 > Math.abs(cur[1] - prev[1]))) {
- aux = max;
- prev = cur;
- emit(text, [get(), cur]);
- }
- }
- }
- /**
- * @param {Object} event
- * @return {undefined}
- */
- function update(event) {
- if (event = that.getTarget(event)) {
- /** @type {number} */
- var elem = Math.random();
- /** @type {Array} */
- var node = [event.scrollLeft, event.scrollTop];
- if (event.localId) {
- if (elem = elems[event.localId], !elem || 10 > Math.abs(node[0] - elem[0]) && 10 > Math.abs(node[1] - elem[1])) {
- return;
- }
- } else {
- for (;elems[elem];) {
- /** @type {number} */
- elem = Math.random();
- }
- /** @type {number} */
- event.localId = elem;
- }
- /** @type {Array} */
- elems[event.localId] = node;
- if (event !== doc) {
- init(event);
- emit(include, [get(), node, event]);
- }
- }
- }
- /**
- * @return {undefined}
- */
- function poll() {
- emit(change, [get(), dom.getViewportSize(), dom.getDocumentSize()]);
- }
- /**
- * @return {undefined}
- */
- function noop() {
- emit(exec, [], true);
- }
- /**
- * @param {Object} event
- * @return {?}
- */
- function dispatch(event) {
- return(event.shiftKey ? 2 : 0) | (event.ctrlKey ? 4 : 0) | (event.altKey ? 1 : 0) | (event.metaKey ? 8 : 0) | (event.ctrlKey || event.altKey ? 16 : 0);
- }
- /**
- * @param {Object} a
- * @return {?}
- */
- function filter(a) {
- return "INPUT" == a.tagName ? "password" == a.type || (a.name && names.test(a.name) || a.id && names.test(a.id)) : false;
- }
- /**
- * @param {Object} doc
- * @param {?} string
- * @param {number} positions
- * @return {undefined}
- */
- function show(doc, string, positions) {
- if (!!(doc = that.getTarget(doc))) {
- if (!filter(doc)) {
- if (!jQuery(doc)) {
- init(doc);
- emit(save, [get(), string, positions, doc]);
- }
- }
- }
- }
- /**
- * @param {Object} data
- * @return {undefined}
- */
- function send(data) {
- var code = data.keyCode;
- var newState = dispatch(data);
- if ({
- 3 : 1,
- 8 : 1,
- 9 : 1,
- 13 : 1,
- 16 : 1,
- 17 : 1,
- 18 : 1,
- 19 : 1,
- 20 : 1,
- 27 : 1,
- 33 : 1,
- 34 : 1,
- 35 : 1,
- 36 : 1,
- 37 : 1,
- 38 : 1,
- 39 : 1,
- 40 : 1,
- 45 : 1,
- 46 : 1,
- 91 : 1,
- 92 : 1,
- 93 : 1,
- 106 : 1,
- 110 : 1,
- 111 : 1,
- 144 : 1,
- 145 : 1
- }[code] || (112 <= code && 123 >= code || (96 <= code && 105 >= code || newState & 16))) {
- if (19 == code) {
- if (4 == (newState & -17)) {
- /** @type {number} */
- code = 144;
- }
- }
- show(data, code, newState | 16);
- /** @type {boolean} */
- fa = false;
- self.setTimeout(function() {
- /** @type {boolean} */
- fa = true;
- }, 1);
- if (!!(67 == code && newState & 4)) {
- if (!(newState & 1)) {
- if (!(newState & 2)) {
- process();
- }
- }
- }
- }
- }
- /**
- * @param {Object} event
- * @return {undefined}
- */
- function onResize(event) {
- if (fa) {
- if (!V) {
- if (0 !== event.which) {
- show(event, event.charCode || event.keyCode, dispatch(event));
- /** @type {boolean} */
- V = true;
- self.setTimeout(function() {
- /** @type {boolean} */
- V = false;
- }, 1);
- }
- }
- }
- }
- /**
- * @return {undefined}
- */
- function process() {
- if (!T) {
- /** @type {boolean} */
- T = true;
- if (out) {
- emit(clone, [get()]);
- }
- self.setTimeout(function() {
- /** @type {boolean} */
- T = false;
- }, 1);
- }
- }
- /**
- * @return {undefined}
- */
- function method() {
- if (!qa) {
- /** @type {boolean} */
- qa = true;
- emit(onerror, [get()]);
- }
- }
- /**
- * @return {undefined}
- */
- function scroll() {
- if (qa) {
- /** @type {boolean} */
- qa = false;
- emit(ok, [get()]);
- }
- }
- /**
- * @param {Event} elem
- * @return {undefined}
- */
- function restoreScript(elem) {
- if (!qa || elem && !elem.fromElement) {
- method();
- }
- }
- /**
- * @param {Event} ev
- * @return {undefined}
- */
- function start(ev) {
- if (ev) {
- if (!ev.toElement) {
- scroll();
- }
- }
- }
- /**
- * @param {Object} params
- * @return {undefined}
- */
- function add(params) {
- if ((params = that.getTarget(params)) && /^INPUT|SELECT|TEXTAREA|BUTTON$/.test(params.tagName)) {
- if (params[name]) {
- init(params);
- } else {
- var data = params.form;
- if (data) {
- data = data.elements;
- var iLen = data.length;
- /** @type {number} */
- var i = 0;
- for (;i < iLen;i++) {
- if (/^INPUT|SELECT|TEXTAREA|BUTTON$/.test(data[i].tagName)) {
- if (!data[i][name]) {
- init(data[i]);
- }
- }
- }
- } else {
- init(params);
- }
- }
- emit(timeout, [get(), params]);
- }
- }
- /**
- * @param {HTMLElement} params
- * @return {undefined}
- */
- function run(params) {
- if (params = that.getTarget(params)) {
- if (/^INPUT|SELECT|TEXTAREA|BUTTON$/.test(params.tagName)) {
- init(params);
- emit(destroy, [get(), params]);
- }
- }
- }
- /**
- * @param {Element} doc
- * @return {undefined}
- */
- function fn(doc) {
- if ((doc = that.getTarget(doc)) && (!filter(doc) && (!jQuery(doc) && /^INPUT|SELECT|TEXTAREA$/.test(doc.tagName)))) {
- var b = /^(checkbox|radio)$/.test(doc.type) ? doc.checked : doc.value;
- init(doc);
- emit(done, [get(), doc, b]);
- }
- }
- /**
- * @param {Object} e
- * @return {undefined}
- */
- function handleClick(e) {
- if ((e = that.getTarget(e)) && (!$(e) && "FORM" == e.nodeName)) {
- var codeSegments = e.elements;
- /** @type {number} */
- var i = 0;
- for (;i < codeSegments.length;i++) {
- if (!dom.isEmptyField(codeSegments[i])) {
- init(codeSegments[i]);
- }
- }
- emit(error, [get(), e], true);
- }
- }
- /**
- * @param {Object} event
- * @return {undefined}
- */
- function onClick(event) {
- close();
- if (event.touches && event.touches.length) {
- var parent = that.getTarget(event);
- if (parent && parent != doc) {
- init(parent);
- /** @type {number} */
- var t = 0;
- for (;t < event.touches.length;t++) {
- emit(load, [get(), "touch", parent, [event.touches[t].pageX, event.touches[t].pageY], 0, 0]);
- }
- }
- }
- }
- /**
- * @param {Object} e
- * @return {undefined}
- */
- function ready(e) {
- var tooltip = that.getTarget(e);
- if (tooltip) {
- var c;
- if ("wheel" == e.type) {
- /** @type {number} */
- c = 0 < e.deltaY ? 1 : 0 > e.deltaY ? 2 : 0;
- } else {
- if ("mousewheel" == e.type) {
- /** @type {number} */
- c = 0 < e.wheelDelta ? 2 : 0 > e.wheelDelta ? 1 : 0;
- }
- }
- if (c) {
- init(tooltip);
- emit(parser, [get(), tooltip, that.getPos(e), c]);
- }
- }
- }
- /**
- * @param {Element} v
- * @return {undefined}
- */
- function callback(v) {
- if (v = that.getTarget(v)) {
- if ("BODY" == v.tagName) {
- context.append([], true);
- }
- }
- }
- var context = new t({
- protocol : allBindingsAccessor,
- counterId : depMaps,
- counterType : rootjQuery,
- meta : {
- url : trigger().href,
- hitId : deepDataAndEvents,
- timezone : udataCur,
- timestamp : now
- }
- });
- var $cookies = {
- A : 1,
- ABBR : 2,
- ACRONYM : 3,
- ADDRESS : 4,
- APPLET : 5,
- AREA : 6,
- B : 7,
- BASE : 8,
- BASEFONT : 9,
- BDO : 10,
- BIG : 11,
- BLOCKQUOTE : 12,
- BODY : 13,
- BR : 14,
- BUTTON : 15,
- CAPTION : 16,
- CENTER : 17,
- CITE : 18,
- CODE : 19,
- COL : 20,
- COLGROUP : 21,
- DD : 22,
- DEL : 23,
- DFN : 24,
- DIR : 25,
- DIV : 26,
- DL : 27,
- DT : 28,
- EM : 29,
- FIELDSET : 30,
- FONT : 31,
- FORM : 32,
- FRAME : 33,
- FRAMESET : 34,
- H1 : 35,
- H2 : 36,
- H3 : 37,
- H4 : 38,
- H5 : 39,
- H6 : 40,
- HEAD : 41,
- HR : 42,
- HTML : 43,
- I : 44,
- IFRAME : 45,
- IMG : 46,
- INPUT : 47,
- INS : 48,
- ISINDEX : 49,
- KBD : 50,
- LABEL : 51,
- LEGEND : 52,
- LI : 53,
- LINK : 54,
- MAP : 55,
- MENU : 56,
- META : 57,
- NOFRAMES : 58,
- NOSCRIPT : 59,
- OBJECT : 60,
- OL : 61,
- OPTGROUP : 62,
- OPTION : 63,
- P : 64,
- PARAM : 65,
- PRE : 66,
- Q : 67,
- S : 68,
- SAMP : 69,
- SCRIPT : 70,
- SELECT : 71,
- SMALL : 72,
- SPAN : 73,
- STRIKE : 74,
- STRONG : 75,
- STYLE : 76,
- SUB : 77,
- SUP : 78,
- TABLE : 79,
- TBODY : 80,
- TD : 81,
- TEXTAREA : 82,
- TFOOT : 83,
- TH : 84,
- THEAD : 85,
- TITLE : 86,
- TR : 87,
- TT : 88,
- U : 89,
- UL : 90,
- VAR : 91,
- NOINDEX : 100
- };
- /** @type {number} */
- var ROOM_SIZE = 0;
- /** @type {number} */
- var y = 0;
- tick(0);
- /** @type {number} */
- var func = 1;
- /** @type {number} */
- var min = 0;
- /** @type {Array} */
- var dest = [0, 0];
- /** @type {number} */
- var aux = 0;
- /** @type {Array} */
- var prev = [0, 0];
- var elems = {};
- /** @type {RegExp} */
- var names = /^(password|passwd|pswd)$/;
- /** @type {boolean} */
- var fa = true;
- /** @type {boolean} */
- var V = false;
- /** @type {string} */
- var out = "";
- /** @type {boolean} */
- var T = false;
- /** @type {boolean} */
- var qa = true;
- var newMethods = remove();
- /** @type {string} */
- var name = "metrikaId_" + Math.random();
- var data = {};
- /** @type {string} */
- var j = ":submit" + Math.random();
- if (!self.isMetrikaPlayer()) {
- Event.on(doc, "mousemove", handler);
- Event.on(doc, "click,dblclick,mousedown", listener);
- Event.on(doc, "mouseup", select);
- Event.on(win, "scroll", close);
- if ("onmousewheel" in doc) {
- Event.on(doc, "mousewheel", ready);
- } else {
- Event.on(doc, "wheel", ready);
- }
- Event.on(win, "beforeunload", noop);
- if (!lb) {
- Event.on(win, "unload", noop);
- }
- Event.on(win, "resize", poll);
- Event.on(doc, "keydown", send);
- Event.on(doc, "keypress", onResize);
- Event.on(doc, "copy", process);
- Event.on(doc, "touchmove,touchstart", onClick);
- if (doc.body) {
- Event.on(doc, "mouseleave", callback);
- }
- if (doc.attachEvent && !win.opera) {
- Event.on(doc, "focusin", restoreScript);
- Event.on(doc, "focusout", start);
- } else {
- Event.on(win, "focus", method);
- Event.on(win, "blur", scroll);
- Event.on(doc, "blur", scroll);
- }
- if (doc.addEventListener) {
- Event.on(doc, "scroll", update);
- Event.on(doc, "focus", add);
- Event.on(doc, "blur", run);
- Event.on(doc, "change", fn);
- Event.on(doc, "submit", handleClick);
- } else {
- if (doc.attachEvent) {
- Event.on(doc, "focusin", add);
- Event.on(doc, "focusout", run);
- (function() {
- /** @type {NodeList} */
- var items = doc.getElementsByTagName("form");
- /** @type {number} */
- var i = 0;
- for (;i < items.length;i++) {
- var children = items[i].getElementsByTagName("*");
- /** @type {number} */
- var ci = 0;
- for (;ci < children.length;ci++) {
- if (/^INPUT|SELECT|TEXTAREA$/.test(children[ci].tagName)) {
- Event.on(children[ci], "change", fn);
- }
- }
- Event.on(items[i], "submit", handleClick);
- }
- })();
- }
- }
- (function() {
- /** @type {NodeList} */
- var codeSegments = doc.getElementsByTagName("form");
- if (codeSegments.length) {
- /** @type {number} */
- var i = 0;
- for (;i < codeSegments.length;i++) {
- var val = codeSegments[i].submit;
- if ("function" == typeof val || "object" == typeof val && /^\s*function submit\(\)/.test(String(val))) {
- codeSegments[i][j] = val;
- /**
- * @return {?}
- */
- codeSegments[i].submit = function() {
- handleClick({
- target : this
- });
- return this[j]();
- };
- }
- }
- }
- })();
- if ("0:0" != dom.getDocumentScroll().join(":")) {
- close();
- }
- poll();
- }
- return{
- /**
- * @return {undefined}
- */
- start : function() {
- context.activate();
- },
- /**
- * @return {undefined}
- */
- stop : function() {
- context.clear();
- Event.un(doc, "mousemove", handler);
- Event.un(doc, "click,dblclick,mousedown", listener);
- Event.un(doc, "mouseup", select);
- Event.un(doc, "mousewheel", ready);
- Event.un(doc, "wheel", ready);
- Event.un(win, "scroll", close);
- Event.un(win, "beforeunload", noop);
- Event.un(win, "unload", noop);
- Event.un(win, "resize", poll);
- Event.un(doc, "keydown", send);
- Event.un(doc, "keypress", onResize);
- Event.un(doc, "copy", process);
- Event.un(doc, "touchmove", onClick);
- Event.un(doc, "touchstart", onClick);
- if (doc.body) {
- Event.un(doc, "mouseleave", callback);
- }
- Event.un(doc, "focusin", restoreScript);
- Event.un(doc, "focusout", start);
- Event.un(win, "focus", method);
- Event.un(win, "blur", scroll);
- Event.un(doc, "blur", scroll);
- if (doc.removeEventListener) {
- Event.un(doc, "scroll", update);
- Event.un(doc, "focus", add);
- Event.un(doc, "blur", run);
- Event.un(doc, "change", fn);
- Event.un(doc, "submit", handleClick);
- } else {
- if (doc.detachEvent) {
- Event.un(doc, "focusin", add);
- Event.un(doc, "focusout", run);
- (function() {
- /** @type {NodeList} */
- var codeSegments = doc.getElementsByTagName("form");
- /** @type {number} */
- var i = 0;
- for (;i < codeSegments.length;i++) {
- var children = codeSegments[i].getElementsByTagName("*");
- /** @type {number} */
- var ci = 0;
- for (;ci < children.length;ci++) {
- if (/^INPUT|SELECT|TEXTAREA$/.test(children[ci].tagName)) {
- Event.un(children[ci], "change", fn);
- }
- }
- Event.un(codeSegments[i], "submit", handleClick);
- }
- })();
- }
- }
- (function() {
- /** @type {NodeList} */
- var codeSegments = doc.getElementsByTagName("form");
- /** @type {number} */
- var i = 0;
- for (;i < codeSegments.length;i++) {
- if (codeSegments[i][j]) {
- codeSegments[i].submit = codeSegments[i][j];
- }
- }
- })();
- },
- /**
- * @param {string} step
- * @param {?} v12
- * @return {undefined}
- */
- uploadPages : function(step, v12) {
- /**
- * @return {undefined}
- */
- function process() {
- Event.un(doc, "DOMContentLoaded", process);
- Event.un(win, "load", process);
- var codeSegments = step.split(/\n/);
- var value = trigger().href;
- /** @type {RegExp} */
- var re = /regexp:/;
- /** @type {number} */
- var i = 0;
- for (;i < codeSegments.length;i++) {
- var src = codeSegments[i];
- if (src) {
- if (re.test(src)) {
- src = trim(src.replace(re, ""));
- try {
- /** @type {RegExp} */
- var r = new RegExp(src);
- } catch (Hb) {
- }
- if (r && r.test(value)) {
- vec2.uploadPage(v12);
- break;
- }
- } else {
- if (-1 !== value.indexOf(src)) {
- vec2.uploadPage(v12);
- break;
- }
- }
- }
- }
- }
- var vec2 = this;
- if ("complete" == doc.readyState) {
- process();
- } else {
- Event.on(doc, "DOMContentLoaded", process);
- Event.on(win, "load", process);
- }
- },
- uploadPage : bind(function(input) {
- if ("function" == typeof win.toStaticHTML && -1 < win.toStaticHTML.toString().indexOf("NoScript")) {
- return false;
- }
- /** @type {Element} */
- var elem = doc.documentElement;
- if (elem && 19E4 < ("" + elem.innerHTML).length) {
- return false;
- }
- var xhr = win.XMLHttpRequest ? new win.XMLHttpRequest : new ActiveXObject("Msxml2.XMLHTTP");
- var charset = dom.getDocumentCharset();
- /** @type {string} */
- var type = "text/html" + (charset ? ";charset=" + charset : "");
- var jQuery = new Repo({
- protocol : allBindingsAccessor,
- counterId : depMaps,
- counterType : rootjQuery
- });
- if ("html" == input) {
- return input = RegExp("<script [^>]*?//mc\\.yandex\\.ru/watch/.*?\x3c/script>", "gi"), jQuery.sendContent(dom.getDocumentHTML().replace(input, ""), type, deepDataAndEvents, udataCur, now), true;
- }
- if (xhr) {
- xhr.open("get", trigger().href, true);
- xhr.onreadystatechange = bind(function() {
- if (4 == xhr.readyState) {
- var name = xhr.getResponseHeader("content-type") || "";
- if (charset) {
- if (-1 === name.indexOf("charset=")) {
- /** @type {string} */
- name = type;
- }
- }
- jQuery.sendContent(xhr.responseText, name, deepDataAndEvents, udataCur, now);
- }
- }, "updatePage.1");
- if (xhr.overrideMimeType) {
- if (charset) {
- xhr.overrideMimeType(type);
- }
- }
- xhr.send(null);
- }
- return true;
- }, "uploadPage")
- };
- }
- /**
- * @param {Function} fn
- * @param {string} id
- * @param {boolean} dataAndEvents
- * @return {?}
- */
- function bind(fn, id, dataAndEvents) {
- return function() {
- try {
- return fn.apply(this, arguments);
- } catch (err) {
- if (!dataAndEvents) {
- callback(err, id);
- }
- }
- };
- }
- /**
- * @param {(Error|string)} err
- * @param {string} key
- * @return {undefined}
- */
- function callback(err, key) {
- var dig;
- if (0.01 > Math.random()) {
- try {
- (new Game).log("jserrs", v, err.message, key, params.href, "", "string" == typeof err.stack && err.stack.replace(/\n/g, "\\n"));
- } catch (d) {
- /** @type {Array} */
- dig = ["cp: " + key, err.name + ": " + err.message, "debug: ", "code: " + v, "stack: " + err.stack];
- /** @type {string} */
- (new Image).src = "//an.yandex.ru/jserr/101500?cnt-class=100&errmsg=" + encodeURIComponent(dig.join("; ").replace(/\r?\n/g, "\\n"));
- }
- }
- }
- /**
- * @param {Function} obj
- * @param {number} time
- * @param {string} fnc
- * @return {?}
- */
- function defer(obj, time, fnc) {
- return win.setTimeout(bind(obj, fnc || "setTimeout"), time);
- }
- /**
- * @return {?}
- */
- function trigger() {
- var result = {};
- /** @type {Array.<string>} */
- var keys = "hash host hostname href pathname port protocol search".split(" ");
- /** @type {number} */
- var len = keys.length;
- /** @type {number} */
- var i = len;
- var h;
- var key;
- for (;i--;) {
- /** @type {string} */
- result[keys[i]] = "";
- }
- try {
- /** @type {(Location|null)} */
- h = win.location;
- /** @type {number} */
- i = len;
- for (;i--;) {
- /** @type {string} */
- key = keys[i];
- result[key] = "" + h[key];
- }
- } catch (l) {
- if (params) {
- result = params;
- }
- }
- return result;
- }
- /**
- * @param {boolean} str
- * @return {?}
- */
- function trim(str) {
- return str ? ("" + str).replace(/^\s+/, "").replace(/\s+$/, "") : "";
- }
- /**
- * @return {?}
- */
- function success() {
- return-1 != trigger().hostname.search(/(?:^|\.)(?:ya|yandex)\.(?:\w+|com\.\w+)$/);
- }
- /**
- * @param {Node} regex
- * @return {?}
- */
- function check(regex) {
- return-1 !== ("" + win.navigator.userAgent).toLowerCase().search(regex);
- }
- /**
- * @param {Object} a
- * @return {?}
- */
- function get(a) {
- return trim(a && (a.innerHTML && a.innerHTML.replace(/<\/?[^>]+>/gi, "")));
- }
- /**
- * @param {?} a
- * @param {Array} b
- * @return {?}
- */
- function walk(a, b) {
- var tagNameArr;
- var j;
- if (!a || !b) {
- return false;
- }
- /** @type {Array} */
- tagNameArr = [];
- /** @type {number} */
- j = 0;
- for (;j < b.length;j++) {
- tagNameArr.push(b[j].replace(/\^/g, "\\^").replace(/\$/g, "\\$").replace(/\./g, "\\.").replace(/\[/g, "\\[").replace(/\]/g, "\\]").replace(/\|/g, "\\|").replace(/\(/g, "\\(").replace(/\)/g, "\\)").replace(/\?/g, "\\?").replace(/\*/g, "\\*").replace(/\+/g, "\\+").replace(/\{/g, "\\{").replace(/\}/g, "\\}"));
- }
- return(new RegExp("\\.(" + tagNameArr.join("|") + ")$", "i")).test(a);
- }
- /**
- * @param {Object} target
- * @return {?}
- */
- function handle(target) {
- target = target.target || target.srcElement;
- var c;
- if (!target) {
- return false;
- }
- if (3 == target.nodeType) {
- target = target.parentNode;
- }
- c = target && (target.nodeName && target.nodeName.toString().toLowerCase());
- for (;target && (target.parentNode && (target.parentNode.nodeName && ("a" != c && "area" != c || !target.href)));) {
- c = (target = target.parentNode) && (target.nodeName && target.nodeName.toString().toLowerCase());
- }
- return target.href ? target : false;
- }
- /**
- * @param {boolean} view
- * @param {string} path
- * @return {?}
- */
- function _init(view, path) {
- return(view ? view.replace(/^www\./, "") : "").toLowerCase() == (path ? path.replace(/^www\./, "") : "").toLowerCase();
- }
- /**
- * @param {boolean} a
- * @param {boolean} b
- * @return {?}
- */
- function extend(a, b) {
- /**
- * @param {Object} str
- * @return {?}
- */
- function camelCase(str) {
- str = str.split(":");
- str = str[1] || "";
- str = str.replace(/^\/*/, "").replace(/^www\./, "");
- return str.split("/")[0];
- }
- return a && b ? camelCase(a) == camelCase(b) : a || b ? false : true;
- }
- /**
- * @return {?}
- */
- function parents() {
- var t = win.performance || win.webkitPerformance;
- var src;
- /** @type {Array} */
- var touches = [];
- if (t = t && t.timing) {
- if (src = t.navigationStart) {
- /** @type {Array} */
- touches = [t.domainLookupEnd - t.domainLookupStart, t.connectEnd - t.connectStart, t.responseStart - t.requestStart, t.responseEnd - t.responseStart, t.fetchStart - src, t.redirectEnd - t.redirectStart, t.redirectCount];
- touches.push(t.domInteractive && t.domLoading ? t.domInteractive - t.domLoading : null);
- touches.push(t.domContentLoadedEventStart && t.domContentLoadedEventEnd ? t.domContentLoadedEventEnd - t.domContentLoadedEventStart : null);
- touches.push(t.domComplete ? t.domComplete - src : null);
- touches.push(t.loadEventStart ? t.loadEventStart - src : null);
- touches.push(t.loadEventStart && t.loadEventEnd ? t.loadEventEnd - t.loadEventStart : null);
- touches.push(t.domContentLoadedEventStart ? t.domContentLoadedEventStart - src : null);
- /** @type {number} */
- t = 0;
- for (;t < touches.length;t++) {
- src = touches[t];
- if (null !== src) {
- if (0 > src || 36E5 < src) {
- /** @type {null} */
- touches[t] = null;
- }
- }
- }
- }
- }
- return touches;
- }
- /**
- * @param {?} value
- * @return {?}
- */
- function getValue(value) {
- /** @type {Array} */
- var ary = [];
- var codeSegments = value._lastPerformanceTiming;
- var obj = parents();
- var i;
- var valsLength;
- if (codeSegments) {
- /** @type {number} */
- i = 0;
- valsLength = codeSegments.length;
- for (;i < valsLength;i++) {
- if (null === obj[i]) {
- ary.push(obj[i]);
- } else {
- ary.push(codeSegments[i] === obj[i] ? "" : obj[i]);
- }
- }
- } else {
- ary = obj;
- }
- value._lastPerformanceTiming = obj;
- return ary.join(",");
- }
- /**
- * @return {?}
- */
- function calcFirstPaintTimeResults() {
- var t;
- if ("object" == typeof win.chrome && win.chrome.loadTimes) {
- if (t = win.chrome.loadTimes(), t.requestTime && t.firstPaintTime) {
- return~~(1E3 * (t.firstPaintTime - t.requestTime));
- }
- } else {
- if (win.performance && (win.performance.timing && (t = win.performance.timing, t.navigationStart && t.msFirstPaint))) {
- return t.msFirstPaint - t.navigationStart;
- }
- }
- return null;
- }
- /**
- * @param {Object} config
- * @return {?}
- */
- function load(config) {
- /** @type {string} */
- var contentType = doc.referrer || "";
- var patterns;
- var pattern;
- var e;
- var j;
- var i;
- if ((new RegExp("^https?://" + params.host + "/")).test(contentType)) {
- return false;
- }
- patterns = config.patterns;
- /** @type {number} */
- j = 0;
- for (;j < patterns.length;j++) {
- if (pattern = new RegExp(patterns[j], "i"), contentType.match(pattern)) {
- if (pattern = config.params || [], pattern.length) {
- e = self.safeDecodeURIComponent((RegExp.$1 || "").replace(/\+/g, "%20"));
- /** @type {number} */
- i = 0;
- for (;i < pattern.length;i++) {
- if (e == self.safeDecodeURIComponent(pattern[i])) {
- return true;
- }
- }
- } else {
- return true;
- }
- }
- }
- return false;
- }
- /**
- * @param {number} string
- * @param {boolean} dataAndEvents
- * @return {?}
- */
- function add(string, dataAndEvents) {
- /** @type {boolean} */
- var fake = false;
- var id;
- var html;
- var state;
- var i;
- if (string && ("string" != typeof string && string.length)) {
- /** @type {number} */
- i = 0;
- for (;i < string.length;i++) {
- if (id = string[i].selector, html = string[i].text, state = id.charAt(0), id = id.slice(1), "#" == state) {
- if (state = doc.getElementById(id)) {
- /** @type {boolean} */
- fake = true;
- if (dataAndEvents) {
- codeSegments.unshift([state, state.innerHTML]);
- }
- state.innerHTML = html;
- }
- } else {
- if ("." == state) {
- state = dom.getElementsByClassName(id);
- /** @type {number} */
- id = 0;
- for (;id < state.length;id++) {
- /** @type {boolean} */
- fake = true;
- var val = state[id];
- var text = html;
- if (dataAndEvents) {
- codeSegments.unshift([val, val.innerHTML]);
- }
- val.innerHTML = text;
- }
- }
- }
- }
- }
- return fake;
- }
- /**
- * @return {undefined}
- */
- function _next() {
- var i;
- /** @type {number} */
- i = 0;
- for (;i < codeSegments.length;i++) {
- codeSegments[i][0].innerHTML = codeSegments[i][1];
- }
- }
- /**
- * @param {string} s
- * @param {Object} value
- * @return {?}
- */
- function write(s, value) {
- var p;
- var i;
- /** @type {string} */
- var className = "";
- var parameters;
- var codeSegments;
- var classNames;
- s = s && s.replace(/^\?/, "");
- value = value && value.replace(/^#/, "") || "";
- if (s) {
- i = s.split("&");
- /** @type {number} */
- p = 0;
- for (;p < i.length;p++) {
- classNames = i[p].split("=");
- if ("_openstat" === classNames[0]) {
- className = classNames[1];
- }
- }
- }
- parameters = value.split("?");
- /** @type {number} */
- p = 0;
- for (;p < parameters.length;p++) {
- codeSegments = parameters[p].split("&");
- /** @type {number} */
- i = 0;
- for (;i < codeSegments.length;i++) {
- classNames = codeSegments[i].split("=");
- if ("_openstat" === classNames[0]) {
- className = classNames[1];
- }
- }
- }
- if (className) {
- className = -1 < className.indexOf(";") ? self.safeDecodeURIComponent(className) : Base64.decode(exports.decode(className.replace(/[-*_]/g, function(chr) {
- return{
- "*" : "+",
- "-" : "/",
- _ : "="
- }[chr] || chr;
- })));
- }
- return className && (p = className.split(";"), 4 == p.length) ? {
- service : p[0],
- campaign : p[1],
- ad : p[2],
- source : p[3]
- } : null;
- }
- var self = {
- /**
- * @param {Object} obj
- * @return {?}
- */
- mixin : function(obj) {
- var i;
- var prop;
- /** @type {number} */
- i = 1;
- for (;i < arguments.length;i++) {
- if (arguments[i]) {
- for (prop in arguments[i]) {
- if (arguments[i].hasOwnProperty(prop)) {
- obj[prop] = arguments[i][prop];
- }
- }
- if (arguments[i].hasOwnProperty("toString")) {
- obj.toString = arguments[i].toString;
- }
- }
- }
- return obj;
- }
- };
- /**
- * @param {Object} props
- * @return {undefined}
- */
- var $ = function(props) {
- props = props || {};
- self.mixin(this, props);
- this._initComponent();
- };
- /**
- * @return {undefined}
- */
- $.prototype._initComponent = function() {
- };
- /**
- * @param {?} opt_attributes
- * @return {?}
- */
- $.inherit = function(opt_attributes) {
- var superclass;
- var f;
- opt_attributes = opt_attributes || {};
- superclass = "function" == typeof this ? this : Object;
- if (!opt_attributes.hasOwnProperty("constructor")) {
- /**
- * @return {undefined}
- */
- opt_attributes.constructor = function() {
- superclass.apply(this, arguments);
- };
- }
- /**
- * @return {undefined}
- */
- f = function() {
- };
- f.prototype = superclass.prototype;
- opt_attributes.constructor.prototype = new f;
- self.mixin(opt_attributes.constructor.prototype, opt_attributes);
- /** @type {function (): undefined} */
- opt_attributes.constructor.prototype.constructor = opt_attributes.constructor;
- opt_attributes.constructor.superclass = superclass.prototype;
- /** @type {function (?): ?} */
- opt_attributes.constructor.inherit = $.inherit;
- return opt_attributes.constructor;
- };
- /**
- * @param {string} ar
- * @return {?}
- */
- self.isArray = function(ar) {
- return "function" == typeof Array.isArray ? Array.isArray(ar) : "[object Array]" == Object.prototype.toString.call(ar);
- };
- /**
- * @param {Array} a
- * @return {?}
- */
- self.mergeArrays = function(a) {
- var idx;
- var i;
- /** @type {number} */
- var len = arguments.length;
- var c;
- /** @type {number} */
- idx = 1;
- for (;idx < len;idx++) {
- if (c = arguments[idx], self.isArray(c) || c && "[object Arguments]" === c.toString()) {
- /** @type {number} */
- i = 0;
- for (;i < c.length;i++) {
- a[a.length] = c[i];
- }
- }
- }
- return a;
- };
- /**
- * @param {string} property
- * @param {Object} object
- * @return {?}
- */
- self.getNativeFunction = function(property, object) {
- var __method;
- object = object || win;
- return(__method = object.constructor && (object.constructor.prototype && object.constructor.prototype[property]) || object[property]) && "apply" in __method ? function() {
- return __method.apply(object, arguments);
- } : function() {
- };
- };
- /**
- * @param {Function} callback
- * @param {number} ms
- * @param {string} millis
- * @return {?}
- */
- self.setTimeout = function(callback, ms, millis) {
- return self.getNativeFunction("setTimeout")(bind(callback, millis || "setTimeout"), ms);
- };
- /**
- * @param {Function} fn
- * @param {number} timeout
- * @param {?} scope
- * @param {Array} args
- * @param {string} millis
- * @return {?}
- */
- self.defer = function(fn, timeout, scope, args, millis) {
- return self.setTimeout(function() {
- fn.apply(scope, args || []);
- }, timeout, millis);
- };
- /**
- * @param {Function} func
- * @param {number} ms
- * @param {string} scope
- * @param {string} millis
- * @return {?}
- */
- self.throttle = function(func, ms, scope, millis) {
- var msMax;
- var args;
- var nativeScope;
- return function() {
- /** @type {Arguments} */
- args = arguments;
- nativeScope = this;
- if (!msMax) {
- (function() {
- /** @type {null} */
- msMax = null;
- if (args) {
- func.apply(scope || nativeScope, args);
- /** @type {null} */
- args = null;
- msMax = self.setTimeout(arguments.callee, ms, millis);
- }
- })();
- }
- };
- };
- var ret = $.inherit({
- storage : null,
- storageKey : "dataBuffer",
- maxBufferSize : 255,
- flushTimeout : 1E4,
- active : true,
- meta : null,
- /**
- * @return {undefined}
- */
- onFlush : function() {
- },
- onFlushCtx : null,
- bufferExpireTime : 864E5,
- /**
- * @return {undefined}
- */
- _initComponent : function() {
- var e;
- ret.superclass._initComponent.apply(this, arguments);
- /** @type {Array} */
- this._data = [];
- /** @type {number} */
- this._packetNumber = 0;
- /** @type {null} */
- this._flushTID = null;
- this._saveToStorageThrottled = self.throttle(this._saveToStorage, 300, this, "DataBuffer._saveToStorage");
- if (this.storage) {
- if (e = this.storage.get(this.storageKey)) {
- if (e.data) {
- if (e.meta) {
- if (e.time) {
- if (e.time + this.bufferExpireTime > +new Date) {
- this.onFlush.call(this.onFlushCtx || this, e.data, e.meta, e.pnum);
- }
- }
- }
- }
- }
- this.clear();
- }
- },
- /**
- * @return {?}
- */
- getFlushSize : function() {
- return this._data.length;
- },
- /**
- * @param {Object} name
- * @param {boolean} expectedNumberOfNonCommentArgs
- * @return {undefined}
- */
- append : function(name, expectedNumberOfNonCommentArgs) {
- self.mergeArrays(this._data, name);
- this._saveToStorageThrottled();
- if (this.active) {
- if (expectedNumberOfNonCommentArgs || this.getFlushSize() >= this.maxBufferSize) {
- this._flush();
- }
- if (!this._flushTID) {
- this._flushTID = self.defer(this._flush, this.flushTimeout, this, [], "DataBuffer._flush");
- }
- }
- },
- /**
- * @return {undefined}
- */
- activate : function() {
- if (!this.active) {
- /** @type {boolean} */
- this.active = true;
- this.append([]);
- }
- },
- /**
- * @return {undefined}
- */
- clear : function() {
- /** @type {number} */
- this._data.length = 0;
- /** @type {null} */
- this._flushTID = null;
- if (this.storage) {
- this.storage.remove(this.storageKey);
- }
- },
- /**
- * @return {undefined}
- */
- _flush : function() {
- this.onFlush.call(this.onFlushCtx || this, this._data, this.meta, this._packetNumber);
- this._packetNumber++;
- this.clear();
- },
- /**
- * @return {undefined}
- */
- _saveToStorage : function() {
- if (this.storage) {
- if (this._data.length) {
- this.storage.set(this.storageKey, {
- data : this._data,
- meta : this.meta,
- pnum : this._packetNumber,
- time : +new Date
- });
- }
- }
- }
- });
- var s3 = $.inherit({
- transports : [],
- postParams : [],
- dontSendRequests : false,
- /**
- * @param {string} message
- * @param {Object} data
- * @param {Function} callback
- * @param {?} scope
- * @return {undefined}
- */
- send : function(message, data, callback, scope) {
- callback = callback || function() {
- };
- if (this.dontSendRequests) {
- callback.call(scope);
- } else {
- (function ready(index) {
- var context;
- if (index < this.transports.length) {
- try {
- context = new this.transports[index]({
- postParams : this.postParams
- });
- context.request(message, data, function(dataAndEvents, operation, el) {
- if (dataAndEvents) {
- callback.call(scope, operation, el);
- } else {
- ready.call(this, index + 1);
- }
- }, this);
- } catch (err) {
- callback(err, "send by " + (context && context.id));
- ready.call(this, index + 1);
- }
- }
- }).call(this, 0);
- }
- }
- });
- var store = {
- /**
- * @param {Object} obj
- * @return {?}
- */
- stringify : function(obj) {
- /** @type {Array} */
- var tagNameArr = [];
- var key;
- var value;
- var j;
- for (key in obj) {
- if (obj.hasOwnProperty(key)) {
- if (value = obj[key], self.isArray(value)) {
- /** @type {number} */
- j = 0;
- for (;j < value.length;j++) {
- tagNameArr.push(encodeURIComponent(key) + "=" + encodeURIComponent(String(value[j])));
- }
- } else {
- tagNameArr.push(encodeURIComponent(key) + "=" + encodeURIComponent(String(value)));
- }
- }
- }
- return tagNameArr.join("&");
- }
- };
- /**
- * @param {Object} object
- * @param {Function} callback
- * @param {?} opt_scope
- * @return {undefined}
- */
- self.forEachKey = function(object, callback, opt_scope) {
- var key;
- for (key in object) {
- if (object.hasOwnProperty(key)) {
- callback.call(opt_scope, key, object[key], object);
- }
- }
- };
- /**
- * @param {Array} a
- * @param {?} item
- * @return {?}
- */
- self.inArray = function(a, item) {
- var i;
- /** @type {number} */
- i = 0;
- for (;i < a.length;i++) {
- if (a[i] == item) {
- return true;
- }
- }
- return false;
- };
- var request = $.inherit({
- postParams : [],
- /**
- * @param {string} url
- * @param {Object} context
- * @return {?}
- */
- _buildUrl : function(url, context) {
- var key = store.stringify(context);
- return url + (-1 < url.indexOf("?") ? "&" : key ? "?" : "") + key;
- },
- /**
- * @param {Object} m
- * @return {?}
- */
- _splitParams : function(m) {
- var flags = {};
- var cache = {};
- self.forEachKey(m, function(k, value) {
- if (self.inArray(this.postParams, k)) {
- cache[k] = value;
- } else {
- flags[k] = value;
- }
- }, this);
- return{
- get : flags,
- post : cache
- };
- }
- });
- var options = request.inherit({
- id : "XHR",
- method : "POST",
- withCredentials : true,
- /**
- * @param {string} url
- * @param {Object} data
- * @param {Function} callback
- * @param {?} scope
- * @return {?}
- */
- request : function(url, data, callback, scope) {
- var line;
- var xhr;
- if (/[^a-z0-9.:-]/.test(params.host) && (win.opera && ("function" == typeof win.opera.version && (line = win.opera.version(), "string" == typeof line && "12" == line.split(".")[0])))) {
- return callback.call(scope, false);
- }
- if (win.XMLHttpRequest && (xhr = new XMLHttpRequest, "withCredentials" in xhr)) {
- data = this._splitParams(data);
- url = this._buildUrl(url, data.get);
- try {
- xhr.open(this.method, url, true);
- } catch (l) {
- return callback.call(scope, false);
- }
- xhr.withCredentials = this.withCredentials;
- this._setHeaders(xhr);
- xhr.send(this._preparePostParams(data));
- /**
- * @return {undefined}
- */
- xhr.onreadystatechange = function() {
- if (4 == xhr.readyState) {
- callback.call(scope, 200 == xhr.status, xhr.responseText);
- }
- };
- return;
- }
- callback.call(scope, false);
- },
- /**
- * @param {Function} method
- * @return {undefined}
- */
- setMethod : function(method) {
- /** @type {Function} */
- this.method = method;
- },
- /**
- * @param {Object} data
- * @return {?}
- */
- _preparePostParams : function(data) {
- return store.stringify(data.post);
- },
- /**
- * @param {Object} xhr
- * @return {undefined}
- */
- _setHeaders : function(xhr) {
- xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
- }
- });
- /**
- * @param {number} min
- * @param {number} max
- * @return {?}
- */
- self.random = function(min, max) {
- if (2 > arguments.length) {
- /** @type {number} */
- max = min;
- /** @type {number} */
- min = 0;
- }
- if (1 > arguments.length) {
- /** @type {number} */
- max = 1073741824;
- }
- return Math.floor(Math.random() * (max - min)) + min;
- };
- var Model = request.inherit({
- id : "form",
- enctype : "application/x-www-form-urlencoded",
- htmlfileOnly : false,
- /**
- * @return {undefined}
- */
- _initComponent : function() {
- Model.superclass._initComponent.apply(this, arguments);
- if (!("_htmlfile" in Model.prototype)) {
- Model.prototype._htmlfile = this._createHtmlfile();
- }
- this._doc = this._htmlfile || (this.htmlfileOnly ? null : doc);
- },
- /**
- * @param {string} url
- * @param {Object} config
- * @param {Function} callback
- * @param {?} scope
- * @return {?}
- */
- request : function(url, config, callback, scope) {
- var doc = this._doc;
- var wordLength;
- var d;
- var previous;
- var data;
- if (!doc) {
- return callback.call(scope, false);
- }
- config = this._splitParams(config);
- /** @type {string} */
- wordLength = "ifr" + self.random();
- d = doc.createElement("div");
- /** @type {string} */
- d.style.position = "absolute";
- /** @type {string} */
- d.style.left = "-99999px";
- /** @type {string} */
- d.style.top = "-99999px";
- /** @type {Array} */
- previous = ['<iframe name="', wordLength, '"></iframe>', '<form action="', this._buildUrl(url, config.get), '" method="post" target="', wordLength, '" enctype="', this.enctype, '">'];
- self.forEachKey(config.post, function(res) {
- self.mergeArrays(previous, ['<input type="hidden" autocomplete="off" autocorrect="off"', ' autocapitalize="off" spellcheck="false" name="', res, '"/>']);
- });
- self.mergeArrays(previous, ["</form>"]);
- /** @type {string} */
- d.innerHTML = previous.join("");
- doc.body.appendChild(d);
- data = d.getElementsByTagName("form")[0];
- self.forEachKey(config.post, function(option, intensity) {
- data[option].value = intensity;
- });
- data.submit();
- self.setTimeout(function() {
- doc.body.removeChild(d);
- }, 1E4, "TransportForm.request.2");
- return callback.call(scope, true);
- },
- /**
- * @return {?}
- */
- _createHtmlfile : function() {
- var doc;
- try {
- if (win.ActiveXObject) {
- return doc = new ActiveXObject("htmlfile"), doc.open(), doc.write("<html><body></body></html>"), doc.close(), doc;
- }
- } catch (b) {
- }
- return null;
- }
- });
- var vb = Model.inherit({
- id : "htmlfile",
- htmlfileOnly : true
- });
- var Browser = request.inherit({
- id : "img",
- /**
- * @param {string} url
- * @param {Object} context
- * @param {Function} callback
- * @param {?} scope
- * @return {undefined}
- */
- request : function(url, context, callback, scope) {
- url = this._buildUrl(url, context);
- /** @type {Element} */
- context = doc.createElement("img");
- callback = callback || function() {
- };
- context.onload = bind(function() {
- callback.call(scope, true);
- }, "TransportImage.request");
- context.onerror = bind(function() {
- callback.call(scope, false);
- }, "TransportImage.request");
- /** @type {string} */
- context.src = url;
- }
- });
- var JSON = {
- /**
- * @param {Object} obj
- * @return {?}
- */
- stringify : function(obj) {
- try {
- return JSON.stringify(obj);
- } catch (b) {
- return "null";
- }
- }
- };
- /**
- * @param {Object} object
- * @return {?}
- */
- self.toJSON = function(object) {
- var klass;
- var property;
- var length;
- if (object === value) {
- return "";
- }
- if (null === object) {
- return "null";
- }
- switch(object.constructor) {
- case Boolean:
- return object.toString();
- case Number:
- return isFinite(object) ? object.toString() : "null";
- case String:
- return'"' + object.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\n/g, "\\n").replace(/\r/g, "\\r") + '"';
- case Array:
- /** @type {Array} */
- klass = [];
- /** @type {number} */
- property = 0;
- length = object.length;
- for (;property < length;property++) {
- klass[klass.length] = self.toJSON(object[property]);
- }
- return "[" + klass.join(",") + "]";
- case Object:
- /** @type {Array} */
- klass = [];
- for (property in object) {
- if (object.hasOwnProperty(property)) {
- if (object[property] !== value) {
- /** @type {string} */
- klass[klass.length] = self.toJSON(property) + ":" + self.toJSON(object[property]);
- }
- }
- }
- return "{" + klass.join(",") + "}";
- default:
- JSON.stringify(object);
- }
- };
- var Node = $.inherit({
- counterId : "",
- /**
- * @return {undefined}
- */
- _initComponent : function() {
- Node.superclass._initComponent.apply(this, arguments);
- /** @type {null} */
- this._ls = null;
- try {
- /** @type {(Storage|null)} */
- this._ls = win.localStorage;
- } catch (a) {
- }
- },
- /**
- * @param {string} key
- * @param {string} value
- * @return {undefined}
- */
- set : function(key, value) {
- if (this.isEnabled()) {
- try {
- if (!value || value && (self.isArray(value) && !value.length)) {
- this.remove(key);
- } else {
- this._ls.setItem(this._getLsKey(key), self.toJSON(value));
- }
- } catch (c) {
- }
- }
- },
- /**
- * @param {string} key
- * @return {?}
- */
- get : function(key) {
- if (this.isEnabled()) {
- try {
- return JSON.parse(this._ls.getItem(this._getLsKey(key)));
- } catch (b) {
- }
- }
- return null;
- },
- /**
- * @param {string} key
- * @return {undefined}
- */
- remove : function(key) {
- if (this.isEnabled()) {
- try {
- this._ls.removeItem(this._getLsKey(key));
- } catch (b) {
- }
- }
- },
- /**
- * @return {?}
- */
- isEnabled : function() {
- return this._ls && (win.JSON && ("object" == typeof this._ls && "object" == typeof win.JSON));
- },
- /**
- * @return {?}
- */
- getStorageId : function() {
- var caption = this.get("lsid");
- if (!caption) {
- /** @type {number} */
- caption = Math.round(Math.random() * new Date);
- this.set("lsid", caption);
- }
- return caption;
- },
- /**
- * @return {undefined}
- */
- clearStorageId : function() {
- this.remove("lsid");
- },
- /**
- * @param {string} keepData
- * @return {?}
- */
- _getLsKey : function(keepData) {
- return "_ym" + this.counterId + "_" + keepData;
- }
- });
- var Controller = $.inherit({
- counterId : "",
- onlyCurrentDomain : false,
- skipPrefix : false,
- /**
- * @return {undefined}
- */
- _initComponent : function() {
- var word;
- var i;
- Controller.superclass._initComponent.apply(this, arguments);
- /** @type {null} */
- this._domain = null;
- if (!this.onlyCurrentDomain) {
- word = params.host.split(".");
- /** @type {number} */
- i = 2;
- for (;;) {
- if (i <= word.length) {
- if (this._domain = "." + word.slice(-i).join("."), i++, this.isEnabled()) {
- break;
- }
- } else {
- /** @type {null} */
- this._domain = null;
- break;
- }
- }
- }
- },
- /**
- * @param {(Array|string)} id
- * @param {Object} value
- * @param {number} opt_attributes
- * @return {undefined}
- */
- create : function(id, value, opt_attributes) {
- /** @type {Array} */
- id = [this._prepareName(id) + "=" + encodeURIComponent(value)];
- if (opt_attributes) {
- /** @type {Date} */
- value = new Date;
- value.setTime(value.getTime() + 6E4 * opt_attributes);
- id.push("expires=" + value.toGMTString());
- }
- if (this._domain) {
- id.push("domain=" + this._domain);
- }
- id.push("path=/");
- try {
- /** @type {string} */
- doc.cookie = id.join(";");
- } catch (d) {
- }
- },
- /**
- * @param {string} name
- * @return {?}
- */
- read : function(name) {
- var sel;
- try {
- /** @type {string} */
- sel = doc.cookie;
- } catch (c) {
- }
- return sel && sel.match(new RegExp("(?:^|;\\s*)" + this._prepareName(name) + "=([^;]*)")) ? decodeURIComponent(RegExp.$1) : null;
- },
- /**
- * @param {string} item
- * @return {undefined}
- */
- erase : function(item) {
- this.create(item, "", -1);
- },
- /**
- * @return {?}
- */
- isEnabled : function() {
- var enabled;
- this.create("metrika_enabled", "1", 60);
- /** @type {boolean} */
- enabled = !!this.read("metrika_enabled");
- this.erase("metrika_enabled");
- return enabled;
- },
- /**
- * @param {string} name
- * @return {?}
- */
- _prepareName : function(name) {
- return(this.skipPrefix ? "" : "_ym_") + name + (this.counterId ? "_" + this.counterId : "");
- }
- });
- /**
- * @return {?}
- */
- Controller.isEnabled = function() {
- return(new Controller({
- onlyCurrentDomain : true
- })).isEnabled();
- };
- var instance = s3.inherit({
- protocol : "",
- host : "mc.yandex.ru",
- resource : "",
- counterId : "",
- counterType : 0,
- retry : false,
- transports : [options, Browser, vb],
- /**
- * @return {undefined}
- */
- _initComponent : function() {
- instance.superclass._initComponent.apply(this, arguments);
- if (this.retry) {
- this._storage = new Node;
- }
- },
- /**
- * @param {Object} data
- * @param {number} opt_data
- * @param {Function} serviceName
- * @param {?} service
- * @return {undefined}
- */
- send : function(data, opt_data, serviceName, service) {
- var newState = this._registerRequest(data, opt_data);
- this._sendSavedRequest(newState, data, opt_data, serviceName, service);
- },
- /**
- * @param {string} expr
- * @param {Object} d
- * @param {Object} data
- * @param {Function} matcherFunction
- * @param {?} service
- * @return {?}
- */
- _sendSavedRequest : function(expr, d, data, matcherFunction, service) {
- var arg = win.Ya._metrika.firstReqStatus;
- var _ref;
- var previous;
- if ("process" == arg) {
- win.Ya._metrika.firstReqCallbacks = self.mergeArrays(win.Ya._metrika.firstReqCallbacks || [], [[this, arguments]]);
- } else {
- return arg || (win.Ya._metrika.firstReqStatus = "process"), arg = {}, this.counterType && (arg["cnt-class"] = this.counterType), self.mixin(arg, d), data.st = Math.round((new Date).getTime() / 1E3), data.u = instance._userID, _ref = [this.protocol, "//", this.host, "/" + this.resource + "/" + this.counterId].join(""), previous = [], data && (self.forEachKey(data, function(params, status) {
- if ("t" != params) {
- self.mergeArrays(previous, [params, status]);
- }
- }), data.t && self.mergeArrays(previous, ["t", data.t])), previous.length && (arg["browser-info"] = previous.join(":")), instance.superclass.send.call(this, _ref, arg, function() {
- var codeSegments;
- var i;
- /** @type {string} */
- win.Ya._metrika.firstReqStatus = "complete";
- this._unregisterRequest(expr);
- codeSegments = win.Ya._metrika.firstReqCallbacks;
- /** @type {null} */
- win.Ya._metrika.firstReqCallbacks = null;
- if (codeSegments) {
- /** @type {number} */
- i = 0;
- for (;i < codeSegments.length;i++) {
- codeSegments[i][0]._sendSavedRequest.apply(codeSegments[i][0], codeSegments[i][1]);
- }
- }
- if (matcherFunction) {
- matcherFunction.apply(service, arguments);
- }
- }, this);
- }
- },
- /**
- * @return {?}
- */
- _isRetryEnabled : function() {
- return this.retry && (this._storage && this._storage.isEnabled());
- },
- /**
- * @param {Object} data
- * @param {number} opt_noCache
- * @return {?}
- */
- _registerRequest : function(data, opt_noCache) {
- var pdataOld;
- var resource;
- if (this._isRetryEnabled()) {
- opt_noCache.rqnl = opt_noCache.rqnl || 0;
- opt_noCache.rqnl++;
- pdataOld = this._storage.get("retryReqs") || {};
- /** @type {number} */
- resource = 1;
- for (;pdataOld[resource];) {
- resource++;
- }
- pdataOld[resource] = {
- protocol : this.protocol,
- host : this.host,
- resource : this.resource,
- counterId : this.counterId,
- counterType : this.counterType,
- postParams : this.postParams,
- params : data,
- browserInfo : opt_noCache,
- ghid : Ya._globalMetrikaHitId,
- time : +new Date
- };
- this._storage.set("retryReqs", pdataOld);
- return resource;
- }
- },
- /**
- * @param {string} key
- * @return {undefined}
- */
- _unregisterRequest : function(key) {
- var pdataOld;
- if (key) {
- if (this._isRetryEnabled()) {
- pdataOld = this._storage.get("retryReqs") || {};
- if (pdataOld[key]) {
- delete pdataOld[key];
- this._storage.set("retryReqs", pdataOld);
- }
- }
- }
- },
- _getVersion : bind(function() {
- return v;
- }, "", true)
- });
- /**
- * @return {undefined}
- */
- instance.initCookie = function() {
- var utils = new Controller;
- var index = utils.read("uid");
- if (!index) {
- /** @type {number} */
- index = Math.round((new Date).getTime() / 1E3);
- /** @type {string} */
- index = index + "" + self.random();
- utils.create("uid", index, 1036800);
- }
- instance._userID = index;
- };
- /**
- * @return {undefined}
- */
- instance.retransmit = function() {
- var control = new Node;
- var which = control.get("retryReqs") || {};
- var res;
- control.remove("retryReqs");
- self.forEachKey(which, function(dataAndEvents, req) {
- if (!win.Ya._metrika.firstReqStatus) {
- /** @type {string} */
- win.Ya._metrika.firstReqStatus = "complete";
- }
- if (req.ghid) {
- if (req.ghid != Ya._globalMetrikaHitId) {
- if (req.time) {
- if (req.time + 864E5 > +new Date) {
- if (2 >= req.browserInfo.rqnl) {
- res = new instance({
- protocol : req.protocol,
- host : req.host,
- resource : req.resource,
- counterId : req.counterId,
- counterType : req.counterType,
- postParams : req.postParams || [],
- retry : true
- });
- res.send(req.params, req.browserInfo);
- }
- }
- }
- }
- }
- });
- };
- /**
- * @param {string} data
- * @return {?}
- */
- self.fletcher = function(data) {
- var b = data.length;
- /** @type {number} */
- var i = 0;
- /** @type {number} */
- var buf = 255;
- /** @type {number} */
- var optsData = 255;
- var a;
- var c;
- var encodedLenType;
- for (;b;) {
- a = 21 < b ? 21 : b;
- b -= a;
- do {
- c = "string" == typeof data ? data.charCodeAt(i) : data[i];
- i++;
- if (255 < c) {
- /** @type {number} */
- encodedLenType = c >> 8;
- c &= 255;
- c ^= encodedLenType;
- }
- buf += c;
- optsData += buf;
- } while (--a);
- /** @type {number} */
- buf = (buf & 255) + (buf >> 8);
- /** @type {number} */
- optsData = (optsData & 255) + (optsData >> 8);
- }
- /** @type {number} */
- data = (buf & 255) + (buf >> 8) << 8 | (optsData & 255) + (optsData >> 8);
- return 65535 == data ? 0 : data;
- };
- var exports = {
- abc : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
- tail : "+/=",
- tailSafe : "*-_",
- /**
- * @param {Array} data
- * @param {boolean} dataAndEvents
- * @return {?}
- */
- encode : function(data, dataAndEvents) {
- /** @type {Array.<string>} */
- var arr = (exports.abc + (dataAndEvents ? exports.tailSafe : exports.tail)).split("");
- var length = data.length;
- /** @type {Array} */
- var previous = [];
- /** @type {number} */
- var j = length - length % 3;
- var c;
- var i;
- /** @type {number} */
- i = 0;
- for (;i < j;i += 3) {
- c = (data[i] << 16) + (data[i + 1] << 8) + data[i + 2];
- self.mergeArrays(previous, [arr[c >> 18 & 63], arr[c >> 12 & 63], arr[c >> 6 & 63], arr[c & 63]]);
- }
- switch(length - j) {
- case 1:
- /** @type {number} */
- c = data[j] << 4;
- self.mergeArrays(previous, [arr[c >> 6 & 63], arr[c & 63], arr[64], arr[64]]);
- break;
- case 2:
- /** @type {number} */
- c = (data[j] << 10) + (data[j + 1] << 2);
- self.mergeArrays(previous, [arr[c >> 12 & 63], arr[c >> 6 & 63], arr[c & 63], arr[64]]);
- }
- return previous.join("");
- }
- };
- /**
- * @param {string} str
- * @param {number} length
- * @return {?}
- */
- self.trim = function(str, length) {
- /** @type {string} */
- str = String(str).replace(/^\s+|\s+$/g, "");
- if (length) {
- if (str.length > length) {
- /** @type {string} */
- str = str.substr(0, length);
- }
- }
- return str;
- };
- /**
- * @param {?} f
- * @return {?}
- */
- self.isFunction = function(f) {
- return "function" === typeof f;
- };
- /**
- * @param {?} target
- * @return {?}
- */
- self.isString = function(target) {
- return "[object String]" == Object.prototype.toString.call(target);
- };
- /**
- * @param {Array} a
- * @param {string} keepData
- * @return {?}
- */
- self.arrayIndexOf = function(a, keepData) {
- var i;
- /** @type {number} */
- i = 0;
- for (;i < a.length;i++) {
- if (a[i] === keepData) {
- return i;
- }
- }
- return-1;
- };
- /** @type {RegExp} */
- self._playerRegexp = /^.+\.mtproxy\.yandex\.net$/;
- /**
- * @return {?}
- */
- self.isMetrikaPlayer = function() {
- return "MetrikaPlayer" == win.name || this._playerRegexp.test(win.location.hostname);
- };
- var dom = {
- /**
- * @return {?}
- */
- getDocumentCharset : function() {
- return("" + (doc.characterSet || (doc.charset || ""))).toLowerCase();
- },
- /**
- * @return {?}
- */
- getRootElement : function() {
- /** @type {Element} */
- var head = doc.documentElement;
- return "CSS1Compat" == doc.compatMode ? head : doc.body || head;
- },
- /**
- * @return {?}
- */
- getViewportSize : function() {
- var container = dom.getRootElement();
- return[container.clientWidth || win.innerWidth, container.clientHeight || win.innerHeight];
- },
- /**
- * @return {?}
- */
- getDocumentTitle : function() {
- /** @type {string} */
- var elem = doc.title;
- if ("string" != typeof elem) {
- elem = (elem = doc.getElementsByTagName("title")) && elem.length ? elem[0].innerHTML : "";
- }
- return elem;
- }
- };
- var data = {
- _silverlightVersion : "",
- /**
- * @return {?}
- */
- getSilverlightVersion : function() {
- var config;
- var callback;
- var udataCur;
- var typePattern;
- if (!data._silverlightVersion) {
- if (win.ActiveXObject) {
- try {
- udataCur = new ActiveXObject("AgControl.AgControl");
- /**
- * @param {?} value
- * @param {Array} args
- * @param {number} desiredNonCommentArgIndex
- * @param {number} expectedNumberOfNonCommentArgs
- * @return {undefined}
- */
- config = function(value, args, desiredNonCommentArgIndex, expectedNumberOfNonCommentArgs) {
- for (;callback(value, args);) {
- args[desiredNonCommentArgIndex] += expectedNumberOfNonCommentArgs;
- }
- args[desiredNonCommentArgIndex] -= expectedNumberOfNonCommentArgs;
- };
- /**
- * @param {?} success
- * @param {Array} _
- * @return {?}
- */
- callback = function(success, _) {
- return success.isVersionSupported(_[0] + "." + _[1] + "." + _[2] + "." + _[3]);
- };
- /** @type {Array} */
- typePattern = [1, 0, 0, 0];
- config(udataCur, typePattern, 0, 1);
- config(udataCur, typePattern, 1, 1);
- config(udataCur, typePattern, 2, 1E4);
- config(udataCur, typePattern, 2, 1E3);
- config(udataCur, typePattern, 2, 100);
- config(udataCur, typePattern, 2, 10);
- config(udataCur, typePattern, 2, 1);
- config(udataCur, typePattern, 3, 1);
- /** @type {string} */
- data._silverlightVersion = typePattern.join(".");
- } catch (e) {
- }
- } else {
- if (config = win.navigator, config = config.plugins && config.plugins["Silverlight Plug-In"]) {
- data._silverlightVersion = config.description;
- }
- }
- }
- return data._silverlightVersion || "";
- },
- _flashVersion : 0,
- /**
- * @return {?}
- */
- getFlashVersion : function() {
- var config;
- var v;
- var flash;
- if (!data._flashVersion) {
- if (config = win.navigator, "undefined" != typeof config.plugins && "object" == typeof config.plugins["Shockwave Flash"]) {
- if (v = config.plugins["Shockwave Flash"], flash = v.version, (v = v.description) || flash) {
- if (config = config.mimeTypes, "undefined" == typeof config || (!config["application/x-shockwave-flash"] || config["application/x-shockwave-flash"].enabledPlugin)) {
- if (flash) {
- data._flashVersion = flash;
- } else {
- if (v) {
- data._flashVersion = v.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".");
- }
- }
- }
- }
- } else {
- if ("undefined" != typeof win.ActiveXObject) {
- try {
- if (flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"), v = flash.GetVariable("$version")) {
- data._flashVersion = v.split(" ")[1].replace(/,/g, ".").replace(/[^.\d]/g, "");
- }
- } catch (d) {
- }
- }
- }
- }
- return data._flashVersion;
- },
- /**
- * @return {?}
- */
- getLanguage : function() {
- return(win.navigator ? navigator.language || (navigator.userLanguage || (navigator.browserLanguage || navigator.systemLanguage)) : "").toLowerCase();
- },
- /**
- * @return {?}
- */
- getJavaEnabled : function() {
- try {
- return navigator.javaEnabled();
- } catch (a) {
- return false;
- }
- }
- };
- /**
- * @param {string} object
- * @return {?}
- */
- self.fnv32a = function(object) {
- /** @type {number} */
- var hint = 2166136261;
- var i;
- var length;
- /** @type {number} */
- i = 0;
- length = object.length;
- for (;i < length;++i) {
- hint ^= object.charCodeAt(i);
- hint += (hint << 1) + (hint << 4) + (hint << 7) + (hint << 8) + (hint << 24);
- }
- return hint >>> 0;
- };
- /**
- * @return {?}
- */
- data.getFingerPrint = function() {
- /** @type {Array} */
- var previous = [];
- var m;
- var i;
- if (navigator.plugins && navigator.plugins.length) {
- /** @type {number} */
- i = 0;
- for (;i < navigator.plugins.length;i++) {
- m = navigator.plugins[i];
- self.mergeArrays(previous, [m.name, m.version, m.description, m.filename]);
- }
- }
- if (navigator.mimeTypes && navigator.mimeTypes.length) {
- /** @type {number} */
- i = 0;
- for (;i < navigator.mimeTypes.length;i++) {
- m = navigator.mimeTypes[i];
- self.mergeArrays(previous, [m.type, m.description, m.suffixes]);
- }
- }
- return self.fnv32a(previous.join(";")) + "01";
- };
- /**
- * @return {?}
- */
- data.getPlatform = function() {
- /** @type {string} */
- var ppath = "";
- try {
- /** @type {string} */
- ppath = "" + navigator.platform;
- } catch (b) {
- }
- return ppath;
- };
- /**
- * @return {?}
- */
- data.getNotificationPermission = function() {
- var permission;
- try {
- /** @type {string} */
- permission = Notification.permission;
- } catch (b) {
- }
- switch(permission) {
- case "denied":
- return 1;
- case "granted":
- return 2;
- }
- };
- /**
- * @return {?}
- */
- data.isIframe = function() {
- try {
- return win.top != win.self;
- } catch (a) {
- return false;
- }
- };
- data._nMap = {
- other : "0",
- none : "1",
- unknown : "2",
- wifi : "3",
- ethernet : "4",
- bluetooth : "5",
- cellular : "6",
- wimax : "7",
- mixed : "8"
- };
- /**
- * @return {?}
- */
- data.netType = function() {
- var s = (navigator.connection || {
- type : ""
- }).type;
- return data._nMap[s] || s;
- };
- /**
- * @return {?}
- */
- data.isSafari = function() {
- try {
- return navigator.vendor && (-1 < navigator.vendor.indexOf("Apple") && (navigator.userAgent && !navigator.userAgent.match("CriOS")));
- } catch (a) {
- }
- return false;
- };
- /**
- * @param {Object} node
- * @return {undefined}
- */
- dom.removeNode = function(node) {
- var p = node && node.parentNode;
- if (p) {
- p.removeChild(node);
- }
- };
- var methods = {
- url : "https://mc.yandex.ru/metrika/",
- _value : null,
- /**
- * @return {undefined}
- */
- init : function() {
- var udataCur = this._getLs().read("isad");
- if (udataCur) {
- this._set(udataCur);
- } else {
- if (!this._getReqStatus()) {
- this._send();
- }
- }
- },
- /**
- * @return {?}
- */
- getVal : function() {
- return this._value;
- },
- /**
- * @param {string} value
- * @return {undefined}
- */
- _set : function(value) {
- this._value = "1" == value || "2" == value ? value : null;
- },
- /**
- * @return {undefined}
- */
- _send : function() {
- /** @type {Element} */
- var img = doc.createElement("img");
- var _saveReq = this;
- /**
- * @return {undefined}
- */
- img.onload = function() {
- _saveReq._saveReq(false);
- dom.removeNode(this);
- };
- /**
- * @return {undefined}
- */
- img.onerror = function() {
- _saveReq._saveReq(true);
- dom.removeNode(this);
- };
- this._setReqStatus("process");
- /** @type {string} */
- img.src = this.url + String.fromCharCode(97, 100, 118, 101, 114, 116, 46, 103, 105, 102);
- if (data.isSafari()) {
- /** @type {string} */
- img.style.position = "absolute";
- /** @type {string} */
- img.style.visibility = "hidden";
- /** @type {string} */
- img.style.width = "0px";
- /** @type {string} */
- img.style.height = "0px";
- dom.getRootElement().appendChild(img);
- }
- },
- /**
- * @param {boolean} isXML
- * @return {undefined}
- */
- _saveReq : function(isXML) {
- /** @type {string} */
- this._value = isXML = isXML ? "1" : "2";
- this._setReqStatus("complete");
- this._getLs().create("isad", isXML, 1200);
- },
- /**
- * @param {string} type
- * @return {undefined}
- */
- _setReqStatus : function(type) {
- try {
- /** @type {string} */
- win.Ya._metrika.adStatus = type;
- } catch (b) {
- }
- },
- /**
- * @return {?}
- */
- _getReqStatus : function() {
- try {
- return win.Ya._metrika.adStatus;
- } catch (a) {
- return "complete";
- }
- },
- /**
- * @return {?}
- */
- _getLs : function() {
- if (!this._ls) {
- this._ls = new Controller;
- }
- return this._ls;
- }
- };
- var Base64 = {
- /**
- * @param {string} input
- * @return {?}
- */
- encode : function(input) {
- /** @type {Array} */
- var out = [];
- var j;
- var copies;
- var jl;
- /** @type {number} */
- j = 0;
- jl = input.length;
- for (;j < jl;j++) {
- copies = input.charCodeAt(j);
- if (128 > copies) {
- out.push(copies);
- } else {
- if (127 < copies && 2048 > copies) {
- out.push(copies >> 6 | 192);
- } else {
- out.push(copies >> 12 | 224);
- out.push(copies >> 6 & 63 | 128);
- }
- out.push(copies & 63 | 128);
- }
- }
- return out;
- },
- /**
- * @param {string} utftext
- * @return {?}
- */
- decode : function(utftext) {
- /** @type {string} */
- var str = "";
- /** @type {number} */
- var i = 0;
- var b;
- var e;
- var f;
- for (;i < utftext.length;) {
- b = utftext.charCodeAt(i);
- if (128 > b) {
- str += String.fromCharCode(b);
- i++;
- } else {
- if (191 < b && 224 > b) {
- e = utftext.charCodeAt(i + 1);
- str += String.fromCharCode((b & 31) << 6 | e & 63);
- i += 2;
- } else {
- e = utftext.charCodeAt(i + 1);
- f = utftext.charCodeAt(i + 2);
- str += String.fromCharCode((b & 15) << 12 | (e & 63) << 6 | f & 63);
- i += 3;
- }
- }
- }
- return str;
- }
- };
- /**
- * @param {string} input
- * @param {boolean} secure
- * @return {?}
- */
- exports.decode = function(input, secure) {
- /** @type {string} */
- var excludes = exports.abc + (secure ? exports.tailSafe : exports.tail);
- /** @type {number} */
- var i = 0;
- /** @type {string} */
- var h = "";
- var o1;
- var o2;
- var o3;
- var number;
- var auto;
- for (;input.length % 4;) {
- input += "=";
- }
- do {
- /** @type {number} */
- o1 = excludes.indexOf(input.charAt(i++));
- /** @type {number} */
- o2 = excludes.indexOf(input.charAt(i++));
- /** @type {number} */
- number = excludes.indexOf(input.charAt(i++));
- /** @type {number} */
- auto = excludes.indexOf(input.charAt(i++));
- if (0 > o1 || (0 > o2 || (0 > number || 0 > auto))) {
- return null;
- }
- /** @type {number} */
- o3 = o1 << 18 | o2 << 12 | number << 6 | auto;
- /** @type {number} */
- o1 = o3 >> 16 & 255;
- /** @type {number} */
- o2 = o3 >> 8 & 255;
- o3 &= 255;
- /** @type {string} */
- h = 64 == number ? h + String.fromCharCode(o1) : 64 == auto ? h + String.fromCharCode(o1, o2) : h + String.fromCharCode(o1, o2, o3);
- } while (i < input.length);
- return h;
- };
- var klass = instance.inherit({
- hitId : 0,
- trackHash : false,
- trimParams : false,
- webvisor : false,
- counter : null,
- counterNum : 0,
- resource : "watch",
- retry : true,
- postParams : ["site-info"],
- countersNoTitle : "22836271 1143050 29626870 9928105 26128362 29850769".split(" "),
- fake : false,
- sendTitle : true,
- /**
- * @return {undefined}
- */
- _initComponent : function() {
- klass.superclass._initComponent.apply(this, arguments);
- this._trackHash = this.trackHash;
- if ("0" === "" + this.counterType) {
- /** @type {boolean} */
- this.sendTitle = -1 === self.arrayIndexOf(this.countersNoTitle, "" + this.counterId);
- }
- },
- /**
- * @param {boolean} edge
- * @return {undefined}
- */
- setTrackHash : function(edge) {
- /** @type {boolean} */
- this._trackHash = edge;
- },
- /**
- * @param {Object} options
- * @return {undefined}
- */
- sendHit : function(options) {
- this._hitExt({
- url : options.url,
- title : options.title,
- referrer : options.referrer,
- vParams : options.vParams,
- modes : {
- ar : true,
- saveRef : true,
- pv : true
- },
- callback : options.callback,
- ctx : options.ctx
- });
- },
- /**
- * @param {Object} state
- * @return {undefined}
- */
- sendExperiments : function(state) {
- this._hitExt({
- url : trigger().href,
- title : "",
- referrer : "",
- modes : {
- ex : true,
- ar : true
- },
- experiments : state.experiments,
- callback : state.callback,
- ctx : state.ctx
- });
- },
- /**
- * @param {Object} doc
- * @return {undefined}
- */
- sendPrerenderHit : function(doc) {
- this._hitExt({
- url : doc.url,
- title : doc.title,
- referrer : doc.referrer,
- modes : {
- ar : true,
- pq : true
- }
- });
- },
- /**
- * @param {Object} options
- * @return {undefined}
- */
- sendAjaxHit : function(options) {
- this._hitExt({
- url : options.url,
- title : options.title,
- referrer : options.referrer,
- modes : options.modes
- });
- },
- /**
- * @param {?} dataAndEvents
- * @param {Function} callback
- * @param {string} keepData
- * @return {undefined}
- */
- sendParams : function(dataAndEvents, callback, keepData) {
- this._hitExt({
- url : trigger().href,
- title : "",
- referrer : "",
- vParams : dataAndEvents,
- modes : {
- ar : true,
- pa : true,
- onlyData : true
- },
- /** @type {Function} */
- callback : callback,
- ctx : keepData
- });
- },
- /**
- * @param {boolean} url
- * @param {Object} state
- * @return {undefined}
- */
- sendGoal : function(url, state) {
- var uri;
- var MSG_CLOSURE_CUSTOM_COLOR_BUTTON;
- var fileExt;
- if (!/[\/&=?#]/.test(url)) {
- uri = url ? "goal://" + trigger().hostname + "/" + encodeURIComponent(url) : trigger().href;
- MSG_CLOSURE_CUSTOM_COLOR_BUTTON = dom.getDocumentTitle();
- fileExt = url ? trigger().href : doc.referrer;
- this._hitExt({
- url : uri,
- title : MSG_CLOSURE_CUSTOM_COLOR_BUTTON,
- referrer : fileExt,
- vParams : state.vParams,
- modes : {
- ar : true
- },
- callback : state.callback,
- ctx : state.ctx
- });
- }
- },
- /**
- * @param {Object} settings
- * @return {undefined}
- */
- sendClickLink : function(settings) {
- this._hitExt({
- url : settings.url,
- title : settings.title,
- referrer : trigger().href,
- modes : settings.modes
- });
- },
- /**
- * @param {Object} state
- * @return {undefined}
- */
- sendExtLink : function(state) {
- this._hitExt({
- url : state.url,
- title : state.title || "",
- referrer : trigger().href,
- vParams : state.vParams,
- modes : {
- ar : true,
- ln : true,
- ut : props
- },
- callback : state.callback,
- ctx : state.ctx
- });
- },
- /**
- * @param {Object} state
- * @return {undefined}
- */
- sendFileUpload : function(state) {
- this._hitExt({
- url : state.url,
- title : state.title || "",
- referrer : trigger().href,
- vParams : state.vParams,
- modes : {
- ar : true,
- ln : true,
- dl : true
- },
- callback : state.callback,
- ctx : state.ctx
- });
- },
- /**
- * @param {number} opt_fromIndex
- * @param {Object} state
- * @return {undefined}
- */
- sendNotBounce : function(opt_fromIndex, state) {
- this._hitExt({
- url : trigger().href,
- title : "",
- referrer : "",
- modes : {
- cl : opt_fromIndex,
- ar : true,
- nb : true,
- onlyData : true
- },
- callback : state.callback,
- ctx : state.ctx
- });
- },
- /**
- * @param {Object} options
- * @return {undefined}
- */
- sendDevice : function(options) {
- this._hitExt({
- browserInfo : {
- di : options.data,
- dip : options.port
- },
- callback : options.callback,
- ctx : options.ctx
- });
- },
- /**
- * @param {?} options
- * @return {undefined}
- */
- _hitExt : function(options) {
- /**
- * @param {string} value
- * @param {string} key
- * @return {undefined}
- */
- function callback(value, key) {
- if (key) {
- /** @type {string} */
- result[value] = key;
- }
- }
- var state;
- var data;
- var e;
- var value;
- var str;
- var result;
- var k;
- if (!self.isMetrikaPlayer()) {
- state = options.modes || {};
- data = options.browserInfo || {};
- value = "undefined" != typeof options.referrer ? options.referrer : img.lastReferrer;
- str = options.url || "";
- result = {};
- if (state.ar) {
- if (!state.onlyData) {
- value = null === value || "" === value ? "" : this._prepareHitUrl(value);
- str = this._prepareHitUrl(options.url);
- }
- }
- callback("page-ref", self.trim(value, length));
- callback("page-url", self.trim(str, length));
- if (success()) {
- callback("ut", props);
- } else {
- if ("undefined" != typeof state.ut) {
- callback("ut", self.trim(state.ut, extra));
- }
- }
- callback("exp", options.experiments);
- if (options.vParams) {
- str = self.toJSON(options.vParams);
- if (this.trimParams && str.length > chars) {
- /** @type {boolean} */
- k = true;
- } else {
- callback("site-info", str);
- }
- }
- if (state.saveRef) {
- img.lastReferrer = value;
- }
- if (!this.fake) {
- e = this._getTechInfo(options.title, state, this.counterId, options.ts, options.tz, this._trackHash, this.hitId, this.webvisor, this.counter);
- }
- self.mixin(data, e, {});
- this.send(result, data, function() {
- if (k) {
- this.counter.params(options.vParams);
- }
- if (options.userParams) {
- this.counter.userParams(options.userParams);
- }
- if (self.isFunction(options.callback)) {
- options.callback.apply(options.ctx, arguments);
- }
- }, this);
- }
- },
- /**
- * @param {string} t
- * @return {?}
- */
- _prepareHitUrl : function(t) {
- var s = trigger();
- var data = s.host;
- s = s.href;
- var j;
- if (!self.isString(t)) {
- return s;
- }
- if (-1 != t.search(/^\w+:\/\//)) {
- return t;
- }
- j = t.charAt(0);
- if ("?" == j) {
- return j = s.search(/\?/), -1 == j ? s + t : s.substr(0, j) + t;
- }
- if ("#" == j) {
- return j = s.search(/#/), -1 == j ? s + t : s.substr(0, j) + t;
- }
- if ("/" == j) {
- if (j = s.search(data), -1 != j) {
- return s.substr(0, j + data.length) + t;
- }
- } else {
- return data = s.split("/"), data[data.length - 1] = t, data.join("/");
- }
- return t;
- },
- /**
- * @param {(Function|string)} inplace
- * @param {Object} prop
- * @param {(Function|string)} doc
- * @param {number} i
- * @param {Object} root
- * @param {(number|string)} n
- * @param {number} context
- * @param {?} dataAndEvents
- * @param {?} element
- * @return {?}
- */
- _getTechInfo : function(inplace, prop, doc, i, root, n, context, dataAndEvents, element) {
- /**
- * @param {string} name
- * @param {?} state
- * @return {undefined}
- */
- function $(name, state) {
- if (name) {
- if (state) {
- obj[name] = state;
- }
- }
- }
- /**
- * @param {string} p
- * @return {undefined}
- */
- function factory(p) {
- if (prop[p]) {
- $(p, "1");
- }
- }
- var obj = {};
- var parentXY;
- prop = prop || {};
- i = i || me.getTimestamp();
- root = root || me.getTimezone();
- $("j", data.getJavaEnabled() ? "1" : "");
- $("nt", data.netType());
- if (screen) {
- $("s", screen.width + "x" + screen.height + "x" + (screen.colorDepth || screen.pixelDepth));
- }
- if (win.devicePixelRatio) {
- $("sk", win.devicePixelRatio);
- }
- if (data.isIframe()) {
- $("ifr", "1");
- }
- $("adb", methods.getVal());
- $("f", data.getFlashVersion());
- $("l", data.getSilverlightVersion());
- $("fpr", data.getFingerPrint());
- $("cn", this.counterNum);
- if (!prop.pa) {
- parentXY = dom.getViewportSize();
- $("w", parentXY[0] + "x" + parentXY[1]);
- }
- $("z", root);
- $("i", i);
- $("et", Math.round((new Date).getTime() / 1E3));
- $("en", dom.getDocumentCharset());
- $("v", v);
- $("c", navigator.cookieEnabled ? "1" : "");
- $("la", data.getLanguage());
- $("ntf", data.getNotificationPermission());
- if (!self.random(100)) {
- $("np", exports.encode(Base64.encode(self.trim(data.getPlatform(), 100))));
- }
- if (n) {
- $("wh", "1");
- }
- /** @type {Array.<string>} */
- root = "ar ln dl ad nb pa pq pv ex".split(" ");
- /** @type {number} */
- i = 0;
- for (;i < root.length;i++) {
- factory(root[i]);
- }
- /** @type {Array} */
- root = ["va", "vt", "sn", "sa", "he"];
- if (prop.nb) {
- root.push("cl");
- }
- /** @type {number} */
- i = 0;
- for (;i < root.length;i++) {
- n = root[i];
- $(n, prop[n]);
- }
- root = new Node({
- counterId : doc
- });
- if (root.isEnabled()) {
- doc = root.getStorageId();
- if (i = root.get("reqNum")) {
- i++;
- } else {
- /** @type {number} */
- i = 1;
- }
- root.set("reqNum", i);
- if (root.get("reqNum") == i) {
- $("ls", doc);
- $("rqn", i);
- } else {
- root.remove("reqNum");
- root.clearStorageId();
- if (1 < i) {
- $("ls", doc);
- $("rqn", 0);
- }
- }
- }
- $("rn", self.random());
- $("hid", context);
- $("ds", getValue(element));
- if (!element._firstPaint) {
- element._firstPaint = calcFirstPaintTimeResults();
- $("fp", element._firstPaint);
- }
- if (dataAndEvents) {
- if (!win.name) {
- /** @type {number} */
- win.name = Math.round(65535 * Math.random());
- }
- if (context = +win.name) {
- if (0 > context) {
- context *= -1;
- }
- context %= 65535;
- }
- $("wn", context || self.fletcher(win.name));
- try {
- if (win.history) {
- $("hl", String(win.history.length));
- }
- } catch (La) {
- }
- }
- /** @type {string} */
- context = "";
- if (this.sendTitle) {
- context = this._getTitle(inplace);
- }
- $("t", context);
- return obj;
- },
- /**
- * @param {(Function|string)} data
- * @return {?}
- */
- _getTitle : function(data) {
- data = "undefined" == typeof data ? (data = dom.getDocumentTitle()) ? self.trim(data, firstLength) : "" : self.trim(data, firstLength);
- return data;
- }
- });
- /**
- * @param {Array} args
- * @return {?}
- */
- self.array2Props = function(args) {
- var len = args.length;
- var aup = {};
- var cur = aup;
- var i;
- var dir;
- /** @type {number} */
- i = 0;
- for (;i < len - 1;i++) {
- dir = args[i];
- cur[dir] = {};
- if (i < len - 2) {
- cur = cur[dir];
- }
- }
- cur[dir] = args[len - 1];
- return aup;
- };
- var Game = $.inherit({
- sampling : 1,
- counterId : 26302566,
- /**
- * @return {undefined}
- */
- _initComponent : function() {
- Game.superclass._initComponent.apply(this, arguments);
- this._sender = new klass({
- protocol : "https:",
- counterId : this.counterId,
- retry : false,
- counter : {}
- });
- },
- /**
- * @return {undefined}
- */
- log : function() {
- this.logParams(self.array2Props(arguments));
- },
- /**
- * @param {?} opt_attributes
- * @return {undefined}
- */
- logParams : function(opt_attributes) {
- if (Math.random() < this.sampling) {
- this._sender.sendHit({
- url : params.href,
- title : "",
- referrer : "",
- vParams : opt_attributes
- });
- }
- }
- });
- var _initComponent = instance.inherit({
- resource : "webvisor",
- retry : true,
- postParams : ["wv-data"],
- /**
- * @param {Object} packet
- * @param {?} type
- * @param {?} dataAndEvents
- * @param {number} deepDataAndEvents
- * @param {number} data
- * @param {string} tel
- * @param {Function} callback
- * @param {?} $rootScope
- * @return {?}
- */
- sendPacket : function(packet, type, dataAndEvents, deepDataAndEvents, data, tel, callback, $rootScope) {
- var message;
- var error;
- if (!packet || !packet.length) {
- return false;
- }
- message = exports.encode(packet, true);
- if (0 == message.indexOf("AAAAAAAAADw")) {
- if (win.Error) {
- /** @type {Error} */
- error = Error();
- if ("string" == typeof error.stack) {
- (new Game({
- sampling : 0.1
- })).log("bad visor packet 5", 1);
- }
- }
- }
- packet = {
- rn : self.random(),
- "page-url" : type,
- wmode : 0,
- "wv-type" : 0,
- "wv-hit" : dataAndEvents,
- "wv-part" : deepDataAndEvents + 1,
- "wv-check" : self.fletcher(packet),
- "wv-data" : message
- };
- data = {
- v : this._getVersion(),
- z : data,
- i : tel
- };
- return this.send(packet, data, callback, $rootScope);
- }
- });
- var t = ret.inherit({
- protocol : "",
- counterId : "",
- counterType : "",
- meta : null,
- maxBufferSize : 7500,
- flushTimeout : 3E4,
- storageKey : "visorbuff",
- active : false,
- /**
- * @return {undefined}
- */
- _initComponent : function() {
- this.storage = new Node({
- counterId : this.counterId
- });
- this._sender = new _initComponent({
- protocol : this.protocol,
- counterId : this.counterId,
- counterType : this.counterType
- });
- t.superclass._initComponent.apply(this, arguments);
- },
- /**
- * @param {Object} packet
- * @param {Object} a
- * @param {number} deepDataAndEvents
- * @return {undefined}
- */
- onFlush : function(packet, a, deepDataAndEvents) {
- this._sender.sendPacket(packet, a.url, a.hitId, deepDataAndEvents, a.timezone, a.timestamp);
- }
- });
- var Repo = instance.inherit({
- resource : "webvisor",
- transports : [options, Model],
- postParams : ["wv-data"],
- /**
- * @param {Object} str
- * @param {string} keepData
- * @param {?} deepDataAndEvents
- * @param {number} value
- * @param {string} val
- * @param {Function} serviceName
- * @param {?} $rootScope
- * @return {?}
- */
- sendContent : function(str, keepData, deepDataAndEvents, value, val, serviceName, $rootScope) {
- if (!str) {
- return false;
- }
- if (-1 < str.indexOf("\r")) {
- str = str.replace(/\r\n/g, "\n");
- }
- str = {
- "wv-type" : 1,
- "page-url" : trigger().href,
- "wv-hit" : deepDataAndEvents,
- "wv-data" : exports.encode(Base64.encode(str))
- };
- return 245E3 < str["wv-data"].length ? false : this.send(str, {
- z : value,
- i : val,
- pct : keepData || ""
- }, serviceName, $rootScope);
- }
- });
- /**
- * @param {Object} a
- * @param {Object} object
- * @return {?}
- */
- self.isEqual = function(a, object) {
- /** @type {boolean} */
- var all = true;
- self.forEachKey(a, function(property, value) {
- if (!(object.hasOwnProperty(property) && object[property] === value)) {
- /** @type {boolean} */
- all = false;
- }
- });
- if (!all) {
- return all;
- }
- self.forEachKey(object, function(key, value) {
- if (!(a.hasOwnProperty(key) && a[key] === value)) {
- /** @type {boolean} */
- all = false;
- }
- });
- return all;
- };
- var Event = $.inherit({
- /**
- * @return {undefined}
- */
- _initComponent : function() {
- Event.superclass._initComponent.apply(this, arguments);
- /** @type {Array} */
- this._listeners = [];
- },
- /**
- * @param {HTMLElement} el
- * @param {string} type
- * @param {Function} callback
- * @param {Node} context
- * @param {Object} ev
- * @return {undefined}
- */
- on : function(el, type, callback, context, ev) {
- ev = Event._getOpts(ev);
- type = type.split(",");
- var l = type.length;
- var unloadListeners = this._listeners;
- var sType;
- var bound;
- var i;
- /** @type {number} */
- i = 0;
- for (;i < l;i++) {
- sType = type[i];
- bound = bind(function(e) {
- callback.call(context || this, e || win.event);
- }, "on" + sType);
- /** @type {Array} */
- unloadListeners[unloadListeners.length] = [el, sType, callback, context, ev, bound];
- if (el.addEventListener) {
- el.addEventListener(sType, bound, Event._prepOpts(ev));
- } else {
- if (el.attachEvent) {
- el.attachEvent("on" + sType, bound);
- }
- }
- }
- },
- /**
- * @param {HTMLElement} item
- * @param {string} type
- * @param {Function} callback
- * @param {?} dataAndEvents
- * @param {Object} fn
- * @return {undefined}
- */
- un : function(item, type, callback, dataAndEvents, fn) {
- fn = Event._getOpts(fn);
- var listeners = this._listeners;
- var jl = listeners.length;
- var j;
- var a;
- /** @type {number} */
- j = 0;
- for (;j < jl;j++) {
- if (a = listeners[j], a[0] == item && (a[1] == type && (a[2] == callback && (a[3] == dataAndEvents && self.isEqual(a[4], fn))))) {
- listeners.splice(j, 1);
- this._removeListener(item, type, a[5], fn);
- break;
- }
- }
- },
- /**
- * @return {undefined}
- */
- unAll : function() {
- var listeners = this._listeners;
- var jl = listeners.length;
- var listener;
- var j;
- /** @type {number} */
- j = 0;
- for (;j < jl;j++) {
- listener = listeners[j];
- this._removeListener(listener[0], listener[1], listener[5], listener[4]);
- }
- /** @type {number} */
- listeners.length = 0;
- },
- /**
- * @param {Object} element
- * @param {string} type
- * @param {?} func
- * @param {boolean} ev
- * @return {undefined}
- */
- _removeListener : function(element, type, func, ev) {
- if (element.removeEventListener) {
- element.removeEventListener(type, func, Event._prepOpts(ev));
- } else {
- if (element.detachEvent) {
- element.detachEvent("on" + type, func);
- }
- }
- }
- });
- /**
- * @return {?}
- */
- Event.supportsPassive = function() {
- var useCapture;
- if (Event._supportsPassive !== value) {
- return Event._supportsPassive;
- }
- /** @type {boolean} */
- Event._supportsPassive = false;
- try {
- /** @type {Object} */
- useCapture = Object.defineProperty({}, "passive", {
- /**
- * @return {undefined}
- */
- get : function() {
- /** @type {boolean} */
- Event._supportsPassive = true;
- }
- });
- win.addEventListener("test", null, useCapture);
- } catch (b) {
- }
- return Event._supportsPassive;
- };
- /**
- * @param {Object} args
- * @return {?}
- */
- Event._getOpts = function(args) {
- return self.mixin({
- capture : true,
- passive : true
- }, args || {});
- };
- /**
- * @param {boolean} ui
- * @return {?}
- */
- Event._prepOpts = function(ui) {
- return Event.supportsPassive() ? ui : !!ui.capture;
- };
- /**
- * @return {undefined}
- */
- Event.on = function() {
- if (!Event._instance) {
- Event._instance = new Event;
- }
- Event._instance.on.apply(Event._instance, arguments);
- };
- /**
- * @return {undefined}
- */
- Event.un = function() {
- if (Event._instance) {
- Event._instance.un.apply(Event._instance, arguments);
- }
- };
- /**
- * @return {?}
- */
- dom.getDocumentHTML = function() {
- var root;
- /** @type {string} */
- var value = "";
- /** @type {Element} */
- root = doc.documentElement;
- /** @type {string} */
- var data = root.outerHTML;
- var expires;
- var i;
- var p;
- if (data) {
- /** @type {string} */
- root = data;
- } else {
- /** @type {(NamedNodeMap|null)} */
- data = root.attributes;
- /** @type {string} */
- expires = "";
- /** @type {number} */
- i = 0;
- for (;i < data.length;i++) {
- if (p = data[i]) {
- expires += " " + p.name + '="' + (p.value || "") + '"';
- }
- }
- /** @type {string} */
- root = "<html" + expires + ">" + root.innerHTML + "</html>";
- }
- if (data = doc.doctype) {
- /** @type {string} */
- value = data.publicId ? ' PUBLIC "' + data.publicId + '"' : "";
- /** @type {string} */
- expires = data.systemId ? ' "' + data.systemId + '"' : "";
- /** @type {string} */
- value = "<!DOCTYPE " + data.name + value + expires + ">\n";
- }
- return value + root;
- };
- /**
- * @return {?}
- */
- dom.getDocumentScroll = function() {
- return[win.pageXOffset || (doc.documentElement && doc.documentElement.scrollLeft || (doc.body && doc.body.scrollLeft || 0)), win.pageYOffset || (doc.documentElement && doc.documentElement.scrollTop || (doc.body && doc.body.scrollTop || 0))];
- };
- /**
- * @param {(Object|string)} element
- * @return {?}
- */
- dom.getElementParent = function(element) {
- var src;
- if (!element || element == doc.documentElement) {
- return null;
- }
- if (element == doc.body) {
- return doc.documentElement;
- }
- /** @type {null} */
- src = null;
- try {
- src = element.parentNode;
- } catch (c) {
- }
- return src;
- };
- /**
- * @param {Element} element
- * @param {boolean} name
- * @return {?}
- */
- dom.getElementChildren = function(element, name) {
- /** @type {Array} */
- var children = [];
- var nodes;
- var node;
- var h;
- var _i;
- var _len;
- if (element && (nodes = element.childNodes)) {
- /** @type {number} */
- _i = 0;
- _len = nodes.length;
- for (;_i < _len;_i++) {
- node = nodes[_i];
- if (!(h = "INPUT" == node.nodeName && (node.type && "hidden" == node.type.toLocaleLowerCase()))) {
- if (!(name && node.nodeName != name)) {
- self.mergeArrays(children, [node]);
- }
- }
- }
- }
- return children;
- };
- /**
- * @param {string} element
- * @return {?}
- */
- dom.getElementNeighborPosition = function(element) {
- var nodes = dom.getElementParent(element);
- var className;
- var attr;
- var getElementNeighborPosition;
- var i;
- if (nodes) {
- /** @type {number} */
- getElementNeighborPosition = 0;
- nodes = nodes.childNodes;
- attr = element && element.nodeName;
- /** @type {number} */
- i = 0;
- for (;i < nodes.length;i++) {
- if (className = nodes[i] && nodes[i].nodeName, attr == className) {
- if (element == nodes[i]) {
- return getElementNeighborPosition;
- }
- getElementNeighborPosition++;
- }
- }
- }
- return 0;
- };
- /**
- * @param {Element} el
- * @return {?}
- */
- dom.getElementXY = function(el) {
- var offsetLeft;
- var offsetTop;
- if (!el || (!el.ownerDocument || ("PARAM" == el.tagName || (el == doc.body || el == doc.documentElement)))) {
- return[0, 0];
- }
- if (el.getBoundingClientRect) {
- return el = el.getBoundingClientRect(), offsetLeft = dom.getDocumentScroll(), [Math.round(el.left + offsetLeft[0]), Math.round(el.top + offsetLeft[1])];
- }
- /** @type {number} */
- offsetTop = offsetLeft = 0;
- for (;el;) {
- offsetLeft += el.offsetLeft;
- offsetTop += el.offsetTop;
- el = el.offsetParent;
- }
- return[offsetLeft, offsetTop];
- };
- /**
- * @return {?}
- */
- dom.getDocumentSize = function() {
- var doc = dom.getRootElement();
- var points = dom.getViewportSize();
- return[Math.max(doc.scrollWidth, points[0]), Math.max(doc.scrollHeight, points[1])];
- };
- /**
- * @param {string} el
- * @return {?}
- */
- dom.getElementSize = function(el) {
- var $cont;
- return el == doc.body || el == doc.documentElement ? dom.getDocumentSize() : ($cont = el.getBoundingClientRect && el.getBoundingClientRect()) ? [$cont.width, $cont.height] : [el.offsetWidth, el.offsetHeight];
- };
- /**
- * @param {string} element
- * @return {?}
- */
- dom.getElementRegion = function(element) {
- var elementRect = dom.getElementXY(element);
- element = dom.getElementSize(element);
- return[elementRect[0], elementRect[1], element[0], element[1]];
- };
- /**
- * @param {Object} node
- * @return {?}
- */
- dom.calcChildrenChecksum = function(node) {
- return self.fletcher((node.innerHTML || "").replace(/(<[^>]*>|[\u0000-\u0020])/g, ""));
- };
- /**
- * @param {HTMLFormElement} dataAndEvents
- * @return {?}
- */
- dom.getFormNumber = function(dataAndEvents) {
- /** @type {NodeList} */
- var codeSegments = doc.getElementsByTagName("form");
- var i;
- var valsLength;
- /** @type {number} */
- i = 0;
- /** @type {number} */
- valsLength = codeSegments.length;
- for (;i < valsLength;i++) {
- if (codeSegments[i] == dataAndEvents) {
- return i;
- }
- }
- return-1;
- };
- /**
- * @param {Element} a
- * @return {?}
- */
- dom.isEmptyField = function(a) {
- return "INPUT" == a.nodeName && ("submit" != a.type && ("image" != a.type && "hidden" != a.type)) ? "radio" == a.type || "checkbox" == a.type ? !a.checked : !a.value : "TEXTAREA" == a.nodeName ? !a.value : "SELECT" == a.nodeName ? 0 > a.selectedIndex : true;
- };
- /**
- * @param {Node} children
- * @return {?}
- */
- dom.calcTextChecksum = function(children) {
- /** @type {string} */
- var textContent = "";
- children = children.childNodes;
- var i;
- var valsLength;
- /** @type {number} */
- i = 0;
- valsLength = children.length;
- for (;i < valsLength;i++) {
- if (children[i]) {
- if (3 == children[i].nodeType) {
- textContent += children[i].nodeValue;
- }
- }
- }
- return self.fletcher(textContent.replace(/[\u0000-\u0020]+/g, ""));
- };
- /**
- * @param {Element} el
- * @return {?}
- */
- dom.calcAttribChecksum = function(el) {
- /** @type {string} */
- var qs = "";
- /** @type {Array.<string>} */
- var codeSegments = "width height align title alt name".split(" ");
- var i;
- if ("IMG" == el.tagName) {
- qs += el.src.toLowerCase();
- }
- if ("A" == el.tagName) {
- qs += el.href.toLowerCase();
- }
- qs += String(el.className || "").toLowerCase();
- /** @type {number} */
- i = 0;
- for (;i < codeSegments.length;i++) {
- if (el.getAttribute) {
- qs += String(el.getAttribute(codeSegments[i]) || "").toLowerCase();
- }
- }
- return self.fletcher(qs.replace(/[\u0000-\u0020]+/g, ""));
- };
- /**
- * @param {Object} v02
- * @param {string} dataAndEvents
- * @return {?}
- */
- dom.classNameExists = function(v02, dataAndEvents) {
- try {
- return(new RegExp("(?:^|\\s)" + dataAndEvents + "(?:\\s|$)")).test(v02.className);
- } catch (c) {
- return false;
- }
- };
- /**
- * @param {string} node
- * @param {Object} context
- * @return {?}
- */
- dom.getElementsByClassName = function(node, context) {
- var codeSegments;
- var retnode;
- var i;
- context = context || doc;
- codeSegments = context.getElementsByTagName("*");
- /** @type {Array} */
- retnode = [];
- /** @type {number} */
- i = 0;
- for (;i < codeSegments.length;i++) {
- if (dom.classNameExists(codeSegments[i], node)) {
- retnode.push(codeSegments[i]);
- }
- }
- return retnode;
- };
- var lb = !check(/webkit/) && check(/gecko/);
- var Class = $.inherit({
- hid : 0,
- tz : 0,
- ts : 0,
- counterId : 0,
- counterType : 0,
- url : "",
- protocol : "",
- enabled : false,
- /**
- * @return {undefined}
- */
- _initComponent : function() {
- var controller;
- var c;
- if (this.isEnabled()) {
- controller = this._getStorage();
- c = controller.read("visorc");
- if ("b" != c) {
- if ("w" != c) {
- /** @type {string} */
- c = "";
- }
- }
- if (!controller.isEnabled() || check("opera mini")) {
- /** @type {string} */
- c = "b";
- }
- this._vc = c;
- if ("b" != c) {
- this._recorder = new init(this.protocol, this.counterId, this.counterType, this.hid, this.counter);
- }
- Class.superclass._initComponent.apply(this, arguments);
- }
- },
- /**
- * @param {Object} d
- * @return {undefined}
- */
- start : function(d) {
- var b;
- var width;
- if (this.isEnabled() && this._recorder) {
- d = d || {};
- /** @type {number} */
- b = +d.recp;
- if (!isFinite(b) || (0 > b || 1 < b)) {
- /** @type {string} */
- width = "w";
- }
- if (!width) {
- /** @type {string} */
- width = this.hid % 1E4 / 1E4 < b ? "w" : "b";
- }
- this._getStorage().create("visorc", width, 30);
- if ("w" == width) {
- this._recorder.start();
- b = d.arch_type;
- if (d = d.urls) {
- if (b) {
- if ("none" != b) {
- this._recorder.uploadPages(d, b);
- }
- }
- }
- } else {
- this._recorder.stop();
- }
- }
- },
- /**
- * @return {?}
- */
- isEnabled : function() {
- return this.enabled;
- },
- /**
- * @return {?}
- */
- getVc : function() {
- return this._vc;
- },
- /**
- * @return {?}
- */
- _getStorage : function() {
- if (!this._storage) {
- this._storage = new Controller({
- counterId : this.counterId
- });
- }
- return this._storage;
- }
- });
- var Request = options.inherit({
- id : "RawBodyXHR",
- postParams : ["body"],
- /**
- * @return {undefined}
- */
- _setHeaders : function() {
- },
- /**
- * @param {Object} data
- * @return {?}
- */
- _preparePostParams : function(data) {
- return data.post.body || "";
- }
- });
- /**
- * @param {Array} array
- * @param {Function} callable
- * @param {?} thisObj
- * @return {?}
- */
- self.arrayFilter = function(array, callable, thisObj) {
- /** @type {Array} */
- var result = [];
- var i;
- /** @type {number} */
- i = 0;
- for (;i < array.length;i++) {
- if (callable.call(thisObj, array[i], i, array)) {
- result.push(array[i]);
- }
- }
- return result;
- };
- /**
- * @param {?} other
- * @param {?} value
- * @return {?}
- */
- self.arrDiff = function(other, value) {
- return self.arrayFilter(other, function(key) {
- return-1 === self.arrayIndexOf(value, key);
- });
- };
- /**
- * @param {Object} jsonString
- * @return {?}
- */
- JSON.parse = function(jsonString) {
- try {
- return JSON.parse(jsonString);
- } catch (b) {
- return null;
- }
- };
- /**
- * @return {?}
- */
- self.getTld = function() {
- var codeSegments;
- if (!this._tld) {
- codeSegments = params.hostname.split(".");
- this._tld = codeSegments[codeSegments.length - 1];
- }
- return this._tld;
- };
- s3 = request.inherit({
- id : "script",
- /**
- * @param {Element} el
- * @param {Object} data
- * @param {Function} callback
- * @param {?} scope
- * @return {?}
- */
- request : function(el, data, callback, scope) {
- var key;
- var script = self.getNativeFunction("createElement", doc)("script");
- if (!script) {
- return callback.call(scope, false), false;
- }
- /** @type {string} */
- key = "_ymjsp" + self.random();
- win[key] = bind(function() {
- try {
- delete win[key];
- } catch (l) {
- /** @type {(Function|string)} */
- win[key] = value;
- }
- callback.apply(scope, self.mergeArrays([true], arguments));
- if (script.parentNode) {
- script.parentNode.removeChild(script);
- }
- }, "transport.script");
- /** @type {string} */
- script.type = "text/javascript";
- script.src = this._buildUrl(el, self.mixin({
- wmode : 5,
- callback : key
- }, data));
- el = doc.getElementsByTagName("head")[0];
- if (!el) {
- /** @type {Element} */
- el = doc.createElement("head");
- doc.documentElement.appendChild(el);
- }
- el.insertBefore(script, el.firstChild);
- return true;
- }
- });
- var Comment = klass.inherit({
- transports : [s3],
- trimParams : true,
- /**
- * @return {undefined}
- */
- _initComponent : function() {
- Comment.superclass._initComponent.apply(this, arguments);
- this._ilStorage = new Node({
- counterId : this.counterId
- });
- },
- /**
- * @param {Object} args
- * @return {undefined}
- */
- sendHit : function(args) {
- var map = {};
- var str = this._ilStorage.get("il");
- if (args.visitColor) {
- map.vc = args.visitColor;
- }
- if (args.hasPrerender) {
- /** @type {number} */
- map.pr = 1;
- }
- if (str) {
- this._ilStorage.remove("il");
- map.ilt = exports.encode(Base64.encode(self.trim(str, raw)));
- }
- this._hitExt({
- url : args.url,
- title : args.title,
- referrer : args.referrer,
- vParams : args.vParams,
- userParams : args.userParams,
- experiments : args.experiments,
- modes : args.modes,
- browserInfo : map,
- ts : args.ts,
- tz : args.tz,
- callback : args.callback,
- ctx : args.ctx
- });
- }
- });
- var _cn = $.inherit({
- cid : 3,
- cnt : 0,
- /**
- * @return {undefined}
- */
- _initComponent : function() {
- this._storage = new Node;
- },
- /**
- * @param {Function} f
- * @return {undefined}
- */
- hit : function(f) {
- var self = this;
- var e = this._storage.get("wasSynced");
- if (e && e.time + 864E5 > +new Date || win.Ya._metrika.fakeHit) {
- f();
- } else {
- /** @type {boolean} */
- win.Ya._metrika.fakeHit = true;
- this._getSender().sendHit({
- /**
- * @return {undefined}
- */
- callback : function() {
- self._storage.set("wasSynced", {
- time : +new Date
- });
- f();
- }
- });
- }
- },
- /**
- * @return {?}
- */
- _getSender : function() {
- if (!this._sender) {
- this._sender = new Comment({
- protocol : "https:",
- counterType : this.cnt,
- counterId : this.cid,
- sendTitle : false,
- dontSendRequests : this.dontSendRequests,
- fake : true
- });
- }
- return this._sender;
- }
- });
- var Async = $.inherit({
- baseUrl : "https://mc.yandex.",
- baseTld : "ru",
- syncTlds : ["ua", "by", "kz", "com.tr"],
- langToDomain : {
- uk : "ua",
- be : "by",
- tr : "com.tr",
- kk : "kz"
- },
- /**
- * @param {?} callback
- * @return {undefined}
- */
- sync : function(callback) {
- var jQuery = this;
- var memory = this._need();
- if (!this._is() && memory) {
- this._setStatus(true);
- if (success()) {
- this._getCn().hit(function() {
- jQuery._sync(memory, callback);
- });
- } else {
- callback(function() {
- jQuery._sync(memory);
- });
- }
- } else {
- callback();
- }
- },
- /**
- * @return {?}
- */
- _is : function() {
- try {
- return!!win.Ya._metrika.startSync;
- } catch (a) {
- return false;
- }
- },
- /**
- * @param {boolean} dataAndEvents
- * @return {undefined}
- */
- _setStatus : function(dataAndEvents) {
- try {
- /** @type {boolean} */
- win.Ya._metrika.startSync = dataAndEvents;
- } catch (b) {
- }
- },
- /**
- * @return {?}
- */
- _need : function() {
- var key = this._getDomainByLang();
- var name = this._getTld();
- var buf;
- /** @type {Array} */
- var keys = [];
- if (-1 != self.arrayIndexOf(this.syncTlds, key)) {
- keys.push(key);
- }
- if (-1 != self.arrayIndexOf(this.syncTlds, name)) {
- if (-1 == self.arrayIndexOf(keys, name)) {
- keys.push(name);
- }
- }
- buf = this._getLs().get("synced") || {};
- keys = self.arrayFilter(keys, function(off) {
- return(buf[off] || 1) + 864E5 < +new Date;
- });
- return keys.length && keys || false;
- },
- /**
- * @param {string} options
- * @param {Function} callback
- * @return {undefined}
- */
- _sync : function(options, callback) {
- var codeSegments;
- var self;
- var remote = this;
- if (options.length) {
- self = new Request({
- method : "GET"
- });
- callback = callback || function() {
- };
- self.request(this.baseUrl + this.baseTld + "/sync_cookie_get", null, function(dataAndEvents, s) {
- var i;
- var n;
- var data_user;
- /** @type {number} */
- var a = 0;
- /** @type {number} */
- var bup = 0;
- var browser;
- var authHeader;
- if (dataAndEvents) {
- i = JSON.parse(s);
- try {
- n = i.sync_token;
- authHeader = i.sync_ok;
- } catch (Gb) {
- return callback(), false;
- }
- codeSegments = self.arrDiff(options, authHeader);
- if (a = codeSegments.length) {
- data_user = remote._getLs();
- browser = new Browser;
- /** @type {number} */
- i = 0;
- for (;i < codeSegments.length;i++) {
- (function(path) {
- browser.request(remote.baseUrl + path + "/sync_cookie_image_check", {
- body : n
- }, function(udataCur) {
- bup++;
- if (a === bup) {
- callback();
- }
- if (udataCur) {
- udataCur = data_user.get("synced") || {};
- /** @type {number} */
- udataCur[path] = +new Date;
- data_user.set("synced", udataCur);
- }
- });
- })(codeSegments[i]);
- }
- } else {
- callback();
- }
- } else {
- callback();
- }
- });
- } else {
- callback();
- }
- },
- /**
- * @return {?}
- */
- _getCn : function() {
- if (!this._cn) {
- this._cn = new _cn({
- fake : true,
- dontSendRequests : this.dontSendRequests
- });
- }
- return this._cn;
- },
- /**
- * @return {?}
- */
- _getLs : function() {
- if (!this._ls) {
- this._ls = new Node;
- }
- return this._ls;
- },
- /**
- * @return {?}
- */
- _getTld : function() {
- var name = self.getTld();
- return{
- tr : "com.tr",
- "\u0443\u043a\u0440" : "ua",
- "xn--j1amh" : "ua",
- "\u0431\u0435\u043b" : "by",
- "xn--90ais" : "by"
- }[name] || name;
- },
- /**
- * @return {?}
- */
- _getDomainByLang : function() {
- var line;
- if (!win.navigator) {
- return "ru";
- }
- try {
- line = navigator.languages ? navigator.languages[0] : data.getLanguage();
- } catch (b) {
- }
- line = (line || "").toLowerCase().split("-")[0];
- return this.langToDomain[line] || "ru";
- }
- });
- data.isAndroid = bind(function() {
- /** @type {string} */
- var ua = navigator.userAgent.toLowerCase();
- return-1 < ua.indexOf("android") && (-1 < ua.indexOf("mobile") && navigator.platform.match(/^android|linux armv/i));
- }, "", true);
- /**
- * @return {?}
- */
- self.isDev = function() {
- var tag;
- if (self._isDevSetted) {
- return self._isDev;
- }
- try {
- /** @type {boolean} */
- self._isDevSetted = true;
- /** @type {Image} */
- tag = new Image;
- Object.defineProperty(tag, "id", {
- /**
- * @return {undefined}
- */
- get : function() {
- /** @type {boolean} */
- self._isDev = true;
- }
- });
- } catch (b) {
- }
- };
- var me = {
- /**
- * @return {?}
- */
- getMinutes : function() {
- return Math.floor(+new Date / 1E3 / 60);
- }
- };
- var inst = {
- _url : "https://mc.yandex.ru/user_storage_set?",
- _params : {},
- /**
- * @param {Object} params
- * @return {undefined}
- */
- init : function(params) {
- this._params = params || {};
- },
- /**
- * @param {string} key
- * @param {string} value
- * @return {undefined}
- */
- save : function(key, value) {
- this._getReq().request(this._url + store.stringify({
- key : key,
- value : self.toJSON(value)
- }));
- this._getLs().set(key, value);
- },
- /**
- * @param {string} id
- * @return {?}
- */
- get : function(id) {
- return{
- remote : this._params[id],
- local : this._getLs().get(id)
- };
- },
- /**
- * @param {Object} attr
- * @return {?}
- */
- getNum : function(attr) {
- attr = this.get(attr);
- return Math.max(+attr.remote || 0, +attr.local || 0);
- },
- /**
- * @return {?}
- */
- _getLs : function() {
- if (!this._ls) {
- this._ls = new Node;
- }
- return this._ls;
- },
- /**
- * @return {?}
- */
- _getReq : function() {
- if (!this._req) {
- this._req = new Browser;
- }
- return this._req;
- }
- };
- var model = {
- sync : bind(function() {
- /** @type {Array} */
- var props = ["30102", "29009"];
- var c = {
- t : 'UV|L7,!"T[rwe&D_>ZIb\\aW#98Y.PC6k'
- };
- var self;
- var _len2;
- if (this._enabled()) {
- this._setStatus(true);
- self = new Request({
- method : "GET",
- withCredentials : false
- });
- /** @type {number} */
- _len2 = props.length;
- (function save(key) {
- var p = props[key];
- if (key < _len2) {
- self.request("http://127.0.0.1:" + p + "/p", c, function(walkers, inplace) {
- if (walkers) {
- this._save(walkers, inplace, p);
- } else {
- save.call(this, key + 1);
- }
- }, this);
- } else {
- this._save(false);
- }
- }).call(this, 0);
- }
- }, "ds"),
- /**
- * @param {boolean} obj
- * @param {string} data
- * @param {number} options
- * @return {undefined}
- */
- _save : function(obj, data, options) {
- var udataCur = me.getMinutes();
- if (obj) {
- (new klass({
- protocol : "https:",
- counterType : 0,
- counterId : 42822899,
- sendTitle : false,
- fake : true
- })).sendDevice({
- data : self.trim(data),
- port : options
- });
- } else {
- udataCur -= 45;
- }
- inst.save("ds", udataCur);
- },
- /**
- * @return {?}
- */
- _is : function() {
- try {
- return!!win.Ya._metrika.dSync;
- } catch (a) {
- return false;
- }
- },
- /**
- * @return {?}
- */
- _enabled : function() {
- return 60 < me.getMinutes() - inst.getNum("ds") && (0 == trigger().hostname.search(/^(.*\.)?((ya|yandex(\-team)?)\.(com\.)?\w+|(auto|kinopoisk)\.ru|yadi\.sk|yastatic\.net)$/) && (!this._is() && (data.isAndroid() && !self.isDev())));
- },
- /**
- * @param {boolean} dataAndEvents
- * @return {undefined}
- */
- _setStatus : function(dataAndEvents) {
- try {
- /** @type {boolean} */
- win.Ya._metrika.dSync = dataAndEvents;
- } catch (b) {
- }
- }
- };
- var that = {
- /**
- * @param {Object} e
- * @return {?}
- */
- getPos : function(e) {
- var doc = dom.getRootElement();
- var nearby = dom.getDocumentScroll();
- return[e.pageX || (e.clientX + nearby[0] - (doc.clientLeft || 0) || 0), e.pageY || (e.clientY + nearby[1] - (doc.clientTop || 0) || 0)];
- },
- /**
- * @param {Object} obj
- * @return {?}
- */
- getTarget : function(obj) {
- /** @type {null} */
- var el = null;
- try {
- if (el = obj.target || obj.srcElement) {
- if (!el.ownerDocument) {
- if (el.documentElement) {
- el = el.documentElement;
- }
- }
- }
- } catch (c) {
- }
- return el;
- },
- /**
- * @param {Object} e
- * @return {?}
- */
- getMouseButton : function(e) {
- return e.which || e.button == value ? e.which : e.button & 1 ? 1 : e.button & 2 ? 3 : e.button & 4 ? 2 : 0;
- },
- /**
- * @param {Object} event
- * @return {undefined}
- */
- prevent : function(event) {
- event = event || win.event;
- if (event.preventDefault) {
- event.preventDefault();
- } else {
- /** @type {boolean} */
- event.returnValue = false;
- }
- }
- };
- that.dispatchCustomEvent = bind(function(name, ctx) {
- var e;
- ctx = ctx || doc;
- if (e = self.getNativeFunction("createEvent", doc)("Event")) {
- e.initEvent(name, false, false);
- self.getNativeFunction("dispatchEvent", ctx)(e);
- }
- }, "evt.dispatch");
- /**
- * @param {Function} callback
- * @return {undefined}
- */
- Event.ready = function(callback) {
- /** @type {(Performance|null)} */
- var data = win.performance;
- var handler;
- if ("object" == typeof data && (data.timing && data.timing.domContentLoadedEventStart)) {
- callback();
- } else {
- /**
- * @return {undefined}
- */
- handler = function() {
- Event.un(doc, "DOMContentLoaded", handler);
- Event.un(win, "load", handler);
- callback();
- };
- Event.on(doc, "DOMContentLoaded", handler);
- Event.on(win, "load", handler);
- }
- };
- var img = {
- lastReferrer : null
- };
- /**
- * @param {boolean} o
- * @return {?}
- */
- self.isObject = function(o) {
- try {
- return o && (null !== o && "[object Object]" == Object.prototype.toString.call(o));
- } catch (b) {
- return false;
- }
- };
- /**
- * @param {?} n
- * @return {?}
- */
- self.isNumber = function(n) {
- return isFinite(n) && (!isNaN(n) && "[object Number]" == Object.prototype.toString.call(n));
- };
- /**
- * @param {?} timeoutKey
- * @return {?}
- */
- self.clearTimeout = function(timeoutKey) {
- return self.getNativeFunction("clearTimeout")(timeoutKey);
- };
- /** @type {null} */
- self._urlParser = null;
- /**
- * @param {?} urlString
- * @return {?}
- */
- self.parseUrl = function(urlString) {
- if (!this._urlParser) {
- try {
- /** @type {Element} */
- this._urlParser = doc.createElement("a");
- } catch (b) {
- }
- }
- return this._urlParser ? (this._urlParser.href = urlString, {
- protocol : this._urlParser.protocol,
- host : this._urlParser.host,
- port : this._urlParser.port,
- hostname : this._urlParser.hostname,
- hash : this._urlParser.hash,
- search : this._urlParser.search,
- query : this._urlParser.search.replace(/^\?/, ""),
- pathname : this._urlParser.pathname || "/",
- path : (this._urlParser.pathname || "/") + this._urlParser.search,
- href : this._urlParser.href
- }) : {};
- };
- /**
- * @return {?}
- */
- data.isIE = function() {
- return doc && !doc.addEventListener || false;
- };
- var console = {};
- console._cookie = new Controller({
- onlyCurrentDomain : true
- });
- console.log = bind(function() {
- var a = -1 < params.href.indexOf("_ym_debug=1") || win._ym_debug;
- if (a) {
- this._cookie.create("debug", "1");
- }
- if (win.console) {
- if (console.log) {
- if (a || "1" === this._cookie.read("debug")) {
- console.log.apply(console, arguments);
- }
- }
- }
- }, "DebugConsole.log");
- var _sender = instance.inherit({
- resource : "clmap",
- retry : true,
- transports : [Browser],
- /**
- * @param {?} event
- * @param {string} element
- * @param {Function} serviceName
- * @param {?} $rootScope
- * @return {undefined}
- */
- sendClick : function(event, element, serviceName, $rootScope) {
- this.send({
- "page-url" : event,
- "pointer-click" : element
- }, {}, serviceName, $rootScope);
- }
- });
- var Server = $.inherit({
- filter : null,
- ignoreTags : [],
- quota : 0,
- isTrackHash : false,
- protocol : "",
- counterId : 0,
- counterType : 0,
- startTime : 0,
- dontSendRequests : false,
- MAX_LEN_PATH : 128,
- TIMEOUT_CLICK : 50,
- TIMEOUT_SAME_CLICKS : 1E3,
- DELTA_SAME_CLICKS : 2,
- tags : "A B BIG BODY BUTTON DD DIV DL DT EM FIELDSET FORM H1 H2 H3 H4 H5 H6 HR I IMG INPUT LI OL P PRE SELECT SMALL SPAN STRONG SUB SUP TABLE TBODY TD TEXTAREA TFOOT TH THEAD TR U UL ABBR AREA BLOCKQUOTE CAPTION CENTER CITE CODE CANVAS DFN EMBED FONT INS KBD LEGEND LABEL MAP OBJECT Q S SAMP STRIKE TT ARTICLE AUDIO ASIDE FOOTER HEADER MENU METER NAV PROGRESS SECTION TIME VIDEO NOINDEX NOBR MAIN".split(" "),
- /**
- * @return {undefined}
- */
- _initComponent : function() {
- var f;
- var chr;
- var i;
- /** @type {null} */
- this._lastClick = null;
- /** @type {boolean} */
- this.hasQuota = !!this.quota;
- this._quota = this.quota;
- /** @type {Array} */
- this._ignoreTags = [];
- if (this.ignoreTags) {
- /** @type {number} */
- f = 0;
- for (;f < this.ignoreTags.length;f++) {
- if (this.ignoreTags[f]) {
- self.mergeArrays(this._ignoreTags, [String(this.ignoreTags[f]).toUpperCase()]);
- }
- }
- }
- this._cacheTags = {};
- /** @type {number} */
- f = 59;
- /** @type {function (...[number]): string} */
- chr = String.fromCharCode;
- /** @type {number} */
- i = 0;
- for (;i < this.tags.length;i++) {
- /** @type {string} */
- this._cacheTags[this.tags[i]] = chr(f);
- chr(f);
- f++;
- }
- this._sender = new _sender({
- dontSendRequests : this.dontSendRequests,
- protocol : this.protocol,
- counterId : this.counterId,
- counterType : this.counterType
- });
- /** @type {boolean} */
- this._start = false;
- this.start();
- },
- /**
- * @return {undefined}
- */
- destroy : function() {
- this.stop();
- },
- /**
- * @return {undefined}
- */
- start : function() {
- if (!this._start) {
- Event.on(doc, "click", this._handler, this);
- }
- /** @type {boolean} */
- this._start = true;
- },
- /**
- * @return {undefined}
- */
- stop : function() {
- if (this._start) {
- Event.un(doc, "click", this._handler, this);
- }
- /** @type {boolean} */
- this._start = false;
- },
- /**
- * @param {?} edge
- * @return {undefined}
- */
- setTrackHash : function(edge) {
- this.isTrackHash = edge;
- },
- /**
- * @param {Error} a
- * @return {?}
- */
- _isIgnore : function(a) {
- return dom.classNameExists(a, "(ym-disable-clickmap|ym-clickmap-ignore)");
- },
- /**
- * @param {Object} e
- * @return {undefined}
- */
- _handler : function(e) {
- e = {
- el : that.getTarget(e),
- pos : that.getPos(e),
- button : that.getMouseButton(e),
- time : +new Date
- };
- var previous;
- var original;
- if (this._isTrackingClick(e)) {
- previous = dom.getElementSize(e.el);
- original = dom.getElementXY(e.el);
- /** @type {Array} */
- previous = ["rn", self.random(), "x", Math.floor(65535 * (e.pos[0] - original[0]) / (previous[0] || 1)), "y", Math.floor(65535 * (e.pos[1] - original[1]) / (previous[1] || 1)), "t", Math.floor((e.time - this.startTime) / 100), "p", this._getElPath(e.el)];
- original = trigger().href;
- if (this.isTrackHash) {
- self.mergeArrays(previous, ["wh", "1"]);
- } else {
- original = original.split("#")[0];
- }
- this._sender.sendClick(self.trim(original, length), previous.join(":"));
- /** @type {Object} */
- this._lastClick = e;
- }
- },
- /**
- * @param {Object} e
- * @return {?}
- */
- _isTrackingClick : function(e) {
- var element;
- var i;
- var num;
- if (win.ymDisabledClickmap || (self.isMetrikaPlayer() || !e.el)) {
- return false;
- }
- element = e.el.tagName;
- if ((2 == e.button || 3 == e.button) && "A" != element || this.filter && !this.filter(e.el, element)) {
- return false;
- }
- /** @type {number} */
- i = 0;
- for (;i < this._ignoreTags.length;i++) {
- if (this._ignoreTags[i] == element) {
- return false;
- }
- }
- element = e.el;
- for (;element;) {
- if (this._isIgnore(element)) {
- return false;
- }
- element = element.parentNode;
- }
- if (this._lastClick) {
- if (e.time - this._lastClick.time < this.TIMEOUT_CLICK) {
- return false;
- }
- /** @type {number} */
- element = Math.abs(this._lastClick.pos[0] - e.pos[0]);
- /** @type {number} */
- i = Math.abs(this._lastClick.pos[1] - e.pos[1]);
- /** @type {number} */
- num = e.time - this._lastClick.time;
- if (this._lastClick.el == e.el && (element < this.DELTA_SAME_CLICKS && (i < this.DELTA_SAME_CLICKS && num < this.TIMEOUT_SAME_CLICKS))) {
- return false;
- }
- }
- if (this.hasQuota) {
- if (!this._quota) {
- return false;
- }
- this._quota--;
- }
- return true;
- },
- /**
- * @param {Object} element
- * @return {?}
- */
- _getElPath : function(element) {
- /** @type {string} */
- var str = "";
- for (;element && (element.parentNode && ("BODY" != element.tagName && "HTML" != element.tagName));) {
- str += this._cacheTags[element.tagName] || "*";
- str += dom.getElementNeighborPosition(element) || "";
- element = element.parentNode;
- }
- return self.trim(str, this.MAX_LEN_PATH);
- }
- });
- /**
- * @param {?} o
- * @param {Object} e
- * @return {?}
- */
- dom.loadScript = function(o, e) {
- e = e || win;
- var options = self.mixin({
- type : "text/javascript",
- charset : "utf-8",
- async : true
- }, o);
- var doc = e.document;
- var $ = self.getNativeFunction("createElement", doc);
- var script = $("script");
- var p;
- var a;
- if (script) {
- script.type = options.type;
- script.charset = options.charset;
- script.src = options.src;
- if (options.async) {
- /** @type {boolean} */
- script.async = true;
- }
- try {
- return p = doc.getElementsByTagName("head")[0], p || (a = doc.getElementsByTagName("html")[0], p = $("head"), a && a.appendChild(p)), p.insertBefore(script, p.firstChild), script;
- } catch (t) {
- }
- }
- };
- var sbp = $.inherit({
- /**
- * @return {undefined}
- */
- _initComponent : function() {
- sbp.superclass._initComponent.apply(this, arguments);
- this._executedMsgs = {};
- Event.on(win, "message", this._onMessage, this);
- },
- /**
- * @param {string} scriptLocation
- * @return {undefined}
- */
- _buildRemoteIframe : function(scriptLocation) {
- var element = self.getNativeFunction("createElement", doc)("div");
- /** @type {Element} */
- var parent = doc.body || doc.documentElement;
- var node;
- if (parent) {
- /** @type {string} */
- element.innerHTML = '<iframe name="RemoteIframe" allowtransparency="true" style="position: absolute; left: -999px; top: -999px; width: 1px; height: 1px;"></iframe>';
- node = element.firstChild;
- /**
- * @return {undefined}
- */
- node.onload = function() {
- dom.loadScript({
- src : scriptLocation
- }, node.contentWindow);
- };
- win._ym__remoteIframeEl = node;
- if (element.createShadowRoot || element.webkitCreateShadowRoot) {
- parent.appendChild(element);
- element.removeChild(node);
- if (parent = element.createShadowRoot ? element.createShadowRoot() : element.webkitCreateShadowRoot()) {
- parent.appendChild(node);
- }
- win._ym__remoteIframeContainer = element;
- } else {
- parent.appendChild(node);
- win._ym__remoteIframeContainer = node;
- }
- }
- },
- /**
- * @param {string} key
- * @return {?}
- */
- _isAllowedLang : function(key) {
- return-1 !== self.arrayIndexOf(["ru", "uk", "en", "tr"], key);
- },
- /**
- * @param {?} a
- * @return {?}
- */
- _isAllowedOrigin : function(a) {
- return/^http:\/\/(.+\.)?webvisor\.com\/?$/.test(a);
- },
- /**
- * @param {?} qualifier
- * @return {?}
- */
- _isAllowedStatic : function(qualifier) {
- return/^https?:\/\/(((.+\.)?dev\.webvisor\.com)|(yastatic\.net))(\/.*)?$/.test(qualifier);
- },
- /**
- * @param {MessageEvent} e
- * @return {undefined}
- */
- _onMessage : function(e) {
- var d;
- try {
- d = e.origin;
- } catch (c) {
- }
- if (d) {
- if (this._isAllowedOrigin(d)) {
- if (d = JSON.parse(e.data)) {
- if ("appendremote" === d.action) {
- if (this._isAllowedStatic(d.domain)) {
- if (this._isAllowedLang(d.lang)) {
- if (!this._executedMsgs[d.id]) {
- /** @type {boolean} */
- this._executedMsgs[d.id] = true;
- /** @type {MessageEvent} */
- win._ym__postMessageEvent = e;
- win._ym__inpageMode = d.inpageMode;
- win._ym__initMessage = d.initMessage;
- this._buildRemoteIframe(d.domain + "/cdn/inpage-remote/inpage-remote." + d.lang + ".js");
- }
- }
- }
- }
- }
- }
- }
- }
- });
- /**
- * @param {number} n
- * @return {?}
- */
- self.pad = function(n) {
- return(10 > n ? "0" : "") + n;
- };
- /**
- * @return {?}
- */
- me.getTimestamp = function() {
- /** @type {Date} */
- var ts = new Date;
- /** @type {Array} */
- ts = [ts.getFullYear(), ts.getMonth() + 1, ts.getDate(), ts.getHours(), ts.getMinutes(), ts.getSeconds()];
- /** @type {string} */
- var optsData = "";
- var i;
- /** @type {number} */
- i = 0;
- for (;i < ts.length;i++) {
- optsData += self.pad(ts[i]);
- }
- return optsData;
- };
- /**
- * @return {?}
- */
- me.getTimezone = function() {
- return-(new Date).getTimezoneOffset();
- };
- /**
- * @param {Function} fn
- * @param {(Document|string)} context
- * @return {?}
- */
- self.bind = function(fn, context) {
- return function() {
- return fn.apply(context || this, arguments);
- };
- };
- var TabBody = $.inherit({
- counter : null,
- prefsEcommerce : null,
- dataLayerName : "dataLayer",
- allowedEvents : ["add", "delete", "remove", "purchase", "detail"],
- /**
- * @return {undefined}
- */
- _initComponent : function() {
- /** @type {string} */
- var text = "customArr";
- TabBody.superclass._initComponent.apply(this, arguments);
- if (!this._overridePush(this.prefsEcommerce)) {
- if (self.isString(this.prefsEcommerce)) {
- this.dataLayerName = this.prefsEcommerce;
- }
- text = this.dataLayerName;
- this._tryTimeout = self.bind(this._tryTimeout, this);
- this._tryTimeout();
- }
- this.counter._ecommerce = text;
- },
- /**
- * @param {Object} options
- * @return {?}
- */
- _overridePush : function(options) {
- var self;
- var matcherFunction;
- return options && "function" == typeof options.push ? (self = this, self._send(options), matcherFunction = options.push, options.push = function() {
- self._send([].slice.call(arguments, 0));
- matcherFunction.apply(this, arguments);
- }, true) : false;
- },
- /**
- * @return {undefined}
- */
- _tryTimeout : function() {
- if (!this._overridePush(win[this.dataLayerName])) {
- self.setTimeout(this._tryTimeout, 1E3, "dlObserver");
- }
- },
- /**
- * @param {Array} options
- * @return {undefined}
- */
- _send : function(options) {
- /** @type {Array} */
- var configList = [];
- var a = this.allowedEvents;
- var i;
- var xhr;
- var flags;
- var h;
- var precision;
- /** @type {number} */
- i = 0;
- precision = options.length;
- for (;i < precision;i++) {
- if (xhr = options[i]) {
- if (xhr.ecommerce) {
- flags = {};
- /** @type {boolean} */
- h = false;
- self.forEachKey(xhr.ecommerce, function(key, value) {
- if (0 <= self.arrayIndexOf(a, key)) {
- /** @type {boolean} */
- h = true;
- flags[key] = value;
- }
- });
- if (h) {
- configList.push(flags);
- }
- }
- }
- }
- if (configList.length) {
- this.counter.params({
- __ym : {
- ecommerce : configList
- }
- });
- }
- }
- });
- var query = {
- /**
- * @return {undefined}
- */
- match : function() {
- if (this.enabled()) {
- Event.ready(function() {
- var iframe = self.getNativeFunction("createElement", doc)("iframe");
- /**
- * @return {undefined}
- */
- iframe.onload = function() {
- inst.save("cm", me.getMinutes());
- dom.removeNode(iframe);
- };
- iframe.setAttribute("style", "position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden;visibility:hidden");
- /** @type {string} */
- iframe.src = "https://mc.yandex.ru/metrika/watch_match.html";
- doc.documentElement.appendChild(iframe);
- });
- }
- },
- /**
- * @return {?}
- */
- enabled : function() {
- return 1440 < me.getMinutes() - inst.getNum("cm") && "tr" == self.getTld();
- }
- };
- /**
- * @param {string} string
- * @return {?}
- */
- self.safeDecodeURIComponent = function(string) {
- try {
- return decodeURIComponent(string);
- } catch (b) {
- return "";
- }
- };
- /**
- * @param {Object} s
- * @param {boolean} execResult
- * @return {?}
- */
- store.parse = function(s, execResult) {
- var obj = {};
- var codeSegments;
- var val;
- var name;
- var i;
- s = s && s.replace(/^\?/, "") || "";
- if (s.length) {
- codeSegments = s.split("&");
- /** @type {number} */
- i = 0;
- for (;i < codeSegments.length;i++) {
- if (codeSegments[i]) {
- val = codeSegments[i].split("=");
- if (val[0]) {
- name = self.safeDecodeURIComponent(val[0]);
- val = self.safeDecodeURIComponent((val[1] || "").replace(/\+/g, "%20"));
- if (execResult && name in obj) {
- if (self.isArray(obj[name])) {
- obj[name].push(val);
- } else {
- /** @type {Array} */
- obj[name] = [obj[name], val];
- }
- } else {
- obj[name] = val;
- }
- }
- }
- }
- }
- return obj;
- };
- /** @type {Array} */
- var codeSegments = [];
- var params = trigger();
- var udataCur = me.getTimezone();
- var now = me.getTimestamp();
- var screen = win.screen;
- /** @type {string} */
- var v = "787";
- /** @type {number} */
- var extra = 64;
- /** @type {number} */
- var length = data.isIE() ? 512 : 2048;
- /** @type {number} */
- var chars = data.isIE() ? 512 : 2048;
- /** @type {number} */
- var firstLength = data.isIE() ? 100 : 400;
- /** @type {number} */
- var raw = 100;
- /** @type {string} */
- var props = "noindex";
- /** @type {RegExp} */
- var rchecked = /\.(3gp|7z|aac|ac3|acs|ai|avi|ape|apk|asf|bmp|bz2|cab|cdr|crc32|css|csv|cue|divx|dmg|djvu?|doc(x|m|b)?|emf|eps|exe|flac?|flv|iso|swf|gif|t?gz|jpe?g?|js|m3u8?|m4a|mp(3|4|e?g?)|m4v|md5|mkv|mov|msi|ods|og(g|m|v)|psd|rar|rss|rtf|sea|sfv|sit|sha1|svg|tar|tif?f|torrent|ts|txt|vob|wave?|wma|wmv|wmf|webm|ppt(x|m|b)?|xls(x|m|b)?|pdf|phps|png|xpi|g?zip)$/i;
- /** @type {number} */
- var currentTime = +new Date;
- var aux;
- var max;
- var dontSendRequests;
- win.Ya = win.Ya || {};
- Ya._metrika = Ya._metrika || {};
- Ya._metrika.counters = Ya._metrika.counters || {};
- Ya._metrika.hitParam = Ya._metrika.hitParam || {};
- Ya._metrika.counterNum = Ya._metrika.counterNum || 0;
- Ya._metrika.hitId = Ya._metrika.hitId || self.random();
- Ya._globalMetrikaHitId = self.random();
- /** @type {string} */
- Ya._metrika.v = v;
- /** @type {boolean} */
- dontSendRequests = !!Ya._metrika.oo;
- /**
- * @param {Object} data
- * @param {(Function|string)} count
- * @param {number} ret
- * @param {(RegExp|string)} opt_length
- * @return {?}
- */
- win.Ya.Metrika = function(data, count, ret, opt_length) {
- var that = this;
- return bind(function() {
- /**
- * @param {boolean} recurring
- * @return {?}
- */
- function trigger(recurring) {
- /** @type {boolean} */
- var self = false;
- var tmp;
- var next;
- if (Ya._metrika.hitParam[counterIndex]) {
- if (1 != ret || Ya._metrika.counters[counterIndex]) {
- return false;
- }
- /** @type {boolean} */
- self = true;
- }
- Ya._metrika.counters[counterIndex] = that;
- /** @type {number} */
- Ya._metrika.hitParam[counterIndex] = 1;
- that._webvisor = !opt_length && (!dontSendRequests && (options && options.webvisor || false));
- that._directCampaign = options && options.directCampaign;
- if (options) {
- if (options.trackHash) {
- show(true);
- }
- }
- if (!opt_length) {
- if (!self) {
- tmp = new Class({
- protocol : "https:",
- counterId : data,
- counterType : ret,
- hid : hid,
- tz : udataCur,
- ts : now,
- url : params.href,
- enabled : that._webvisor
- });
- that.replacePhones();
- self = new Async({
- dontSendRequests : dontSendRequests
- });
- /**
- * @param {?} done
- * @return {undefined}
- */
- next = function(done) {
- var model = new Comment({
- protocol : "https:",
- counterType : ret,
- counterId : data,
- trackHash : e,
- hitId : hid,
- webvisor : that._webvisor,
- counter : that,
- dontSendRequests : dontSendRequests,
- counterNum : counterNum
- });
- var modes = {
- ut : module,
- he : options ? ~~options.httpError : 0,
- ad : 1 == ret && (win.Ya && win.Ya.Direct),
- pv : true,
- saveRef : true
- };
- /** @type {number} */
- aux = +new Date;
- model.sendHit({
- url : params.href,
- title : dom.getDocumentTitle(),
- referrer : doc.referrer,
- vParams : count,
- userParams : dataText,
- experiments : image,
- modes : modes,
- visitColor : tmp.getVc(),
- hasPrerender : recurring,
- ts : now,
- tz : udataCur,
- /**
- * @param {Object} opt_attributes
- * @param {string} update
- * @return {undefined}
- */
- callback : function(opt_attributes, update) {
- inst.init(update);
- query.match();
- model.sync();
- console.log("PageView. Counter ", data, ". URL: ", params.href, ". Referrer: " + doc.referrer, ". Params: ", count);
- if (!max) {
- /** @type {number} */
- max = +new Date;
- }
- opt_attributes = opt_attributes || {};
- tmp.start(opt_attributes.webvisor);
- var options = opt_attributes.mp2;
- var v;
- var controller;
- controller = new Controller({
- counterId : data
- });
- controller.erase("mp2_substs");
- if (options) {
- b: {
- v = options.conditions;
- var j;
- if (v && v.length) {
- /** @type {number} */
- j = 0;
- for (;j < v.length;j++) {
- var a;
- a = v[j];
- if ("ref" == a.type) {
- a = load(a);
- } else {
- if ("adv" == a.type) {
- var i;
- var f;
- var c;
- var b;
- var n;
- i = a;
- b = Ya._metrika.counter._directCampaign;
- f = i.ServiceNamePattern;
- var config = i.RefererPattern;
- a = b ? i.direct_orders : i.direct_camp;
- /** @type {string} */
- var q = doc.referrer;
- var iterable = store.parse(params.search);
- var t = write(params.search, params.hash);
- var object = {};
- /** @type {Array} */
- c = ["source", "medium", "campaign", "term", "content"];
- /** @type {number} */
- n = 0;
- for (;n < c.length;n++) {
- if (iterable["utm_" + c[n]]) {
- object[c[n]] = iterable["utm_" + c[n]];
- }
- }
- var nType = b ? "direct.yandex.ru" : t && t.service || object.source;
- /** @type {boolean} */
- n = false;
- if (!n && (f && f.length)) {
- /** @type {number} */
- c = 0;
- for (;c < f.length;c++) {
- if ((new RegExp(f[c], "i")).test(nType)) {
- /** @type {boolean} */
- n = true;
- break;
- }
- }
- }
- if (!n && (!i.yandex_direct && (config && config.length))) {
- /** @type {number} */
- f = 0;
- for (;f < config.length;f++) {
- if ((new RegExp(config[f], "i")).test(q)) {
- /** @type {boolean} */
- n = true;
- break;
- }
- }
- }
- if (!n) {
- if (i.google_adwords) {
- if (iterable.gclid) {
- /** @type {boolean} */
- n = true;
- }
- }
- }
- if (n && (a && (a.length && (n = false, b = b || (t && t.campaign || object && object.campaign))))) {
- /** @type {number} */
- i = 0;
- for (;i < a.length;i++) {
- if (a[i] == b) {
- /** @type {boolean} */
- n = true;
- break;
- }
- }
- }
- /** @type {boolean} */
- a = n;
- } else {
- /** @type {boolean} */
- a = false;
- }
- }
- if (a) {
- if (v[j].track_id) {
- controller.create("mp2_track", v[j].track_id, 43200);
- }
- break b;
- }
- }
- }
- }
- v = controller.read("mp2_track");
- options = options.substs && options.substs[v];
- if (v && options) {
- controller.create("mp2_substs", self.toJSON(options));
- controller = add(options);
- that.params("__ym", controller ? "mp_trackid" : "mp_trackid_bad", v);
- } else {
- _next();
- }
- } else {
- _next();
- }
- Event.on(win, "load", that.replacePhones, that);
- /** @type {boolean} */
- that._inited = true;
- if (done) {
- done();
- }
- }
- });
- };
- self.sync(next);
- }
- }
- confirm();
- if (options) {
- if (options.enableAll) {
- setup(true);
- fn(true);
- create();
- } else {
- if (options.clickmap) {
- fn(options.clickmap);
- }
- if (options.trackLinks) {
- setup(options.trackLinks);
- }
- if (options.accurateTrackBounce) {
- create(options.accurateTrackBounce);
- }
- }
- if (options.ecommerce || options.useDataLayer) {
- new TabBody({
- counter : that,
- prefsEcommerce : options.ecommerce
- });
- }
- if (options.triggerEvent) {
- defer(function() {
- that.dispatchCustomEvent("yacounter" + data + "inited");
- }, 0);
- }
- }
- }
- /**
- * @param {boolean} val
- * @return {undefined}
- */
- function setup(val) {
- var attr = {};
- switch(typeof val) {
- case "string":
- /** @type {boolean} */
- attr.on = true;
- break;
- case "object":
- /** @type {boolean} */
- attr.on = true;
- break;
- case "boolean":
- /** @type {boolean} */
- attr.on = val;
- break;
- default:
- return;
- }
- that._trackLinks = attr;
- }
- /**
- * @return {undefined}
- */
- function confirm() {
- setup(false);
- Event.on(doc, "click", function(e) {
- if (that._trackLinks) {
- if (that._trackLinks.on) {
- next(e);
- }
- }
- });
- }
- /**
- * @param {?} i
- * @return {undefined}
- */
- function next(i) {
- var a = handle(i);
- var value;
- var c;
- var handler;
- var res;
- if (a) {
- /** @type {boolean} */
- i = false;
- /** @type {string} */
- c = (value = "" + a.href) ? value.split(/\?/)[0] : "";
- /**
- * @param {(Object|string)} d
- * @return {undefined}
- */
- handler = function(d) {
- var className = get(a);
- $.sendClickLink({
- url : value,
- title : value == className ? "" : className,
- modes : d
- });
- };
- if (rchecked.test(c) || (rchecked.test(value) || (walk(value, key) || walk(c, key)))) {
- /** @type {boolean} */
- i = true;
- }
- res = dom.classNameExists(a, "ym-disable-tracklink");
- c = dom.classNameExists(a, "ym-external-link");
- if (!res) {
- res = {
- ln : true,
- dl : i
- };
- if (c) {
- handler(res);
- } else {
- c = a.hostname || (self.parseUrl(a.href).hostname || "");
- if (_init(trigger().hostname, c)) {
- if (i) {
- /** @type {boolean} */
- res.ln = false;
- handler(res);
- } else {
- if (i = get(a)) {
- if (i != value) {
- n.set("il", self.trim(i, raw));
- }
- }
- }
- } else {
- if (!(value && -1 != value.search(/^ *(data|javascript):/i))) {
- /** @type {string} */
- res.ut = props;
- handler(res);
- }
- }
- }
- }
- }
- }
- /**
- * @param {boolean} deepDataAndEvents
- * @return {undefined}
- */
- function fn(deepDataAndEvents) {
- if ("undefined" == typeof deepDataAndEvents) {
- /** @type {boolean} */
- deepDataAndEvents = true;
- }
- if (true === deepDataAndEvents) {
- deepDataAndEvents = {};
- }
- if (that._clickmap) {
- that._clickmap.destroy();
- }
- if (deepDataAndEvents) {
- that._clickmap = new Server({
- dontSendRequests : dontSendRequests,
- filter : deepDataAndEvents.filter,
- ignoreTags : deepDataAndEvents.ignoreTags,
- quota : deepDataAndEvents.quota,
- isTrackHash : deepDataAndEvents.isTrackHash,
- protocol : "https:",
- counterId : data,
- counterType : ret,
- startTime : currentTime
- });
- }
- }
- /**
- * @param {Function} callback
- * @param {number} time
- * @return {undefined}
- */
- function init(callback, time) {
- /**
- * @return {undefined}
- */
- function check() {
- var ms;
- if (!t) {
- if (timeoutKey) {
- self.clearTimeout(timeoutKey);
- }
- ms = list ? i : i + +new Date - off;
- /** @type {number} */
- ms = time - ms;
- if (0 > ms) {
- /** @type {number} */
- ms = 0;
- }
- timeoutKey = self.setTimeout(function() {
- /** @type {boolean} */
- t = true;
- cb(false);
- callback();
- }, ms, "trackUserTime");
- }
- }
- /**
- * @return {undefined}
- */
- function end() {
- if (!memory) {
- /** @type {boolean} */
- stack = true;
- /** @type {boolean} */
- list = false;
- /** @type {boolean} */
- memory = true;
- check();
- }
- }
- /**
- * @param {boolean} recurring
- * @return {undefined}
- */
- function cb(recurring) {
- var i;
- /** @type {number} */
- i = 0;
- for (;i < items.length;i += 3) {
- if (recurring) {
- Event.on(items[i], items[i + 1], items[i + 2]);
- } else {
- Event.un(items[i], items[i + 1], items[i + 2]);
- }
- }
- }
- /** @type {boolean} */
- var stack = false;
- /** @type {boolean} */
- var memory = false;
- /** @type {boolean} */
- var list = true;
- /** @type {number} */
- var i = 0;
- /** @type {number} */
- var off = +new Date;
- /** @type {null} */
- var timeoutKey = null;
- /** @type {boolean} */
- var t = false;
- var items;
- if (data.isIE()) {
- self.setTimeout(callback, time, "trackUserTime");
- } else {
- /** @type {Array} */
- items = [win, "blur", function() {
- /** @type {boolean} */
- list = stack = memory = true;
- i += +new Date - off;
- /** @type {number} */
- off = +new Date;
- check();
- }, win, "focus", function() {
- if (!stack) {
- if (!memory) {
- /** @type {number} */
- i = 0;
- }
- }
- /** @type {number} */
- off = +new Date;
- /** @type {boolean} */
- stack = memory = true;
- /** @type {boolean} */
- list = false;
- check();
- }, doc, "click", end, doc, "mousemove", end, doc, "keydown", end, doc, "scroll", end];
- cb(true);
- check();
- }
- }
- /**
- * @param {number} id
- * @return {undefined}
- */
- function create(id) {
- var end;
- var daysToDayOfWeek;
- if ("number" != typeof id) {
- /** @type {number} */
- id = 15E3;
- }
- if (!that._isAccurateTrackBounce) {
- /** @type {boolean} */
- that._isAccurateTrackBounce = true;
- end = new Node({
- counterId : data
- });
- daysToDayOfWeek = end.get("lastHit");
- end.set("lastHit", +new Date);
- if ((end = end.get("lastHit")) && (!daysToDayOfWeek || daysToDayOfWeek < end - 18E5) || (!extend(doc.referrer, trigger().href) || 0.1 > Math.random())) {
- init(function() {
- that.notBounce();
- }, id);
- }
- }
- }
- /**
- * @param {?} next
- * @return {undefined}
- */
- function after(next) {
- /**
- * @return {?}
- */
- var go = function() {
- var key = trigger().hash.split("#")[1];
- var lastNestingSeparator;
- if ("undefined" == typeof key) {
- return false;
- }
- lastNestingSeparator = key.indexOf("?");
- if (0 < lastNestingSeparator) {
- key = key.substring(0, lastNestingSeparator);
- }
- return key;
- };
- var skip;
- skip = go();
- (function after() {
- var val = go();
- if (val !== skip) {
- next();
- skip = val;
- }
- timeoutKey = self.setTimeout(after, 200, "trackHash");
- })();
- }
- /**
- * @param {?} callback
- * @return {undefined}
- */
- function show(callback) {
- if (false === callback) {
- if (e) {
- if ("onhashchange" in win) {
- Event.un(win, "hashchange", handleClick);
- } else {
- self.clearTimeout(timeoutKey);
- }
- /** @type {boolean} */
- e = false;
- }
- } else {
- if (callback = handleClick, !e) {
- if ("onhashchange" in win) {
- Event.on(win, "hashchange", callback);
- } else {
- after(callback);
- }
- /** @type {boolean} */
- e = true;
- }
- }
- $.setTrackHash(e);
- /** @type {boolean} */
- that._trackHash = e;
- }
- /**
- * @return {undefined}
- */
- function handleClick() {
- var modes = {
- ut : module,
- ad : 1 == ret && (win.Ya && win.Ya.Direct),
- wh : true,
- saveRef : true,
- pv : true
- };
- optsData = img.lastReferrer = h;
- $.sendAjaxHit({
- url : trigger().href,
- title : dom.getDocumentTitle(),
- referrer : optsData,
- modes : modes
- });
- h = trigger().href;
- }
- /**
- * @param {string} key
- * @param {Array} k
- * @param {Object} obj
- * @return {undefined}
- */
- function loop(key, k, obj) {
- key = jQuery.parseValidate(key, k);
- /** @type {Array} */
- k = [];
- if (key) {
- k.push(key);
- obj = obj || {};
- if (self.isFunction(obj.callback)) {
- k.push(obj.callback);
- if (obj.ctx) {
- k.push(obj.ctx);
- }
- }
- }
- if (k.length) {
- that.params.apply(that, k);
- }
- }
- var counterIndex;
- /** @type {string} */
- var module = "";
- var image;
- var dataText;
- var options;
- /** @type {string} */
- var optsData = "";
- var h = img.lastReferrer = params.href;
- var counterNum;
- var $;
- var key;
- var controller;
- var n;
- var e;
- var callback;
- var herecomment;
- var hid;
- if (!Ya._metrika.counter) {
- Ya._metrika.counter = that;
- }
- if ("object" == typeof data) {
- /** @type {Object} */
- options = data;
- opt_length = data.defer;
- module = data.ut;
- ret = data.type;
- count = data.params;
- dataText = data.userParams;
- image = options.experiments;
- herecomment = options.nck;
- data = data.id;
- }
- data = data || 0;
- if (!/^\d+$/.test(data)) {
- /** @type {number} */
- data = 0;
- }
- ret = ret || 0;
- /** @type {string} */
- counterIndex = data + ":" + ret;
- if (Ya._metrika.counters[counterIndex]) {
- return Ya._metrika.counters[counterIndex];
- }
- hid = Ya._metrika.hitId;
- Ya._metrika.counterNum++;
- counterNum = Ya._metrika.counterNum;
- if (!herecomment) {
- instance.initCookie();
- methods.init();
- }
- instance.retransmit();
- $ = new klass({
- protocol : "https:",
- counterType : ret,
- counterId : data,
- hitId : hid,
- counter : that,
- dontSendRequests : dontSendRequests,
- counterNum : counterNum
- });
- that.replacePhones = bind(function() {
- var jsonString;
- var prefix;
- try {
- if (jsonString = (new Controller({
- counterId : data
- })).read("mp2_substs")) {
- if (prefix = JSON.parse(jsonString)) {
- add(prefix, true);
- }
- }
- } catch (B) {
- }
- return that;
- }, "counter.replacePhones");
- that.reachGoal = bind(function(urls, c, callback, contextOverride) {
- if (2 <= arguments.length) {
- if ("function" === typeof c) {
- /** @type {(Function|string)} */
- contextOverride = callback;
- /** @type {(Function|string)} */
- callback = c;
- /** @type {(Function|string)} */
- c = value;
- }
- }
- console.log("Reach goal. Counter: " + data + ". Goal id: " + urls + ". Params: ", c);
- $.sendGoal(urls, {
- vParams : c,
- callback : callback,
- /** @type {Function} */
- ctx : contextOverride
- });
- return that;
- }, "counter.reachGoal");
- that.trackLinks = bind(function(next) {
- setup(next);
- return that;
- }, "counter.trackLinks");
- n = new Node({
- counterId : data
- });
- that.hit = bind(function(file, opts, text, config, callback, txn) {
- if (file) {
- if (self.isObject(opts)) {
- text = opts.referer;
- config = opts.params;
- callback = opts.callback;
- txn = opts.ctx;
- opts = opts.title;
- }
- console.log("PageView. Counter " + data, ". URL: " + file, ". Referrer: " + text, ". Params: ", config);
- $.sendHit({
- url : file,
- title : opts,
- referrer : text,
- /** @type {Function} */
- vParams : config,
- callback : callback,
- ctx : txn
- });
- }
- return that;
- }, "counter.hit");
- that.params = bind(function(dataAndEvents) {
- /** @type {number} */
- var len = arguments.length;
- /** @type {number} */
- var i = len;
- var which;
- var key;
- /** @type {Array.<?>} */
- var arg = [].slice.call(arguments, 0);
- if (dataAndEvents) {
- if (1 < arguments.length) {
- if (self.isFunction(arguments[len - 1])) {
- which = arguments[len - 1];
- /** @type {number} */
- i = len - 1;
- } else {
- if (self.isFunction(arguments[len - 2])) {
- which = arguments[len - 2];
- key = arguments[len - 1];
- /** @type {number} */
- i = len - 2;
- }
- }
- /** @type {Array.<?>} */
- arg = [].slice.call(arg, 0, i);
- if (1 < arg.length) {
- /** @type {Array} */
- arg = [self.array2Props(arg)];
- }
- }
- console.log("User params. Counter " + data + ". Params: ", arg[0]);
- $.sendParams(arg[0], which, key);
- }
- return that;
- }, "counter.params");
- that.file = bind(function(requestUrl, options) {
- if (requestUrl) {
- options = options || {};
- $.sendFileUpload({
- url : requestUrl,
- title : options.title,
- vParams : options.params,
- callback : options.callback,
- ctx : options.ctx
- });
- }
- return that;
- }, "counter.file");
- that.extLink = bind(function(requestUrl, options) {
- if (requestUrl) {
- options = options || {};
- $.sendExtLink({
- url : requestUrl,
- title : options.title,
- vParams : options.params,
- callback : options.callback,
- ctx : options.ctx
- });
- }
- return that;
- }, "counter.extLink");
- that.notBounce = bind(function(options) {
- /** @type {number} */
- var diff = 0;
- options = options || {};
- if (aux) {
- if (max) {
- /** @type {number} */
- diff = max - aux;
- }
- }
- $.sendNotBounce(diff, {
- callback : options.callback,
- ctx : options.ctx
- });
- return that;
- }, "counter.notBounce");
- /** @type {Array} */
- key = [];
- /**
- * @param {?} path
- * @return {?}
- */
- that.addFileExtension = function(path) {
- if ("string" == typeof path) {
- key.push(path);
- } else {
- key = key.concat(path);
- }
- return that;
- };
- /**
- * @param {boolean} deepDataAndEvents
- * @return {?}
- */
- that.clickmap = function(deepDataAndEvents) {
- fn(deepDataAndEvents);
- return that;
- };
- /**
- * @param {number} moduleId
- * @return {?}
- */
- that.accurateTrackBounce = function(moduleId) {
- create(moduleId);
- return that;
- };
- /** @type {null} */
- var timeoutKey = null;
- /** @type {boolean} */
- e = false;
- /**
- * @param {?} next_callback
- * @return {?}
- */
- that.trackHash = function(next_callback) {
- show(next_callback);
- return that;
- };
- /**
- * @param {Array} arr
- * @param {Function} fn
- * @param {?} thisv
- * @return {?}
- */
- self.arrayEvery = function(arr, fn, thisv) {
- var i;
- /** @type {number} */
- i = 0;
- for (;i < arr.length;i++) {
- if (!fn.call(thisv, arr[i], i, arr)) {
- return false;
- }
- }
- return true;
- };
- var jQuery = {
- requiredEcommerceFields : ["currency", "goods"],
- /**
- * @param {string} event
- * @param {Object} data
- * @return {?}
- */
- parseValidate : function(event, data) {
- var obj = this.validate(event, data);
- var key;
- if (!obj.isValid) {
- return console && console.log(obj.message), false;
- }
- obj = {};
- obj[event] = {};
- if (data.currency) {
- obj.currencyCode = data.currency;
- }
- if (data.goods) {
- obj[event].products = data.goods;
- }
- for (key in data) {
- if (data.hasOwnProperty(key)) {
- if (-1 === self.arrayIndexOf(this.requiredEcommerceFields, key)) {
- if (!obj[event].actionField) {
- obj[event].actionField = {};
- }
- obj[event].actionField[key] = data[key];
- }
- }
- }
- return{
- __ym : {
- ecommerce : [obj]
- }
- };
- },
- /**
- * @param {string} type
- * @param {Object} collection
- * @return {?}
- */
- validate : function(type, collection) {
- /** @type {boolean} */
- var isValid = false;
- /** @type {string} */
- var output = "";
- if (self.isObject(collection)) {
- switch(type) {
- case "detail":
- ;
- case "add":
- ;
- case "remove":
- if (self.isArray(collection.goods) && collection.goods.length) {
- if (!(isValid = self.arrayEvery(collection.goods, function(result) {
- return self.isObject(result) && (self.isString(result.id) || (self.isNumber(result.id) || (self.isString(result.name) || self.isString(result.name))));
- }))) {
- /** @type {string} */
- output = "All items in 'goods' should be objects and contain 'id' or 'name' field";
- }
- } else {
- /** @type {string} */
- output = "Ecommerce data should contain 'goods' non-empty array";
- }
- break;
- case "purchase":
- if (self.isNumber(collection.id) || self.isString(collection.id)) {
- /** @type {boolean} */
- isValid = true;
- } else {
- /** @type {string} */
- output = "Purchase object should contain string or number 'id' field";
- }
- ;
- }
- } else {
- /** @type {string} */
- output = "Ecommerce data should be an object";
- }
- return{
- isValid : isValid,
- message : output
- };
- }
- };
- that.ecommerceDetail = bind(function(k, walkers) {
- loop("detail", k, walkers);
- return that;
- }, "ecommerce.detail");
- that.ecommerceAdd = bind(function(k, walkers) {
- loop("add", k, walkers);
- return that;
- }, "ecommerce.add");
- that.ecommerceRemove = bind(function(k, walkers) {
- loop("remove", k, walkers);
- return that;
- }, "ecommerce.remove");
- that.ecommercePurchase = bind(function(k, walkers) {
- loop("purchase", k, walkers);
- return that;
- }, "ecommerce.purchase");
- that.userParams = bind(function(group, remote, rtt) {
- if (self.isObject(group)) {
- that.params({
- __ymu : group
- }, remote || function() {
- }, rtt);
- }
- return that;
- }, "uparams");
- that.experiments = bind(function(dataAndEvents, callback, contextOverride) {
- $.sendExperiments({
- /** @type {Function} */
- callback : callback,
- ctx : contextOverride,
- experiments : dataAndEvents
- });
- return that;
- }, "exps");
- that.id = that.setUserID = bind(function(i, remote, rtt) {
- if (self.isString(i) || self.isNumber(i)) {
- that.params({
- __ym : {
- user_id : i
- }
- }, remote || function() {
- }, rtt);
- }
- return that;
- }, "id");
- controller = new Controller;
- that.getClientID = bind(function() {
- return controller.read("uid");
- }, "guid");
- /**
- * @return {?}
- */
- that.enableAll = function() {
- setup(true);
- fn(true);
- create();
- return that;
- };
- /**
- * @return {undefined}
- */
- that.uploadPage = function() {
- };
- /** @type {function (): ?} */
- that._performanceTiming = parents;
- if (data) {
- if ("prerender" == doc.webkitVisibilityState) {
- $.sendPrerenderHit({
- url : params.href,
- title : dom.getDocumentTitle(),
- referrer : doc.referrer
- });
- /**
- * @return {undefined}
- */
- callback = function() {
- if ("prerender" != doc.webkitVisibilityState) {
- Event.un(doc, "webkitvisibilitychange", callback);
- trigger(true);
- }
- };
- Event.on(doc, "webkitvisibilitychange", callback);
- } else {
- trigger(false);
- }
- }
- }, "init")();
- };
- (function() {
- if (win.performance && "function" === typeof performance.getEntries) {
- var c = {
- 2343947156 : 1,
- 1996539654 : 1,
- 2065498185 : 1,
- 823651274 : 1,
- 12282461 : 1,
- 1555719328 : 1,
- 1417229093 : 1,
- 138396985 : 1
- };
- var codeSegments = performance.getEntries();
- var old = {};
- var t;
- var name;
- var eventName;
- var i;
- /** @type {number} */
- i = 0;
- for (;i < codeSegments.length;i++) {
- t = codeSegments[i];
- name = t.name.replace(/^https?:\/\//, "").split("?")[0];
- eventName = self.fnv32a(name);
- if (c[eventName]) {
- if (!old[name]) {
- if (0 < t.duration) {
- old[name] = {
- dns : Math.round(t.domainLookupEnd - t.domainLookupStart),
- tcp : Math.round(t.connectEnd - t.connectStart),
- duration : Math.round(t.duration),
- response : Math.round(t.responseEnd - t.requestStart),
- pages : params.href
- };
- }
- }
- }
- }
- (new Game({
- sampling : 0.001
- })).logParams({
- timings8 : old
- });
- }
- })();
- if (!win.Ya._metrika.remoteCtrlInited) {
- /** @type {boolean} */
- win.Ya._metrika.remoteCtrlInited = true;
- new sbp;
- }
- /**
- * @return {?}
- */
- win.Ya.Metrika.counters = function() {
- /** @type {Array} */
- var results = [];
- self.forEachKey(win.Ya._metrika.counters, function(pair, e) {
- var d = pair.split(":");
- results.push({
- id : +d[0],
- type : +d[1],
- accurateTrackBounce : e._isAccurateTrackBounce,
- clickmap : e._clickmap && e._clickmap._start,
- oldCode : !!win.ya_cid,
- trackHash : !!e._trackHash,
- trackLinks : e._trackLinks && e._trackLinks.on,
- webvisor : !!e._webvisor
- });
- });
- return results;
- };
- if (win.ya_cid) {
- if (Ya.Metrika) {
- new Ya.Metrika(win.ya_cid, win.ya_params, win.ya_class);
- }
- }
- if (win.ya_cid) {
- if (!win.ya_hit) {
- /**
- * @param {?} deepDataAndEvents
- * @param {?} opt_obj2
- * @return {undefined}
- */
- win.ya_hit = function(deepDataAndEvents, opt_obj2) {
- if (Ya._metrika.counter) {
- Ya._metrika.counter.reachGoal(deepDataAndEvents, opt_obj2);
- }
- };
- }
- }
- (function() {
- /**
- * @param {string} key
- * @return {undefined}
- */
- function promote(key) {
- try {
- delete win[key];
- } catch (m) {
- /** @type {(Function|string)} */
- win[key] = value;
- }
- }
- var i = win.yandex_metrika_callback;
- var codeSegments = win.yandex_metrika_callbacks;
- var part;
- if ("function" == typeof i) {
- i();
- }
- if ("object" == typeof codeSegments) {
- /** @type {number} */
- i = 0;
- for (;i < codeSegments.length;i++) {
- if (part = codeSegments[i]) {
- /** @type {null} */
- codeSegments[i] = null;
- part();
- }
- }
- }
- promote("yandex_metrika_callback");
- promote("yandex_metrika_callbacks");
- })();
- /**
- * @param {?} opt_attributes
- * @return {undefined}
- */
- win.Ya.Metrika.informer = function(opt_attributes) {
- /** @type {boolean} */
- var b = !!Ya.Metrika._informer;
- Ya.Metrika._informer = opt_attributes;
- if (!b) {
- dom.loadScript({
- src : "https://informer.yandex.ru/metrika/informer.js"
- });
- }
- };
- Event.on(doc, "click", bind(function(event) {
- var el = that.getTarget(event);
- var _langCode;
- var id;
- if (el) {
- if ("ym-advanced-informer" == el.className) {
- _langCode = el.getAttribute("data-lang");
- id = el.getAttribute("data-cid");
- Ya.Metrika.informer({
- i : el,
- id : +id,
- lang : _langCode
- });
- that.prevent(event);
- }
- }
- }, "adv-inf"), null, {
- passive : false
- });
- })(this, this.document);
Add Comment
Please, Sign In to add comment