Guest User

Untitled

a guest
Mar 22nd, 2017
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 201.48 KB | None | 0 0
  1. (function(win, doc, value) {
  2. /**
  3. * @param {string} allBindingsAccessor
  4. * @param {string} depMaps
  5. * @param {?} rootjQuery
  6. * @param {?} deepDataAndEvents
  7. * @return {?}
  8. */
  9. function init(allBindingsAccessor, depMaps, rootjQuery, deepDataAndEvents) {
  10. /**
  11. * @param {number} val1
  12. * @return {undefined}
  13. */
  14. function tick(val1) {
  15. /** @type {number} */
  16. var val2 = (new Date).getTime();
  17. if (val1) {
  18. if (val2 < val1) {
  19. ROOM_SIZE += val1 - val2 + 20;
  20. }
  21. }
  22. self.setTimeout(function() {
  23. tick(val2);
  24. }, 20, "timeCorrector");
  25. }
  26. /**
  27. * @return {?}
  28. */
  29. function remove() {
  30. var maxY = (new Date).getTime() + ROOM_SIZE;
  31. if (maxY < y) {
  32. maxY = y + 10;
  33. }
  34. return y = maxY;
  35. }
  36. /**
  37. * @return {?}
  38. */
  39. function get() {
  40. return Math.round((remove() - newMethods) / 50);
  41. }
  42. /**
  43. * @param {Array} err
  44. * @param {number} val
  45. * @return {undefined}
  46. */
  47. function cb(err, val) {
  48. /** @type {number} */
  49. val = Math.max(0, Math.min(val, 65535));
  50. self.mergeArrays(err, [val >> 8, val & 255]);
  51. }
  52. /**
  53. * @param {Array} arg
  54. * @param {number} opt_attributes
  55. * @return {undefined}
  56. */
  57. function fail(arg, opt_attributes) {
  58. self.mergeArrays(arg, [opt_attributes & 255]);
  59. }
  60. /**
  61. * @param {Array} arg
  62. * @param {number} value
  63. * @return {undefined}
  64. */
  65. function debug(arg, value) {
  66. /** @type {number} */
  67. value = Math.max(0, value | 0);
  68. for (;127 < value;) {
  69. self.mergeArrays(arg, [value & 127 | 128]);
  70. value >>= 7;
  71. }
  72. self.mergeArrays(arg, [value]);
  73. }
  74. /**
  75. * @param {Array} err
  76. * @param {string} key
  77. * @return {undefined}
  78. */
  79. function next(err, key) {
  80. if (255 < key.length) {
  81. key = key.substr(0, 255);
  82. }
  83. self.mergeArrays(err, [key.length]);
  84. /** @type {number} */
  85. var characterPosition = 0;
  86. for (;characterPosition < key.length;characterPosition++) {
  87. cb(err, key.charCodeAt(characterPosition));
  88. }
  89. }
  90. /**
  91. * @param {Array} e
  92. * @param {string} d
  93. * @return {undefined}
  94. */
  95. function complete(e, d) {
  96. debug(e, d.length);
  97. /** @type {number} */
  98. var i = 0;
  99. for (;i < d.length;i++) {
  100. debug(e, d.charCodeAt(i));
  101. }
  102. }
  103. /**
  104. * @param {number} id
  105. * @param {string} filename
  106. * @param {Array} result
  107. * @param {Array} loadingLang
  108. * @param {boolean} key
  109. * @param {boolean} callback
  110. * @return {?}
  111. */
  112. function load(id, filename, result, loadingLang, key, callback) {
  113. var header;
  114. for (;result && ((header = dom.getElementSize(result)) && (!header[0] || !header[1]));) {
  115. result = dom.getElementParent(result);
  116. }
  117. if (!result) {
  118. return null;
  119. }
  120. header = result[name];
  121. if (!header || 0 > header) {
  122. return null;
  123. }
  124. var attributes = {
  125. mousemove : 2,
  126. click : 32,
  127. dblclick : 33,
  128. mousedown : 4,
  129. mouseup : 30,
  130. touch : 12
  131. }[filename];
  132. if (!attributes) {
  133. return null;
  134. }
  135. var dependentResult = dom.getElementXY(result);
  136. /** @type {Array} */
  137. result = [];
  138. fail(result, attributes);
  139. debug(result, id);
  140. debug(result, header);
  141. debug(result, Math.max(0, loadingLang[0] - dependentResult[0]));
  142. debug(result, Math.max(0, loadingLang[1] - dependentResult[1]));
  143. if (/^mouse(up|down)|click$/.test(filename)) {
  144. id = key || callback;
  145. fail(result, 2 > id ? 1 : id == (key ? 2 : 4) ? 4 : 2);
  146. }
  147. return result;
  148. }
  149. /**
  150. * @param {number} id
  151. * @param {number} json
  152. * @param {Array} chunk
  153. * @param {number} opt_attributes
  154. * @return {?}
  155. */
  156. function parser(id, json, chunk, opt_attributes) {
  157. json = json[name];
  158. if (!json || 0 > json) {
  159. return null;
  160. }
  161. /** @type {Array} */
  162. var ex = [];
  163. fail(ex, 31);
  164. debug(ex, id);
  165. debug(ex, json);
  166. debug(ex, chunk[0]);
  167. debug(ex, chunk[1]);
  168. fail(ex, 0);
  169. fail(ex, 0);
  170. fail(ex, opt_attributes);
  171. return ex;
  172. }
  173. /**
  174. * @param {number} id
  175. * @param {Array} item
  176. * @return {?}
  177. */
  178. function text(id, item) {
  179. /** @type {Array} */
  180. var ex = [];
  181. fail(ex, 3);
  182. debug(ex, id);
  183. debug(ex, item[0]);
  184. debug(ex, item[1]);
  185. return ex;
  186. }
  187. /**
  188. * @param {number} val
  189. * @param {Array} captures
  190. * @param {number} template
  191. * @return {?}
  192. */
  193. function include(val, captures, template) {
  194. /** @type {Array} */
  195. var ex = [];
  196. template = template[name];
  197. if (!template || 0 > template) {
  198. return null;
  199. }
  200. fail(ex, 16);
  201. debug(ex, val);
  202. debug(ex, captures[0]);
  203. debug(ex, captures[1]);
  204. debug(ex, template);
  205. return ex;
  206. }
  207. /**
  208. * @param {number} d
  209. * @param {Array} data
  210. * @param {Array} start1
  211. * @return {?}
  212. */
  213. function change(d, data, start1) {
  214. /** @type {Array} */
  215. var ex = [];
  216. fail(ex, 28);
  217. debug(ex, d);
  218. debug(ex, data[0]);
  219. debug(ex, data[1]);
  220. debug(ex, start1[0]);
  221. debug(ex, start1[1]);
  222. return ex;
  223. }
  224. /**
  225. * @param {number} val
  226. * @param {number} res
  227. * @param {number} attributes
  228. * @param {Object} map
  229. * @return {?}
  230. */
  231. function save(val, res, attributes, map) {
  232. /** @type {Array} */
  233. var ex = [];
  234. fail(ex, 5);
  235. debug(ex, val);
  236. cb(ex, res);
  237. fail(ex, attributes);
  238. val = map[name];
  239. if (!val || 0 > val) {
  240. /** @type {number} */
  241. val = 0;
  242. }
  243. debug(ex, val);
  244. return ex;
  245. }
  246. /**
  247. * @param {number} d
  248. * @param {string} values
  249. * @return {?}
  250. */
  251. function success(d, values) {
  252. var resp;
  253. var val;
  254. if (0 == values.length) {
  255. /** @type {string} */
  256. val = resp = "";
  257. } else {
  258. if (100 >= values.length) {
  259. /** @type {string} */
  260. resp = values;
  261. /** @type {string} */
  262. val = "";
  263. } else {
  264. if (200 >= values.length) {
  265. resp = values.substr(0, 100);
  266. val = values.substr(100);
  267. } else {
  268. resp = values.substr(0, 97);
  269. val = values.substr(values.length - 97);
  270. }
  271. }
  272. }
  273. /** @type {Array} */
  274. var e = [];
  275. fail(e, 29);
  276. debug(e, d);
  277. complete(e, resp);
  278. complete(e, val);
  279. return e;
  280. }
  281. /**
  282. * @param {number} object
  283. * @return {?}
  284. */
  285. function clone(object) {
  286. /** @type {Array} */
  287. var e = [];
  288. fail(e, 27);
  289. debug(e, object);
  290. return e;
  291. }
  292. /**
  293. * @param {number} er
  294. * @return {?}
  295. */
  296. function onerror(er) {
  297. /** @type {Array} */
  298. var ex = [];
  299. fail(ex, 14);
  300. debug(ex, er);
  301. return ex;
  302. }
  303. /**
  304. * @param {number} desc
  305. * @return {?}
  306. */
  307. function ok(desc) {
  308. /** @type {Array} */
  309. var ex = [];
  310. fail(ex, 15);
  311. debug(ex, desc);
  312. return ex;
  313. }
  314. /**
  315. * @param {number} ms
  316. * @param {Object} data
  317. * @return {?}
  318. */
  319. function timeout(ms, data) {
  320. /** @type {Array} */
  321. var ex = [];
  322. fail(ex, 17);
  323. debug(ex, ms);
  324. debug(ex, data[name]);
  325. return ex;
  326. }
  327. /**
  328. * @param {number} path
  329. * @param {Object} data
  330. * @return {?}
  331. */
  332. function destroy(path, data) {
  333. /** @type {Array} */
  334. var ex = [];
  335. fail(ex, 18);
  336. debug(ex, path);
  337. debug(ex, data[name]);
  338. return ex;
  339. }
  340. /**
  341. * @param {number} er
  342. * @param {Object} data
  343. * @param {?} str
  344. * @return {?}
  345. */
  346. function done(er, data, str) {
  347. /** @type {Array} */
  348. var ex = [];
  349. fail(ex, 19);
  350. debug(ex, er);
  351. debug(ex, data[name]);
  352. next(ex, String(str));
  353. return ex;
  354. }
  355. /**
  356. * @param {Object} node
  357. * @return {?}
  358. */
  359. function check(node) {
  360. var val = node[name];
  361. if (!val || (0 > val || (!/^INPUT|SELECT|TEXTAREA$/.test(node.nodeName) || (!node.form || $(node.form))))) {
  362. return null;
  363. }
  364. var pdataOld = dom.getFormNumber(node.form);
  365. if (0 > pdataOld) {
  366. return null;
  367. }
  368. var udataCur;
  369. udataCur = "INPUT" == node.nodeName ? {
  370. text : 0,
  371. color : 0,
  372. date : 0,
  373. datetime : 0,
  374. "datetime-local" : 0,
  375. email : 0,
  376. number : 0,
  377. range : 0,
  378. search : 0,
  379. tel : 0,
  380. time : 0,
  381. url : 0,
  382. month : 0,
  383. week : 0,
  384. password : 2,
  385. radio : 3,
  386. checkbox : 4,
  387. file : 6,
  388. image : 7
  389. }[node.type] : {
  390. SELECT : 1,
  391. TEXTAREA : 5
  392. }[node.nodeName];
  393. if ("number" != typeof udataCur) {
  394. return null;
  395. }
  396. /** @type {number} */
  397. var n = -1;
  398. var result = node.form.elements;
  399. var iLength = result.length;
  400. /** @type {number} */
  401. var i = 0;
  402. /** @type {number} */
  403. var step = 0;
  404. for (;i < iLength;i++) {
  405. if (result[i].name == node.name) {
  406. if (result[i] == node) {
  407. /** @type {number} */
  408. n = step;
  409. break;
  410. }
  411. step++;
  412. }
  413. }
  414. if (0 > n) {
  415. return null;
  416. }
  417. /** @type {Array} */
  418. result = [];
  419. fail(result, 7);
  420. debug(result, val);
  421. debug(result, pdataOld);
  422. debug(result, udataCur);
  423. complete(result, node.name || "");
  424. debug(result, n);
  425. return result;
  426. }
  427. /**
  428. * @param {number} reason
  429. * @param {HTMLFormElement} node
  430. * @return {?}
  431. */
  432. function error(reason, node) {
  433. var i = dom.getFormNumber(node);
  434. if (0 > i) {
  435. return null;
  436. }
  437. var result = node.elements;
  438. var iLength = result.length;
  439. /** @type {Array} */
  440. var conf = [];
  441. /** @type {number} */
  442. var j = 0;
  443. for (;j < iLength;j++) {
  444. if (!dom.isEmptyField(result[j])) {
  445. var params = result[j][name];
  446. if (params) {
  447. if (0 < params) {
  448. self.mergeArrays(conf, [params]);
  449. }
  450. }
  451. }
  452. }
  453. /** @type {Array} */
  454. result = [];
  455. fail(result, 11);
  456. debug(result, reason);
  457. debug(result, i);
  458. debug(result, conf.length);
  459. /** @type {number} */
  460. i = 0;
  461. for (;i < conf.length;i++) {
  462. debug(result, conf[i]);
  463. }
  464. return result;
  465. }
  466. /**
  467. * @return {?}
  468. */
  469. function exec() {
  470. /** @type {Array} */
  471. var ex = [];
  472. fail(ex, 13);
  473. return ex;
  474. }
  475. /**
  476. * @param {Function} name
  477. * @param {Array} value
  478. * @param {boolean} expectedNumberOfNonCommentArgs
  479. * @return {undefined}
  480. */
  481. function emit(name, value, expectedNumberOfNonCommentArgs) {
  482. name = name.apply(win, value);
  483. context.append(name, expectedNumberOfNonCommentArgs);
  484. }
  485. /**
  486. * @param {Object} node
  487. * @return {undefined}
  488. */
  489. function init(node) {
  490. if (node[name]) {
  491. a: {
  492. var res = get();
  493. var i = node[name];
  494. if (0 < i) {
  495. /** @type {Array} */
  496. var expected = [];
  497. node = dom.getElementRegion(node);
  498. var e = data[i];
  499. var pos = node[0] + "x" + node[1];
  500. var key = node[2] + "x" + node[3];
  501. if (pos != e.pos) {
  502. e.pos = pos;
  503. fail(expected, 9);
  504. debug(expected, res);
  505. debug(expected, i);
  506. debug(expected, node[0]);
  507. debug(expected, node[1]);
  508. }
  509. if (key != e.size) {
  510. e.size = key;
  511. fail(expected, 10);
  512. debug(expected, res);
  513. debug(expected, i);
  514. debug(expected, node[2]);
  515. debug(expected, node[3]);
  516. }
  517. if (expected.length) {
  518. /** @type {Array} */
  519. node = expected;
  520. break a;
  521. }
  522. }
  523. /** @type {null} */
  524. node = null;
  525. }
  526. } else {
  527. if (i = dom.getElementParent(node)) {
  528. init(i);
  529. }
  530. node[name] = func;
  531. data[func] = {};
  532. func++;
  533. if (node.nodeName) {
  534. if (i = +node[name], !isFinite(i) || 0 >= i) {
  535. /** @type {null} */
  536. res = null;
  537. } else {
  538. /** @type {number} */
  539. expected = 64;
  540. /** @type {number} */
  541. e = 0;
  542. var elements = dom.getElementParent(node);
  543. pos = elements && elements[name] ? elements[name] : 0;
  544. if (0 > pos) {
  545. /** @type {number} */
  546. pos = 0;
  547. }
  548. key = node.nodeName.toUpperCase();
  549. var value = $cookies[key];
  550. if (!value) {
  551. expected |= 2;
  552. }
  553. var now = dom.getElementNeighborPosition(node);
  554. if (!now) {
  555. expected |= 4;
  556. }
  557. var current = dom.getElementRegion(node);
  558. if (elements = elements ? dom.getElementRegion(elements) : null) {
  559. if (current[0] == elements[0]) {
  560. if (current[1] == elements[1]) {
  561. if (current[2] == elements[2]) {
  562. if (current[3] == elements[3]) {
  563. expected |= 8;
  564. }
  565. }
  566. }
  567. }
  568. }
  569. data[i].pos = current[0] + "x" + current[1];
  570. data[i].size = current[2] + "x" + current[3];
  571. if (node.id) {
  572. if ("string" == typeof node.id) {
  573. expected |= 32;
  574. }
  575. }
  576. if (elements = dom.calcTextChecksum(node)) {
  577. expected |= 16;
  578. }
  579. var n = dom.calcAttribChecksum(node);
  580. if (n) {
  581. e |= 2;
  582. }
  583. var ex;
  584. b: {
  585. ex = dom.getElementChildren(dom.getElementParent(node), node.tagName);
  586. /** @type {number} */
  587. var ii = 0;
  588. for (;ii < ex.length;ii++) {
  589. if ((!ex[ii].id || "string" != typeof ex[ii].id) && (dom.calcAttribChecksum(ex[ii]) == n && dom.calcTextChecksum(ex[ii]) == elements)) {
  590. /** @type {boolean} */
  591. ex = true;
  592. break b;
  593. }
  594. }
  595. /** @type {boolean} */
  596. ex = false;
  597. }
  598. if (ex) {
  599. expected |= 1;
  600. res = dom.calcChildrenChecksum(node);
  601. }
  602. /** @type {Array} */
  603. ex = [];
  604. fail(ex, 1);
  605. debug(ex, i);
  606. fail(ex, expected);
  607. debug(ex, pos);
  608. if (value) {
  609. fail(ex, value);
  610. } else {
  611. next(ex, key);
  612. }
  613. if (now) {
  614. debug(ex, now);
  615. }
  616. if (!(expected & 8)) {
  617. debug(ex, current[0]);
  618. debug(ex, current[1]);
  619. debug(ex, current[2]);
  620. debug(ex, current[3]);
  621. }
  622. if (expected & 32) {
  623. next(ex, node.id);
  624. }
  625. if (elements) {
  626. cb(ex, elements);
  627. }
  628. if (expected & 1) {
  629. cb(ex, res);
  630. }
  631. fail(ex, e);
  632. if (n) {
  633. cb(ex, n);
  634. }
  635. /** @type {Array} */
  636. res = ex;
  637. }
  638. } else {
  639. /** @type {number} */
  640. node[name] = -1;
  641. /** @type {null} */
  642. res = null;
  643. }
  644. context.append(res, void 0);
  645. node = check(node);
  646. }
  647. context.append(node, void 0);
  648. }
  649. /**
  650. * @param {?} a
  651. * @param {boolean} dataAndEvents
  652. * @return {?}
  653. */
  654. function jQuery(a, dataAndEvents) {
  655. var ret = a && dom.classNameExists(a, "(ym-disable-keys|-metrika-nokeys)");
  656. if (dataAndEvents) {
  657. if (a) {
  658. ret = ret || !!dom.getElementsByClassName("(ym-disable-keys|-metrika-nokeys)", a).length;
  659. }
  660. }
  661. return ret;
  662. }
  663. /**
  664. * @param {Object} a
  665. * @return {?}
  666. */
  667. function $(a) {
  668. return a && dom.classNameExists(a, "(ym-disable-submit|-metrika-noform)");
  669. }
  670. /**
  671. * @param {Object} e
  672. * @return {undefined}
  673. */
  674. function listener(e) {
  675. var el = that.getTarget(e);
  676. if (el && "SCROLLBAR" != el.nodeName) {
  677. if (/^INPUT|SELECT|TEXTAREA|BUTTON$/.test(el.tagName)) {
  678. if (el[name]) {
  679. init(el);
  680. } else {
  681. var data = el.form;
  682. if (data) {
  683. data = data.elements;
  684. var iLen = data.length;
  685. /** @type {number} */
  686. var i = 0;
  687. for (;i < iLen;i++) {
  688. if (/^INPUT|SELECT|TEXTAREA|BUTTON$/.test(data[i].tagName)) {
  689. if (!data[i][name]) {
  690. init(data[i]);
  691. }
  692. }
  693. }
  694. } else {
  695. init(el);
  696. }
  697. }
  698. } else {
  699. init(el);
  700. }
  701. emit(load, [get(), e.type, el, that.getPos(e), e.which, e.button]);
  702. }
  703. }
  704. /**
  705. * @param {Object} e
  706. * @return {undefined}
  707. */
  708. function select(e) {
  709. listener(e);
  710. a: {
  711. var val;
  712. var n;
  713. if (win.getSelection) {
  714. try {
  715. /** @type {(Selection|null)} */
  716. var sel = win.getSelection();
  717. } catch (jb) {
  718. break a;
  719. }
  720. /** @type {string} */
  721. val = sel.toString();
  722. /** @type {(Node|null)} */
  723. n = sel.anchorNode;
  724. } else {
  725. if (doc.selection) {
  726. if (doc.selection.createRange) {
  727. /** @type {(ControlRange|TextRange|null)} */
  728. e = doc.selection.createRange();
  729. val = e.text;
  730. n = e.parentElement();
  731. }
  732. }
  733. }
  734. if ("string" == typeof val) {
  735. try {
  736. for (;n && 1 != n.nodeType;) {
  737. n = n.parentNode;
  738. }
  739. } catch (jb) {
  740. break a;
  741. }
  742. if (!(n && filter(n))) {
  743. if (!jQuery(n, true)) {
  744. if (!(val == out)) {
  745. /** @type {string} */
  746. out = val;
  747. emit(success, [get(), val]);
  748. }
  749. }
  750. }
  751. }
  752. }
  753. }
  754. /**
  755. * @param {Object} e
  756. * @return {undefined}
  757. */
  758. function handler(e) {
  759. var max = remove();
  760. /** @type {number} */
  761. var range = max - min;
  762. if (!(10 > range)) {
  763. var vec = that.getPos(e);
  764. /** @type {number} */
  765. var z0 = dest[0] - vec[0];
  766. /** @type {number} */
  767. var z1 = dest[1] - vec[1];
  768. /** @type {number} */
  769. z0 = z0 * z0 + z1 * z1;
  770. if (!(0 >= z0)) {
  771. if (!(16 > z0 && 100 > range)) {
  772. if (!(20 > range && 256 > z0)) {
  773. min = max;
  774. dest = vec;
  775. listener(e);
  776. }
  777. }
  778. }
  779. }
  780. }
  781. /**
  782. * @return {undefined}
  783. */
  784. function close() {
  785. var cur = dom.getDocumentScroll();
  786. var max = remove();
  787. if (!(10 > max - aux)) {
  788. if (!(10 > Math.abs(cur[0] - prev[0]) && 10 > Math.abs(cur[1] - prev[1]))) {
  789. aux = max;
  790. prev = cur;
  791. emit(text, [get(), cur]);
  792. }
  793. }
  794. }
  795. /**
  796. * @param {Object} event
  797. * @return {undefined}
  798. */
  799. function update(event) {
  800. if (event = that.getTarget(event)) {
  801. /** @type {number} */
  802. var elem = Math.random();
  803. /** @type {Array} */
  804. var node = [event.scrollLeft, event.scrollTop];
  805. if (event.localId) {
  806. if (elem = elems[event.localId], !elem || 10 > Math.abs(node[0] - elem[0]) && 10 > Math.abs(node[1] - elem[1])) {
  807. return;
  808. }
  809. } else {
  810. for (;elems[elem];) {
  811. /** @type {number} */
  812. elem = Math.random();
  813. }
  814. /** @type {number} */
  815. event.localId = elem;
  816. }
  817. /** @type {Array} */
  818. elems[event.localId] = node;
  819. if (event !== doc) {
  820. init(event);
  821. emit(include, [get(), node, event]);
  822. }
  823. }
  824. }
  825. /**
  826. * @return {undefined}
  827. */
  828. function poll() {
  829. emit(change, [get(), dom.getViewportSize(), dom.getDocumentSize()]);
  830. }
  831. /**
  832. * @return {undefined}
  833. */
  834. function noop() {
  835. emit(exec, [], true);
  836. }
  837. /**
  838. * @param {Object} event
  839. * @return {?}
  840. */
  841. function dispatch(event) {
  842. return(event.shiftKey ? 2 : 0) | (event.ctrlKey ? 4 : 0) | (event.altKey ? 1 : 0) | (event.metaKey ? 8 : 0) | (event.ctrlKey || event.altKey ? 16 : 0);
  843. }
  844. /**
  845. * @param {Object} a
  846. * @return {?}
  847. */
  848. function filter(a) {
  849. return "INPUT" == a.tagName ? "password" == a.type || (a.name && names.test(a.name) || a.id && names.test(a.id)) : false;
  850. }
  851. /**
  852. * @param {Object} doc
  853. * @param {?} string
  854. * @param {number} positions
  855. * @return {undefined}
  856. */
  857. function show(doc, string, positions) {
  858. if (!!(doc = that.getTarget(doc))) {
  859. if (!filter(doc)) {
  860. if (!jQuery(doc)) {
  861. init(doc);
  862. emit(save, [get(), string, positions, doc]);
  863. }
  864. }
  865. }
  866. }
  867. /**
  868. * @param {Object} data
  869. * @return {undefined}
  870. */
  871. function send(data) {
  872. var code = data.keyCode;
  873. var newState = dispatch(data);
  874. if ({
  875. 3 : 1,
  876. 8 : 1,
  877. 9 : 1,
  878. 13 : 1,
  879. 16 : 1,
  880. 17 : 1,
  881. 18 : 1,
  882. 19 : 1,
  883. 20 : 1,
  884. 27 : 1,
  885. 33 : 1,
  886. 34 : 1,
  887. 35 : 1,
  888. 36 : 1,
  889. 37 : 1,
  890. 38 : 1,
  891. 39 : 1,
  892. 40 : 1,
  893. 45 : 1,
  894. 46 : 1,
  895. 91 : 1,
  896. 92 : 1,
  897. 93 : 1,
  898. 106 : 1,
  899. 110 : 1,
  900. 111 : 1,
  901. 144 : 1,
  902. 145 : 1
  903. }[code] || (112 <= code && 123 >= code || (96 <= code && 105 >= code || newState & 16))) {
  904. if (19 == code) {
  905. if (4 == (newState & -17)) {
  906. /** @type {number} */
  907. code = 144;
  908. }
  909. }
  910. show(data, code, newState | 16);
  911. /** @type {boolean} */
  912. fa = false;
  913. self.setTimeout(function() {
  914. /** @type {boolean} */
  915. fa = true;
  916. }, 1);
  917. if (!!(67 == code && newState & 4)) {
  918. if (!(newState & 1)) {
  919. if (!(newState & 2)) {
  920. process();
  921. }
  922. }
  923. }
  924. }
  925. }
  926. /**
  927. * @param {Object} event
  928. * @return {undefined}
  929. */
  930. function onResize(event) {
  931. if (fa) {
  932. if (!V) {
  933. if (0 !== event.which) {
  934. show(event, event.charCode || event.keyCode, dispatch(event));
  935. /** @type {boolean} */
  936. V = true;
  937. self.setTimeout(function() {
  938. /** @type {boolean} */
  939. V = false;
  940. }, 1);
  941. }
  942. }
  943. }
  944. }
  945. /**
  946. * @return {undefined}
  947. */
  948. function process() {
  949. if (!T) {
  950. /** @type {boolean} */
  951. T = true;
  952. if (out) {
  953. emit(clone, [get()]);
  954. }
  955. self.setTimeout(function() {
  956. /** @type {boolean} */
  957. T = false;
  958. }, 1);
  959. }
  960. }
  961. /**
  962. * @return {undefined}
  963. */
  964. function method() {
  965. if (!qa) {
  966. /** @type {boolean} */
  967. qa = true;
  968. emit(onerror, [get()]);
  969. }
  970. }
  971. /**
  972. * @return {undefined}
  973. */
  974. function scroll() {
  975. if (qa) {
  976. /** @type {boolean} */
  977. qa = false;
  978. emit(ok, [get()]);
  979. }
  980. }
  981. /**
  982. * @param {Event} elem
  983. * @return {undefined}
  984. */
  985. function restoreScript(elem) {
  986. if (!qa || elem && !elem.fromElement) {
  987. method();
  988. }
  989. }
  990. /**
  991. * @param {Event} ev
  992. * @return {undefined}
  993. */
  994. function start(ev) {
  995. if (ev) {
  996. if (!ev.toElement) {
  997. scroll();
  998. }
  999. }
  1000. }
  1001. /**
  1002. * @param {Object} params
  1003. * @return {undefined}
  1004. */
  1005. function add(params) {
  1006. if ((params = that.getTarget(params)) && /^INPUT|SELECT|TEXTAREA|BUTTON$/.test(params.tagName)) {
  1007. if (params[name]) {
  1008. init(params);
  1009. } else {
  1010. var data = params.form;
  1011. if (data) {
  1012. data = data.elements;
  1013. var iLen = data.length;
  1014. /** @type {number} */
  1015. var i = 0;
  1016. for (;i < iLen;i++) {
  1017. if (/^INPUT|SELECT|TEXTAREA|BUTTON$/.test(data[i].tagName)) {
  1018. if (!data[i][name]) {
  1019. init(data[i]);
  1020. }
  1021. }
  1022. }
  1023. } else {
  1024. init(params);
  1025. }
  1026. }
  1027. emit(timeout, [get(), params]);
  1028. }
  1029. }
  1030. /**
  1031. * @param {HTMLElement} params
  1032. * @return {undefined}
  1033. */
  1034. function run(params) {
  1035. if (params = that.getTarget(params)) {
  1036. if (/^INPUT|SELECT|TEXTAREA|BUTTON$/.test(params.tagName)) {
  1037. init(params);
  1038. emit(destroy, [get(), params]);
  1039. }
  1040. }
  1041. }
  1042. /**
  1043. * @param {Element} doc
  1044. * @return {undefined}
  1045. */
  1046. function fn(doc) {
  1047. if ((doc = that.getTarget(doc)) && (!filter(doc) && (!jQuery(doc) && /^INPUT|SELECT|TEXTAREA$/.test(doc.tagName)))) {
  1048. var b = /^(checkbox|radio)$/.test(doc.type) ? doc.checked : doc.value;
  1049. init(doc);
  1050. emit(done, [get(), doc, b]);
  1051. }
  1052. }
  1053. /**
  1054. * @param {Object} e
  1055. * @return {undefined}
  1056. */
  1057. function handleClick(e) {
  1058. if ((e = that.getTarget(e)) && (!$(e) && "FORM" == e.nodeName)) {
  1059. var codeSegments = e.elements;
  1060. /** @type {number} */
  1061. var i = 0;
  1062. for (;i < codeSegments.length;i++) {
  1063. if (!dom.isEmptyField(codeSegments[i])) {
  1064. init(codeSegments[i]);
  1065. }
  1066. }
  1067. emit(error, [get(), e], true);
  1068. }
  1069. }
  1070. /**
  1071. * @param {Object} event
  1072. * @return {undefined}
  1073. */
  1074. function onClick(event) {
  1075. close();
  1076. if (event.touches && event.touches.length) {
  1077. var parent = that.getTarget(event);
  1078. if (parent && parent != doc) {
  1079. init(parent);
  1080. /** @type {number} */
  1081. var t = 0;
  1082. for (;t < event.touches.length;t++) {
  1083. emit(load, [get(), "touch", parent, [event.touches[t].pageX, event.touches[t].pageY], 0, 0]);
  1084. }
  1085. }
  1086. }
  1087. }
  1088. /**
  1089. * @param {Object} e
  1090. * @return {undefined}
  1091. */
  1092. function ready(e) {
  1093. var tooltip = that.getTarget(e);
  1094. if (tooltip) {
  1095. var c;
  1096. if ("wheel" == e.type) {
  1097. /** @type {number} */
  1098. c = 0 < e.deltaY ? 1 : 0 > e.deltaY ? 2 : 0;
  1099. } else {
  1100. if ("mousewheel" == e.type) {
  1101. /** @type {number} */
  1102. c = 0 < e.wheelDelta ? 2 : 0 > e.wheelDelta ? 1 : 0;
  1103. }
  1104. }
  1105. if (c) {
  1106. init(tooltip);
  1107. emit(parser, [get(), tooltip, that.getPos(e), c]);
  1108. }
  1109. }
  1110. }
  1111. /**
  1112. * @param {Element} v
  1113. * @return {undefined}
  1114. */
  1115. function callback(v) {
  1116. if (v = that.getTarget(v)) {
  1117. if ("BODY" == v.tagName) {
  1118. context.append([], true);
  1119. }
  1120. }
  1121. }
  1122. var context = new t({
  1123. protocol : allBindingsAccessor,
  1124. counterId : depMaps,
  1125. counterType : rootjQuery,
  1126. meta : {
  1127. url : trigger().href,
  1128. hitId : deepDataAndEvents,
  1129. timezone : udataCur,
  1130. timestamp : now
  1131. }
  1132. });
  1133. var $cookies = {
  1134. A : 1,
  1135. ABBR : 2,
  1136. ACRONYM : 3,
  1137. ADDRESS : 4,
  1138. APPLET : 5,
  1139. AREA : 6,
  1140. B : 7,
  1141. BASE : 8,
  1142. BASEFONT : 9,
  1143. BDO : 10,
  1144. BIG : 11,
  1145. BLOCKQUOTE : 12,
  1146. BODY : 13,
  1147. BR : 14,
  1148. BUTTON : 15,
  1149. CAPTION : 16,
  1150. CENTER : 17,
  1151. CITE : 18,
  1152. CODE : 19,
  1153. COL : 20,
  1154. COLGROUP : 21,
  1155. DD : 22,
  1156. DEL : 23,
  1157. DFN : 24,
  1158. DIR : 25,
  1159. DIV : 26,
  1160. DL : 27,
  1161. DT : 28,
  1162. EM : 29,
  1163. FIELDSET : 30,
  1164. FONT : 31,
  1165. FORM : 32,
  1166. FRAME : 33,
  1167. FRAMESET : 34,
  1168. H1 : 35,
  1169. H2 : 36,
  1170. H3 : 37,
  1171. H4 : 38,
  1172. H5 : 39,
  1173. H6 : 40,
  1174. HEAD : 41,
  1175. HR : 42,
  1176. HTML : 43,
  1177. I : 44,
  1178. IFRAME : 45,
  1179. IMG : 46,
  1180. INPUT : 47,
  1181. INS : 48,
  1182. ISINDEX : 49,
  1183. KBD : 50,
  1184. LABEL : 51,
  1185. LEGEND : 52,
  1186. LI : 53,
  1187. LINK : 54,
  1188. MAP : 55,
  1189. MENU : 56,
  1190. META : 57,
  1191. NOFRAMES : 58,
  1192. NOSCRIPT : 59,
  1193. OBJECT : 60,
  1194. OL : 61,
  1195. OPTGROUP : 62,
  1196. OPTION : 63,
  1197. P : 64,
  1198. PARAM : 65,
  1199. PRE : 66,
  1200. Q : 67,
  1201. S : 68,
  1202. SAMP : 69,
  1203. SCRIPT : 70,
  1204. SELECT : 71,
  1205. SMALL : 72,
  1206. SPAN : 73,
  1207. STRIKE : 74,
  1208. STRONG : 75,
  1209. STYLE : 76,
  1210. SUB : 77,
  1211. SUP : 78,
  1212. TABLE : 79,
  1213. TBODY : 80,
  1214. TD : 81,
  1215. TEXTAREA : 82,
  1216. TFOOT : 83,
  1217. TH : 84,
  1218. THEAD : 85,
  1219. TITLE : 86,
  1220. TR : 87,
  1221. TT : 88,
  1222. U : 89,
  1223. UL : 90,
  1224. VAR : 91,
  1225. NOINDEX : 100
  1226. };
  1227. /** @type {number} */
  1228. var ROOM_SIZE = 0;
  1229. /** @type {number} */
  1230. var y = 0;
  1231. tick(0);
  1232. /** @type {number} */
  1233. var func = 1;
  1234. /** @type {number} */
  1235. var min = 0;
  1236. /** @type {Array} */
  1237. var dest = [0, 0];
  1238. /** @type {number} */
  1239. var aux = 0;
  1240. /** @type {Array} */
  1241. var prev = [0, 0];
  1242. var elems = {};
  1243. /** @type {RegExp} */
  1244. var names = /^(password|passwd|pswd)$/;
  1245. /** @type {boolean} */
  1246. var fa = true;
  1247. /** @type {boolean} */
  1248. var V = false;
  1249. /** @type {string} */
  1250. var out = "";
  1251. /** @type {boolean} */
  1252. var T = false;
  1253. /** @type {boolean} */
  1254. var qa = true;
  1255. var newMethods = remove();
  1256. /** @type {string} */
  1257. var name = "metrikaId_" + Math.random();
  1258. var data = {};
  1259. /** @type {string} */
  1260. var j = ":submit" + Math.random();
  1261. if (!self.isMetrikaPlayer()) {
  1262. Event.on(doc, "mousemove", handler);
  1263. Event.on(doc, "click,dblclick,mousedown", listener);
  1264. Event.on(doc, "mouseup", select);
  1265. Event.on(win, "scroll", close);
  1266. if ("onmousewheel" in doc) {
  1267. Event.on(doc, "mousewheel", ready);
  1268. } else {
  1269. Event.on(doc, "wheel", ready);
  1270. }
  1271. Event.on(win, "beforeunload", noop);
  1272. if (!lb) {
  1273. Event.on(win, "unload", noop);
  1274. }
  1275. Event.on(win, "resize", poll);
  1276. Event.on(doc, "keydown", send);
  1277. Event.on(doc, "keypress", onResize);
  1278. Event.on(doc, "copy", process);
  1279. Event.on(doc, "touchmove,touchstart", onClick);
  1280. if (doc.body) {
  1281. Event.on(doc, "mouseleave", callback);
  1282. }
  1283. if (doc.attachEvent && !win.opera) {
  1284. Event.on(doc, "focusin", restoreScript);
  1285. Event.on(doc, "focusout", start);
  1286. } else {
  1287. Event.on(win, "focus", method);
  1288. Event.on(win, "blur", scroll);
  1289. Event.on(doc, "blur", scroll);
  1290. }
  1291. if (doc.addEventListener) {
  1292. Event.on(doc, "scroll", update);
  1293. Event.on(doc, "focus", add);
  1294. Event.on(doc, "blur", run);
  1295. Event.on(doc, "change", fn);
  1296. Event.on(doc, "submit", handleClick);
  1297. } else {
  1298. if (doc.attachEvent) {
  1299. Event.on(doc, "focusin", add);
  1300. Event.on(doc, "focusout", run);
  1301. (function() {
  1302. /** @type {NodeList} */
  1303. var items = doc.getElementsByTagName("form");
  1304. /** @type {number} */
  1305. var i = 0;
  1306. for (;i < items.length;i++) {
  1307. var children = items[i].getElementsByTagName("*");
  1308. /** @type {number} */
  1309. var ci = 0;
  1310. for (;ci < children.length;ci++) {
  1311. if (/^INPUT|SELECT|TEXTAREA$/.test(children[ci].tagName)) {
  1312. Event.on(children[ci], "change", fn);
  1313. }
  1314. }
  1315. Event.on(items[i], "submit", handleClick);
  1316. }
  1317. })();
  1318. }
  1319. }
  1320. (function() {
  1321. /** @type {NodeList} */
  1322. var codeSegments = doc.getElementsByTagName("form");
  1323. if (codeSegments.length) {
  1324. /** @type {number} */
  1325. var i = 0;
  1326. for (;i < codeSegments.length;i++) {
  1327. var val = codeSegments[i].submit;
  1328. if ("function" == typeof val || "object" == typeof val && /^\s*function submit\(\)/.test(String(val))) {
  1329. codeSegments[i][j] = val;
  1330. /**
  1331. * @return {?}
  1332. */
  1333. codeSegments[i].submit = function() {
  1334. handleClick({
  1335. target : this
  1336. });
  1337. return this[j]();
  1338. };
  1339. }
  1340. }
  1341. }
  1342. })();
  1343. if ("0:0" != dom.getDocumentScroll().join(":")) {
  1344. close();
  1345. }
  1346. poll();
  1347. }
  1348. return{
  1349. /**
  1350. * @return {undefined}
  1351. */
  1352. start : function() {
  1353. context.activate();
  1354. },
  1355. /**
  1356. * @return {undefined}
  1357. */
  1358. stop : function() {
  1359. context.clear();
  1360. Event.un(doc, "mousemove", handler);
  1361. Event.un(doc, "click,dblclick,mousedown", listener);
  1362. Event.un(doc, "mouseup", select);
  1363. Event.un(doc, "mousewheel", ready);
  1364. Event.un(doc, "wheel", ready);
  1365. Event.un(win, "scroll", close);
  1366. Event.un(win, "beforeunload", noop);
  1367. Event.un(win, "unload", noop);
  1368. Event.un(win, "resize", poll);
  1369. Event.un(doc, "keydown", send);
  1370. Event.un(doc, "keypress", onResize);
  1371. Event.un(doc, "copy", process);
  1372. Event.un(doc, "touchmove", onClick);
  1373. Event.un(doc, "touchstart", onClick);
  1374. if (doc.body) {
  1375. Event.un(doc, "mouseleave", callback);
  1376. }
  1377. Event.un(doc, "focusin", restoreScript);
  1378. Event.un(doc, "focusout", start);
  1379. Event.un(win, "focus", method);
  1380. Event.un(win, "blur", scroll);
  1381. Event.un(doc, "blur", scroll);
  1382. if (doc.removeEventListener) {
  1383. Event.un(doc, "scroll", update);
  1384. Event.un(doc, "focus", add);
  1385. Event.un(doc, "blur", run);
  1386. Event.un(doc, "change", fn);
  1387. Event.un(doc, "submit", handleClick);
  1388. } else {
  1389. if (doc.detachEvent) {
  1390. Event.un(doc, "focusin", add);
  1391. Event.un(doc, "focusout", run);
  1392. (function() {
  1393. /** @type {NodeList} */
  1394. var codeSegments = doc.getElementsByTagName("form");
  1395. /** @type {number} */
  1396. var i = 0;
  1397. for (;i < codeSegments.length;i++) {
  1398. var children = codeSegments[i].getElementsByTagName("*");
  1399. /** @type {number} */
  1400. var ci = 0;
  1401. for (;ci < children.length;ci++) {
  1402. if (/^INPUT|SELECT|TEXTAREA$/.test(children[ci].tagName)) {
  1403. Event.un(children[ci], "change", fn);
  1404. }
  1405. }
  1406. Event.un(codeSegments[i], "submit", handleClick);
  1407. }
  1408. })();
  1409. }
  1410. }
  1411. (function() {
  1412. /** @type {NodeList} */
  1413. var codeSegments = doc.getElementsByTagName("form");
  1414. /** @type {number} */
  1415. var i = 0;
  1416. for (;i < codeSegments.length;i++) {
  1417. if (codeSegments[i][j]) {
  1418. codeSegments[i].submit = codeSegments[i][j];
  1419. }
  1420. }
  1421. })();
  1422. },
  1423. /**
  1424. * @param {string} step
  1425. * @param {?} v12
  1426. * @return {undefined}
  1427. */
  1428. uploadPages : function(step, v12) {
  1429. /**
  1430. * @return {undefined}
  1431. */
  1432. function process() {
  1433. Event.un(doc, "DOMContentLoaded", process);
  1434. Event.un(win, "load", process);
  1435. var codeSegments = step.split(/\n/);
  1436. var value = trigger().href;
  1437. /** @type {RegExp} */
  1438. var re = /regexp:/;
  1439. /** @type {number} */
  1440. var i = 0;
  1441. for (;i < codeSegments.length;i++) {
  1442. var src = codeSegments[i];
  1443. if (src) {
  1444. if (re.test(src)) {
  1445. src = trim(src.replace(re, ""));
  1446. try {
  1447. /** @type {RegExp} */
  1448. var r = new RegExp(src);
  1449. } catch (Hb) {
  1450. }
  1451. if (r && r.test(value)) {
  1452. vec2.uploadPage(v12);
  1453. break;
  1454. }
  1455. } else {
  1456. if (-1 !== value.indexOf(src)) {
  1457. vec2.uploadPage(v12);
  1458. break;
  1459. }
  1460. }
  1461. }
  1462. }
  1463. }
  1464. var vec2 = this;
  1465. if ("complete" == doc.readyState) {
  1466. process();
  1467. } else {
  1468. Event.on(doc, "DOMContentLoaded", process);
  1469. Event.on(win, "load", process);
  1470. }
  1471. },
  1472. uploadPage : bind(function(input) {
  1473. if ("function" == typeof win.toStaticHTML && -1 < win.toStaticHTML.toString().indexOf("NoScript")) {
  1474. return false;
  1475. }
  1476. /** @type {Element} */
  1477. var elem = doc.documentElement;
  1478. if (elem && 19E4 < ("" + elem.innerHTML).length) {
  1479. return false;
  1480. }
  1481. var xhr = win.XMLHttpRequest ? new win.XMLHttpRequest : new ActiveXObject("Msxml2.XMLHTTP");
  1482. var charset = dom.getDocumentCharset();
  1483. /** @type {string} */
  1484. var type = "text/html" + (charset ? ";charset=" + charset : "");
  1485. var jQuery = new Repo({
  1486. protocol : allBindingsAccessor,
  1487. counterId : depMaps,
  1488. counterType : rootjQuery
  1489. });
  1490. if ("html" == input) {
  1491. return input = RegExp("<script [^>]*?//mc\\.yandex\\.ru/watch/.*?\x3c/script>", "gi"), jQuery.sendContent(dom.getDocumentHTML().replace(input, ""), type, deepDataAndEvents, udataCur, now), true;
  1492. }
  1493. if (xhr) {
  1494. xhr.open("get", trigger().href, true);
  1495. xhr.onreadystatechange = bind(function() {
  1496. if (4 == xhr.readyState) {
  1497. var name = xhr.getResponseHeader("content-type") || "";
  1498. if (charset) {
  1499. if (-1 === name.indexOf("charset=")) {
  1500. /** @type {string} */
  1501. name = type;
  1502. }
  1503. }
  1504. jQuery.sendContent(xhr.responseText, name, deepDataAndEvents, udataCur, now);
  1505. }
  1506. }, "updatePage.1");
  1507. if (xhr.overrideMimeType) {
  1508. if (charset) {
  1509. xhr.overrideMimeType(type);
  1510. }
  1511. }
  1512. xhr.send(null);
  1513. }
  1514. return true;
  1515. }, "uploadPage")
  1516. };
  1517. }
  1518. /**
  1519. * @param {Function} fn
  1520. * @param {string} id
  1521. * @param {boolean} dataAndEvents
  1522. * @return {?}
  1523. */
  1524. function bind(fn, id, dataAndEvents) {
  1525. return function() {
  1526. try {
  1527. return fn.apply(this, arguments);
  1528. } catch (err) {
  1529. if (!dataAndEvents) {
  1530. callback(err, id);
  1531. }
  1532. }
  1533. };
  1534. }
  1535. /**
  1536. * @param {(Error|string)} err
  1537. * @param {string} key
  1538. * @return {undefined}
  1539. */
  1540. function callback(err, key) {
  1541. var dig;
  1542. if (0.01 > Math.random()) {
  1543. try {
  1544. (new Game).log("jserrs", v, err.message, key, params.href, "", "string" == typeof err.stack && err.stack.replace(/\n/g, "\\n"));
  1545. } catch (d) {
  1546. /** @type {Array} */
  1547. dig = ["cp: " + key, err.name + ": " + err.message, "debug: ", "code: " + v, "stack: " + err.stack];
  1548. /** @type {string} */
  1549. (new Image).src = "//an.yandex.ru/jserr/101500?cnt-class=100&errmsg=" + encodeURIComponent(dig.join("; ").replace(/\r?\n/g, "\\n"));
  1550. }
  1551. }
  1552. }
  1553. /**
  1554. * @param {Function} obj
  1555. * @param {number} time
  1556. * @param {string} fnc
  1557. * @return {?}
  1558. */
  1559. function defer(obj, time, fnc) {
  1560. return win.setTimeout(bind(obj, fnc || "setTimeout"), time);
  1561. }
  1562. /**
  1563. * @return {?}
  1564. */
  1565. function trigger() {
  1566. var result = {};
  1567. /** @type {Array.<string>} */
  1568. var keys = "hash host hostname href pathname port protocol search".split(" ");
  1569. /** @type {number} */
  1570. var len = keys.length;
  1571. /** @type {number} */
  1572. var i = len;
  1573. var h;
  1574. var key;
  1575. for (;i--;) {
  1576. /** @type {string} */
  1577. result[keys[i]] = "";
  1578. }
  1579. try {
  1580. /** @type {(Location|null)} */
  1581. h = win.location;
  1582. /** @type {number} */
  1583. i = len;
  1584. for (;i--;) {
  1585. /** @type {string} */
  1586. key = keys[i];
  1587. result[key] = "" + h[key];
  1588. }
  1589. } catch (l) {
  1590. if (params) {
  1591. result = params;
  1592. }
  1593. }
  1594. return result;
  1595. }
  1596. /**
  1597. * @param {boolean} str
  1598. * @return {?}
  1599. */
  1600. function trim(str) {
  1601. return str ? ("" + str).replace(/^\s+/, "").replace(/\s+$/, "") : "";
  1602. }
  1603. /**
  1604. * @return {?}
  1605. */
  1606. function success() {
  1607. return-1 != trigger().hostname.search(/(?:^|\.)(?:ya|yandex)\.(?:\w+|com\.\w+)$/);
  1608. }
  1609. /**
  1610. * @param {Node} regex
  1611. * @return {?}
  1612. */
  1613. function check(regex) {
  1614. return-1 !== ("" + win.navigator.userAgent).toLowerCase().search(regex);
  1615. }
  1616. /**
  1617. * @param {Object} a
  1618. * @return {?}
  1619. */
  1620. function get(a) {
  1621. return trim(a && (a.innerHTML && a.innerHTML.replace(/<\/?[^>]+>/gi, "")));
  1622. }
  1623. /**
  1624. * @param {?} a
  1625. * @param {Array} b
  1626. * @return {?}
  1627. */
  1628. function walk(a, b) {
  1629. var tagNameArr;
  1630. var j;
  1631. if (!a || !b) {
  1632. return false;
  1633. }
  1634. /** @type {Array} */
  1635. tagNameArr = [];
  1636. /** @type {number} */
  1637. j = 0;
  1638. for (;j < b.length;j++) {
  1639. 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, "\\}"));
  1640. }
  1641. return(new RegExp("\\.(" + tagNameArr.join("|") + ")$", "i")).test(a);
  1642. }
  1643. /**
  1644. * @param {Object} target
  1645. * @return {?}
  1646. */
  1647. function handle(target) {
  1648. target = target.target || target.srcElement;
  1649. var c;
  1650. if (!target) {
  1651. return false;
  1652. }
  1653. if (3 == target.nodeType) {
  1654. target = target.parentNode;
  1655. }
  1656. c = target && (target.nodeName && target.nodeName.toString().toLowerCase());
  1657. for (;target && (target.parentNode && (target.parentNode.nodeName && ("a" != c && "area" != c || !target.href)));) {
  1658. c = (target = target.parentNode) && (target.nodeName && target.nodeName.toString().toLowerCase());
  1659. }
  1660. return target.href ? target : false;
  1661. }
  1662. /**
  1663. * @param {boolean} view
  1664. * @param {string} path
  1665. * @return {?}
  1666. */
  1667. function _init(view, path) {
  1668. return(view ? view.replace(/^www\./, "") : "").toLowerCase() == (path ? path.replace(/^www\./, "") : "").toLowerCase();
  1669. }
  1670. /**
  1671. * @param {boolean} a
  1672. * @param {boolean} b
  1673. * @return {?}
  1674. */
  1675. function extend(a, b) {
  1676. /**
  1677. * @param {Object} str
  1678. * @return {?}
  1679. */
  1680. function camelCase(str) {
  1681. str = str.split(":");
  1682. str = str[1] || "";
  1683. str = str.replace(/^\/*/, "").replace(/^www\./, "");
  1684. return str.split("/")[0];
  1685. }
  1686. return a && b ? camelCase(a) == camelCase(b) : a || b ? false : true;
  1687. }
  1688. /**
  1689. * @return {?}
  1690. */
  1691. function parents() {
  1692. var t = win.performance || win.webkitPerformance;
  1693. var src;
  1694. /** @type {Array} */
  1695. var touches = [];
  1696. if (t = t && t.timing) {
  1697. if (src = t.navigationStart) {
  1698. /** @type {Array} */
  1699. 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];
  1700. touches.push(t.domInteractive && t.domLoading ? t.domInteractive - t.domLoading : null);
  1701. touches.push(t.domContentLoadedEventStart && t.domContentLoadedEventEnd ? t.domContentLoadedEventEnd - t.domContentLoadedEventStart : null);
  1702. touches.push(t.domComplete ? t.domComplete - src : null);
  1703. touches.push(t.loadEventStart ? t.loadEventStart - src : null);
  1704. touches.push(t.loadEventStart && t.loadEventEnd ? t.loadEventEnd - t.loadEventStart : null);
  1705. touches.push(t.domContentLoadedEventStart ? t.domContentLoadedEventStart - src : null);
  1706. /** @type {number} */
  1707. t = 0;
  1708. for (;t < touches.length;t++) {
  1709. src = touches[t];
  1710. if (null !== src) {
  1711. if (0 > src || 36E5 < src) {
  1712. /** @type {null} */
  1713. touches[t] = null;
  1714. }
  1715. }
  1716. }
  1717. }
  1718. }
  1719. return touches;
  1720. }
  1721. /**
  1722. * @param {?} value
  1723. * @return {?}
  1724. */
  1725. function getValue(value) {
  1726. /** @type {Array} */
  1727. var ary = [];
  1728. var codeSegments = value._lastPerformanceTiming;
  1729. var obj = parents();
  1730. var i;
  1731. var valsLength;
  1732. if (codeSegments) {
  1733. /** @type {number} */
  1734. i = 0;
  1735. valsLength = codeSegments.length;
  1736. for (;i < valsLength;i++) {
  1737. if (null === obj[i]) {
  1738. ary.push(obj[i]);
  1739. } else {
  1740. ary.push(codeSegments[i] === obj[i] ? "" : obj[i]);
  1741. }
  1742. }
  1743. } else {
  1744. ary = obj;
  1745. }
  1746. value._lastPerformanceTiming = obj;
  1747. return ary.join(",");
  1748. }
  1749. /**
  1750. * @return {?}
  1751. */
  1752. function calcFirstPaintTimeResults() {
  1753. var t;
  1754. if ("object" == typeof win.chrome && win.chrome.loadTimes) {
  1755. if (t = win.chrome.loadTimes(), t.requestTime && t.firstPaintTime) {
  1756. return~~(1E3 * (t.firstPaintTime - t.requestTime));
  1757. }
  1758. } else {
  1759. if (win.performance && (win.performance.timing && (t = win.performance.timing, t.navigationStart && t.msFirstPaint))) {
  1760. return t.msFirstPaint - t.navigationStart;
  1761. }
  1762. }
  1763. return null;
  1764. }
  1765. /**
  1766. * @param {Object} config
  1767. * @return {?}
  1768. */
  1769. function load(config) {
  1770. /** @type {string} */
  1771. var contentType = doc.referrer || "";
  1772. var patterns;
  1773. var pattern;
  1774. var e;
  1775. var j;
  1776. var i;
  1777. if ((new RegExp("^https?://" + params.host + "/")).test(contentType)) {
  1778. return false;
  1779. }
  1780. patterns = config.patterns;
  1781. /** @type {number} */
  1782. j = 0;
  1783. for (;j < patterns.length;j++) {
  1784. if (pattern = new RegExp(patterns[j], "i"), contentType.match(pattern)) {
  1785. if (pattern = config.params || [], pattern.length) {
  1786. e = self.safeDecodeURIComponent((RegExp.$1 || "").replace(/\+/g, "%20"));
  1787. /** @type {number} */
  1788. i = 0;
  1789. for (;i < pattern.length;i++) {
  1790. if (e == self.safeDecodeURIComponent(pattern[i])) {
  1791. return true;
  1792. }
  1793. }
  1794. } else {
  1795. return true;
  1796. }
  1797. }
  1798. }
  1799. return false;
  1800. }
  1801. /**
  1802. * @param {number} string
  1803. * @param {boolean} dataAndEvents
  1804. * @return {?}
  1805. */
  1806. function add(string, dataAndEvents) {
  1807. /** @type {boolean} */
  1808. var fake = false;
  1809. var id;
  1810. var html;
  1811. var state;
  1812. var i;
  1813. if (string && ("string" != typeof string && string.length)) {
  1814. /** @type {number} */
  1815. i = 0;
  1816. for (;i < string.length;i++) {
  1817. if (id = string[i].selector, html = string[i].text, state = id.charAt(0), id = id.slice(1), "#" == state) {
  1818. if (state = doc.getElementById(id)) {
  1819. /** @type {boolean} */
  1820. fake = true;
  1821. if (dataAndEvents) {
  1822. codeSegments.unshift([state, state.innerHTML]);
  1823. }
  1824. state.innerHTML = html;
  1825. }
  1826. } else {
  1827. if ("." == state) {
  1828. state = dom.getElementsByClassName(id);
  1829. /** @type {number} */
  1830. id = 0;
  1831. for (;id < state.length;id++) {
  1832. /** @type {boolean} */
  1833. fake = true;
  1834. var val = state[id];
  1835. var text = html;
  1836. if (dataAndEvents) {
  1837. codeSegments.unshift([val, val.innerHTML]);
  1838. }
  1839. val.innerHTML = text;
  1840. }
  1841. }
  1842. }
  1843. }
  1844. }
  1845. return fake;
  1846. }
  1847. /**
  1848. * @return {undefined}
  1849. */
  1850. function _next() {
  1851. var i;
  1852. /** @type {number} */
  1853. i = 0;
  1854. for (;i < codeSegments.length;i++) {
  1855. codeSegments[i][0].innerHTML = codeSegments[i][1];
  1856. }
  1857. }
  1858. /**
  1859. * @param {string} s
  1860. * @param {Object} value
  1861. * @return {?}
  1862. */
  1863. function write(s, value) {
  1864. var p;
  1865. var i;
  1866. /** @type {string} */
  1867. var className = "";
  1868. var parameters;
  1869. var codeSegments;
  1870. var classNames;
  1871. s = s && s.replace(/^\?/, "");
  1872. value = value && value.replace(/^#/, "") || "";
  1873. if (s) {
  1874. i = s.split("&");
  1875. /** @type {number} */
  1876. p = 0;
  1877. for (;p < i.length;p++) {
  1878. classNames = i[p].split("=");
  1879. if ("_openstat" === classNames[0]) {
  1880. className = classNames[1];
  1881. }
  1882. }
  1883. }
  1884. parameters = value.split("?");
  1885. /** @type {number} */
  1886. p = 0;
  1887. for (;p < parameters.length;p++) {
  1888. codeSegments = parameters[p].split("&");
  1889. /** @type {number} */
  1890. i = 0;
  1891. for (;i < codeSegments.length;i++) {
  1892. classNames = codeSegments[i].split("=");
  1893. if ("_openstat" === classNames[0]) {
  1894. className = classNames[1];
  1895. }
  1896. }
  1897. }
  1898. if (className) {
  1899. className = -1 < className.indexOf(";") ? self.safeDecodeURIComponent(className) : Base64.decode(exports.decode(className.replace(/[-*_]/g, function(chr) {
  1900. return{
  1901. "*" : "+",
  1902. "-" : "/",
  1903. _ : "="
  1904. }[chr] || chr;
  1905. })));
  1906. }
  1907. return className && (p = className.split(";"), 4 == p.length) ? {
  1908. service : p[0],
  1909. campaign : p[1],
  1910. ad : p[2],
  1911. source : p[3]
  1912. } : null;
  1913. }
  1914. var self = {
  1915. /**
  1916. * @param {Object} obj
  1917. * @return {?}
  1918. */
  1919. mixin : function(obj) {
  1920. var i;
  1921. var prop;
  1922. /** @type {number} */
  1923. i = 1;
  1924. for (;i < arguments.length;i++) {
  1925. if (arguments[i]) {
  1926. for (prop in arguments[i]) {
  1927. if (arguments[i].hasOwnProperty(prop)) {
  1928. obj[prop] = arguments[i][prop];
  1929. }
  1930. }
  1931. if (arguments[i].hasOwnProperty("toString")) {
  1932. obj.toString = arguments[i].toString;
  1933. }
  1934. }
  1935. }
  1936. return obj;
  1937. }
  1938. };
  1939. /**
  1940. * @param {Object} props
  1941. * @return {undefined}
  1942. */
  1943. var $ = function(props) {
  1944. props = props || {};
  1945. self.mixin(this, props);
  1946. this._initComponent();
  1947. };
  1948. /**
  1949. * @return {undefined}
  1950. */
  1951. $.prototype._initComponent = function() {
  1952. };
  1953. /**
  1954. * @param {?} opt_attributes
  1955. * @return {?}
  1956. */
  1957. $.inherit = function(opt_attributes) {
  1958. var superclass;
  1959. var f;
  1960. opt_attributes = opt_attributes || {};
  1961. superclass = "function" == typeof this ? this : Object;
  1962. if (!opt_attributes.hasOwnProperty("constructor")) {
  1963. /**
  1964. * @return {undefined}
  1965. */
  1966. opt_attributes.constructor = function() {
  1967. superclass.apply(this, arguments);
  1968. };
  1969. }
  1970. /**
  1971. * @return {undefined}
  1972. */
  1973. f = function() {
  1974. };
  1975. f.prototype = superclass.prototype;
  1976. opt_attributes.constructor.prototype = new f;
  1977. self.mixin(opt_attributes.constructor.prototype, opt_attributes);
  1978. /** @type {function (): undefined} */
  1979. opt_attributes.constructor.prototype.constructor = opt_attributes.constructor;
  1980. opt_attributes.constructor.superclass = superclass.prototype;
  1981. /** @type {function (?): ?} */
  1982. opt_attributes.constructor.inherit = $.inherit;
  1983. return opt_attributes.constructor;
  1984. };
  1985. /**
  1986. * @param {string} ar
  1987. * @return {?}
  1988. */
  1989. self.isArray = function(ar) {
  1990. return "function" == typeof Array.isArray ? Array.isArray(ar) : "[object Array]" == Object.prototype.toString.call(ar);
  1991. };
  1992. /**
  1993. * @param {Array} a
  1994. * @return {?}
  1995. */
  1996. self.mergeArrays = function(a) {
  1997. var idx;
  1998. var i;
  1999. /** @type {number} */
  2000. var len = arguments.length;
  2001. var c;
  2002. /** @type {number} */
  2003. idx = 1;
  2004. for (;idx < len;idx++) {
  2005. if (c = arguments[idx], self.isArray(c) || c && "[object Arguments]" === c.toString()) {
  2006. /** @type {number} */
  2007. i = 0;
  2008. for (;i < c.length;i++) {
  2009. a[a.length] = c[i];
  2010. }
  2011. }
  2012. }
  2013. return a;
  2014. };
  2015. /**
  2016. * @param {string} property
  2017. * @param {Object} object
  2018. * @return {?}
  2019. */
  2020. self.getNativeFunction = function(property, object) {
  2021. var __method;
  2022. object = object || win;
  2023. return(__method = object.constructor && (object.constructor.prototype && object.constructor.prototype[property]) || object[property]) && "apply" in __method ? function() {
  2024. return __method.apply(object, arguments);
  2025. } : function() {
  2026. };
  2027. };
  2028. /**
  2029. * @param {Function} callback
  2030. * @param {number} ms
  2031. * @param {string} millis
  2032. * @return {?}
  2033. */
  2034. self.setTimeout = function(callback, ms, millis) {
  2035. return self.getNativeFunction("setTimeout")(bind(callback, millis || "setTimeout"), ms);
  2036. };
  2037. /**
  2038. * @param {Function} fn
  2039. * @param {number} timeout
  2040. * @param {?} scope
  2041. * @param {Array} args
  2042. * @param {string} millis
  2043. * @return {?}
  2044. */
  2045. self.defer = function(fn, timeout, scope, args, millis) {
  2046. return self.setTimeout(function() {
  2047. fn.apply(scope, args || []);
  2048. }, timeout, millis);
  2049. };
  2050. /**
  2051. * @param {Function} func
  2052. * @param {number} ms
  2053. * @param {string} scope
  2054. * @param {string} millis
  2055. * @return {?}
  2056. */
  2057. self.throttle = function(func, ms, scope, millis) {
  2058. var msMax;
  2059. var args;
  2060. var nativeScope;
  2061. return function() {
  2062. /** @type {Arguments} */
  2063. args = arguments;
  2064. nativeScope = this;
  2065. if (!msMax) {
  2066. (function() {
  2067. /** @type {null} */
  2068. msMax = null;
  2069. if (args) {
  2070. func.apply(scope || nativeScope, args);
  2071. /** @type {null} */
  2072. args = null;
  2073. msMax = self.setTimeout(arguments.callee, ms, millis);
  2074. }
  2075. })();
  2076. }
  2077. };
  2078. };
  2079. var ret = $.inherit({
  2080. storage : null,
  2081. storageKey : "dataBuffer",
  2082. maxBufferSize : 255,
  2083. flushTimeout : 1E4,
  2084. active : true,
  2085. meta : null,
  2086. /**
  2087. * @return {undefined}
  2088. */
  2089. onFlush : function() {
  2090. },
  2091. onFlushCtx : null,
  2092. bufferExpireTime : 864E5,
  2093. /**
  2094. * @return {undefined}
  2095. */
  2096. _initComponent : function() {
  2097. var e;
  2098. ret.superclass._initComponent.apply(this, arguments);
  2099. /** @type {Array} */
  2100. this._data = [];
  2101. /** @type {number} */
  2102. this._packetNumber = 0;
  2103. /** @type {null} */
  2104. this._flushTID = null;
  2105. this._saveToStorageThrottled = self.throttle(this._saveToStorage, 300, this, "DataBuffer._saveToStorage");
  2106. if (this.storage) {
  2107. if (e = this.storage.get(this.storageKey)) {
  2108. if (e.data) {
  2109. if (e.meta) {
  2110. if (e.time) {
  2111. if (e.time + this.bufferExpireTime > +new Date) {
  2112. this.onFlush.call(this.onFlushCtx || this, e.data, e.meta, e.pnum);
  2113. }
  2114. }
  2115. }
  2116. }
  2117. }
  2118. this.clear();
  2119. }
  2120. },
  2121. /**
  2122. * @return {?}
  2123. */
  2124. getFlushSize : function() {
  2125. return this._data.length;
  2126. },
  2127. /**
  2128. * @param {Object} name
  2129. * @param {boolean} expectedNumberOfNonCommentArgs
  2130. * @return {undefined}
  2131. */
  2132. append : function(name, expectedNumberOfNonCommentArgs) {
  2133. self.mergeArrays(this._data, name);
  2134. this._saveToStorageThrottled();
  2135. if (this.active) {
  2136. if (expectedNumberOfNonCommentArgs || this.getFlushSize() >= this.maxBufferSize) {
  2137. this._flush();
  2138. }
  2139. if (!this._flushTID) {
  2140. this._flushTID = self.defer(this._flush, this.flushTimeout, this, [], "DataBuffer._flush");
  2141. }
  2142. }
  2143. },
  2144. /**
  2145. * @return {undefined}
  2146. */
  2147. activate : function() {
  2148. if (!this.active) {
  2149. /** @type {boolean} */
  2150. this.active = true;
  2151. this.append([]);
  2152. }
  2153. },
  2154. /**
  2155. * @return {undefined}
  2156. */
  2157. clear : function() {
  2158. /** @type {number} */
  2159. this._data.length = 0;
  2160. /** @type {null} */
  2161. this._flushTID = null;
  2162. if (this.storage) {
  2163. this.storage.remove(this.storageKey);
  2164. }
  2165. },
  2166. /**
  2167. * @return {undefined}
  2168. */
  2169. _flush : function() {
  2170. this.onFlush.call(this.onFlushCtx || this, this._data, this.meta, this._packetNumber);
  2171. this._packetNumber++;
  2172. this.clear();
  2173. },
  2174. /**
  2175. * @return {undefined}
  2176. */
  2177. _saveToStorage : function() {
  2178. if (this.storage) {
  2179. if (this._data.length) {
  2180. this.storage.set(this.storageKey, {
  2181. data : this._data,
  2182. meta : this.meta,
  2183. pnum : this._packetNumber,
  2184. time : +new Date
  2185. });
  2186. }
  2187. }
  2188. }
  2189. });
  2190. var s3 = $.inherit({
  2191. transports : [],
  2192. postParams : [],
  2193. dontSendRequests : false,
  2194. /**
  2195. * @param {string} message
  2196. * @param {Object} data
  2197. * @param {Function} callback
  2198. * @param {?} scope
  2199. * @return {undefined}
  2200. */
  2201. send : function(message, data, callback, scope) {
  2202. callback = callback || function() {
  2203. };
  2204. if (this.dontSendRequests) {
  2205. callback.call(scope);
  2206. } else {
  2207. (function ready(index) {
  2208. var context;
  2209. if (index < this.transports.length) {
  2210. try {
  2211. context = new this.transports[index]({
  2212. postParams : this.postParams
  2213. });
  2214. context.request(message, data, function(dataAndEvents, operation, el) {
  2215. if (dataAndEvents) {
  2216. callback.call(scope, operation, el);
  2217. } else {
  2218. ready.call(this, index + 1);
  2219. }
  2220. }, this);
  2221. } catch (err) {
  2222. callback(err, "send by " + (context && context.id));
  2223. ready.call(this, index + 1);
  2224. }
  2225. }
  2226. }).call(this, 0);
  2227. }
  2228. }
  2229. });
  2230. var store = {
  2231. /**
  2232. * @param {Object} obj
  2233. * @return {?}
  2234. */
  2235. stringify : function(obj) {
  2236. /** @type {Array} */
  2237. var tagNameArr = [];
  2238. var key;
  2239. var value;
  2240. var j;
  2241. for (key in obj) {
  2242. if (obj.hasOwnProperty(key)) {
  2243. if (value = obj[key], self.isArray(value)) {
  2244. /** @type {number} */
  2245. j = 0;
  2246. for (;j < value.length;j++) {
  2247. tagNameArr.push(encodeURIComponent(key) + "=" + encodeURIComponent(String(value[j])));
  2248. }
  2249. } else {
  2250. tagNameArr.push(encodeURIComponent(key) + "=" + encodeURIComponent(String(value)));
  2251. }
  2252. }
  2253. }
  2254. return tagNameArr.join("&");
  2255. }
  2256. };
  2257. /**
  2258. * @param {Object} object
  2259. * @param {Function} callback
  2260. * @param {?} opt_scope
  2261. * @return {undefined}
  2262. */
  2263. self.forEachKey = function(object, callback, opt_scope) {
  2264. var key;
  2265. for (key in object) {
  2266. if (object.hasOwnProperty(key)) {
  2267. callback.call(opt_scope, key, object[key], object);
  2268. }
  2269. }
  2270. };
  2271. /**
  2272. * @param {Array} a
  2273. * @param {?} item
  2274. * @return {?}
  2275. */
  2276. self.inArray = function(a, item) {
  2277. var i;
  2278. /** @type {number} */
  2279. i = 0;
  2280. for (;i < a.length;i++) {
  2281. if (a[i] == item) {
  2282. return true;
  2283. }
  2284. }
  2285. return false;
  2286. };
  2287. var request = $.inherit({
  2288. postParams : [],
  2289. /**
  2290. * @param {string} url
  2291. * @param {Object} context
  2292. * @return {?}
  2293. */
  2294. _buildUrl : function(url, context) {
  2295. var key = store.stringify(context);
  2296. return url + (-1 < url.indexOf("?") ? "&" : key ? "?" : "") + key;
  2297. },
  2298. /**
  2299. * @param {Object} m
  2300. * @return {?}
  2301. */
  2302. _splitParams : function(m) {
  2303. var flags = {};
  2304. var cache = {};
  2305. self.forEachKey(m, function(k, value) {
  2306. if (self.inArray(this.postParams, k)) {
  2307. cache[k] = value;
  2308. } else {
  2309. flags[k] = value;
  2310. }
  2311. }, this);
  2312. return{
  2313. get : flags,
  2314. post : cache
  2315. };
  2316. }
  2317. });
  2318. var options = request.inherit({
  2319. id : "XHR",
  2320. method : "POST",
  2321. withCredentials : true,
  2322. /**
  2323. * @param {string} url
  2324. * @param {Object} data
  2325. * @param {Function} callback
  2326. * @param {?} scope
  2327. * @return {?}
  2328. */
  2329. request : function(url, data, callback, scope) {
  2330. var line;
  2331. var xhr;
  2332. 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])))) {
  2333. return callback.call(scope, false);
  2334. }
  2335. if (win.XMLHttpRequest && (xhr = new XMLHttpRequest, "withCredentials" in xhr)) {
  2336. data = this._splitParams(data);
  2337. url = this._buildUrl(url, data.get);
  2338. try {
  2339. xhr.open(this.method, url, true);
  2340. } catch (l) {
  2341. return callback.call(scope, false);
  2342. }
  2343. xhr.withCredentials = this.withCredentials;
  2344. this._setHeaders(xhr);
  2345. xhr.send(this._preparePostParams(data));
  2346. /**
  2347. * @return {undefined}
  2348. */
  2349. xhr.onreadystatechange = function() {
  2350. if (4 == xhr.readyState) {
  2351. callback.call(scope, 200 == xhr.status, xhr.responseText);
  2352. }
  2353. };
  2354. return;
  2355. }
  2356. callback.call(scope, false);
  2357. },
  2358. /**
  2359. * @param {Function} method
  2360. * @return {undefined}
  2361. */
  2362. setMethod : function(method) {
  2363. /** @type {Function} */
  2364. this.method = method;
  2365. },
  2366. /**
  2367. * @param {Object} data
  2368. * @return {?}
  2369. */
  2370. _preparePostParams : function(data) {
  2371. return store.stringify(data.post);
  2372. },
  2373. /**
  2374. * @param {Object} xhr
  2375. * @return {undefined}
  2376. */
  2377. _setHeaders : function(xhr) {
  2378. xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  2379. }
  2380. });
  2381. /**
  2382. * @param {number} min
  2383. * @param {number} max
  2384. * @return {?}
  2385. */
  2386. self.random = function(min, max) {
  2387. if (2 > arguments.length) {
  2388. /** @type {number} */
  2389. max = min;
  2390. /** @type {number} */
  2391. min = 0;
  2392. }
  2393. if (1 > arguments.length) {
  2394. /** @type {number} */
  2395. max = 1073741824;
  2396. }
  2397. return Math.floor(Math.random() * (max - min)) + min;
  2398. };
  2399. var Model = request.inherit({
  2400. id : "form",
  2401. enctype : "application/x-www-form-urlencoded",
  2402. htmlfileOnly : false,
  2403. /**
  2404. * @return {undefined}
  2405. */
  2406. _initComponent : function() {
  2407. Model.superclass._initComponent.apply(this, arguments);
  2408. if (!("_htmlfile" in Model.prototype)) {
  2409. Model.prototype._htmlfile = this._createHtmlfile();
  2410. }
  2411. this._doc = this._htmlfile || (this.htmlfileOnly ? null : doc);
  2412. },
  2413. /**
  2414. * @param {string} url
  2415. * @param {Object} config
  2416. * @param {Function} callback
  2417. * @param {?} scope
  2418. * @return {?}
  2419. */
  2420. request : function(url, config, callback, scope) {
  2421. var doc = this._doc;
  2422. var wordLength;
  2423. var d;
  2424. var previous;
  2425. var data;
  2426. if (!doc) {
  2427. return callback.call(scope, false);
  2428. }
  2429. config = this._splitParams(config);
  2430. /** @type {string} */
  2431. wordLength = "ifr" + self.random();
  2432. d = doc.createElement("div");
  2433. /** @type {string} */
  2434. d.style.position = "absolute";
  2435. /** @type {string} */
  2436. d.style.left = "-99999px";
  2437. /** @type {string} */
  2438. d.style.top = "-99999px";
  2439. /** @type {Array} */
  2440. previous = ['<iframe name="', wordLength, '"></iframe>', '<form action="', this._buildUrl(url, config.get), '" method="post" target="', wordLength, '" enctype="', this.enctype, '">'];
  2441. self.forEachKey(config.post, function(res) {
  2442. self.mergeArrays(previous, ['<input type="hidden" autocomplete="off" autocorrect="off"', ' autocapitalize="off" spellcheck="false" name="', res, '"/>']);
  2443. });
  2444. self.mergeArrays(previous, ["</form>"]);
  2445. /** @type {string} */
  2446. d.innerHTML = previous.join("");
  2447. doc.body.appendChild(d);
  2448. data = d.getElementsByTagName("form")[0];
  2449. self.forEachKey(config.post, function(option, intensity) {
  2450. data[option].value = intensity;
  2451. });
  2452. data.submit();
  2453. self.setTimeout(function() {
  2454. doc.body.removeChild(d);
  2455. }, 1E4, "TransportForm.request.2");
  2456. return callback.call(scope, true);
  2457. },
  2458. /**
  2459. * @return {?}
  2460. */
  2461. _createHtmlfile : function() {
  2462. var doc;
  2463. try {
  2464. if (win.ActiveXObject) {
  2465. return doc = new ActiveXObject("htmlfile"), doc.open(), doc.write("<html><body></body></html>"), doc.close(), doc;
  2466. }
  2467. } catch (b) {
  2468. }
  2469. return null;
  2470. }
  2471. });
  2472. var vb = Model.inherit({
  2473. id : "htmlfile",
  2474. htmlfileOnly : true
  2475. });
  2476. var Browser = request.inherit({
  2477. id : "img",
  2478. /**
  2479. * @param {string} url
  2480. * @param {Object} context
  2481. * @param {Function} callback
  2482. * @param {?} scope
  2483. * @return {undefined}
  2484. */
  2485. request : function(url, context, callback, scope) {
  2486. url = this._buildUrl(url, context);
  2487. /** @type {Element} */
  2488. context = doc.createElement("img");
  2489. callback = callback || function() {
  2490. };
  2491. context.onload = bind(function() {
  2492. callback.call(scope, true);
  2493. }, "TransportImage.request");
  2494. context.onerror = bind(function() {
  2495. callback.call(scope, false);
  2496. }, "TransportImage.request");
  2497. /** @type {string} */
  2498. context.src = url;
  2499. }
  2500. });
  2501. var JSON = {
  2502. /**
  2503. * @param {Object} obj
  2504. * @return {?}
  2505. */
  2506. stringify : function(obj) {
  2507. try {
  2508. return JSON.stringify(obj);
  2509. } catch (b) {
  2510. return "null";
  2511. }
  2512. }
  2513. };
  2514. /**
  2515. * @param {Object} object
  2516. * @return {?}
  2517. */
  2518. self.toJSON = function(object) {
  2519. var klass;
  2520. var property;
  2521. var length;
  2522. if (object === value) {
  2523. return "";
  2524. }
  2525. if (null === object) {
  2526. return "null";
  2527. }
  2528. switch(object.constructor) {
  2529. case Boolean:
  2530. return object.toString();
  2531. case Number:
  2532. return isFinite(object) ? object.toString() : "null";
  2533. case String:
  2534. return'"' + object.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\n/g, "\\n").replace(/\r/g, "\\r") + '"';
  2535. case Array:
  2536. /** @type {Array} */
  2537. klass = [];
  2538. /** @type {number} */
  2539. property = 0;
  2540. length = object.length;
  2541. for (;property < length;property++) {
  2542. klass[klass.length] = self.toJSON(object[property]);
  2543. }
  2544. return "[" + klass.join(",") + "]";
  2545. case Object:
  2546. /** @type {Array} */
  2547. klass = [];
  2548. for (property in object) {
  2549. if (object.hasOwnProperty(property)) {
  2550. if (object[property] !== value) {
  2551. /** @type {string} */
  2552. klass[klass.length] = self.toJSON(property) + ":" + self.toJSON(object[property]);
  2553. }
  2554. }
  2555. }
  2556. return "{" + klass.join(",") + "}";
  2557. default:
  2558. JSON.stringify(object);
  2559. }
  2560. };
  2561. var Node = $.inherit({
  2562. counterId : "",
  2563. /**
  2564. * @return {undefined}
  2565. */
  2566. _initComponent : function() {
  2567. Node.superclass._initComponent.apply(this, arguments);
  2568. /** @type {null} */
  2569. this._ls = null;
  2570. try {
  2571. /** @type {(Storage|null)} */
  2572. this._ls = win.localStorage;
  2573. } catch (a) {
  2574. }
  2575. },
  2576. /**
  2577. * @param {string} key
  2578. * @param {string} value
  2579. * @return {undefined}
  2580. */
  2581. set : function(key, value) {
  2582. if (this.isEnabled()) {
  2583. try {
  2584. if (!value || value && (self.isArray(value) && !value.length)) {
  2585. this.remove(key);
  2586. } else {
  2587. this._ls.setItem(this._getLsKey(key), self.toJSON(value));
  2588. }
  2589. } catch (c) {
  2590. }
  2591. }
  2592. },
  2593. /**
  2594. * @param {string} key
  2595. * @return {?}
  2596. */
  2597. get : function(key) {
  2598. if (this.isEnabled()) {
  2599. try {
  2600. return JSON.parse(this._ls.getItem(this._getLsKey(key)));
  2601. } catch (b) {
  2602. }
  2603. }
  2604. return null;
  2605. },
  2606. /**
  2607. * @param {string} key
  2608. * @return {undefined}
  2609. */
  2610. remove : function(key) {
  2611. if (this.isEnabled()) {
  2612. try {
  2613. this._ls.removeItem(this._getLsKey(key));
  2614. } catch (b) {
  2615. }
  2616. }
  2617. },
  2618. /**
  2619. * @return {?}
  2620. */
  2621. isEnabled : function() {
  2622. return this._ls && (win.JSON && ("object" == typeof this._ls && "object" == typeof win.JSON));
  2623. },
  2624. /**
  2625. * @return {?}
  2626. */
  2627. getStorageId : function() {
  2628. var caption = this.get("lsid");
  2629. if (!caption) {
  2630. /** @type {number} */
  2631. caption = Math.round(Math.random() * new Date);
  2632. this.set("lsid", caption);
  2633. }
  2634. return caption;
  2635. },
  2636. /**
  2637. * @return {undefined}
  2638. */
  2639. clearStorageId : function() {
  2640. this.remove("lsid");
  2641. },
  2642. /**
  2643. * @param {string} keepData
  2644. * @return {?}
  2645. */
  2646. _getLsKey : function(keepData) {
  2647. return "_ym" + this.counterId + "_" + keepData;
  2648. }
  2649. });
  2650. var Controller = $.inherit({
  2651. counterId : "",
  2652. onlyCurrentDomain : false,
  2653. skipPrefix : false,
  2654. /**
  2655. * @return {undefined}
  2656. */
  2657. _initComponent : function() {
  2658. var word;
  2659. var i;
  2660. Controller.superclass._initComponent.apply(this, arguments);
  2661. /** @type {null} */
  2662. this._domain = null;
  2663. if (!this.onlyCurrentDomain) {
  2664. word = params.host.split(".");
  2665. /** @type {number} */
  2666. i = 2;
  2667. for (;;) {
  2668. if (i <= word.length) {
  2669. if (this._domain = "." + word.slice(-i).join("."), i++, this.isEnabled()) {
  2670. break;
  2671. }
  2672. } else {
  2673. /** @type {null} */
  2674. this._domain = null;
  2675. break;
  2676. }
  2677. }
  2678. }
  2679. },
  2680. /**
  2681. * @param {(Array|string)} id
  2682. * @param {Object} value
  2683. * @param {number} opt_attributes
  2684. * @return {undefined}
  2685. */
  2686. create : function(id, value, opt_attributes) {
  2687. /** @type {Array} */
  2688. id = [this._prepareName(id) + "=" + encodeURIComponent(value)];
  2689. if (opt_attributes) {
  2690. /** @type {Date} */
  2691. value = new Date;
  2692. value.setTime(value.getTime() + 6E4 * opt_attributes);
  2693. id.push("expires=" + value.toGMTString());
  2694. }
  2695. if (this._domain) {
  2696. id.push("domain=" + this._domain);
  2697. }
  2698. id.push("path=/");
  2699. try {
  2700. /** @type {string} */
  2701. doc.cookie = id.join(";");
  2702. } catch (d) {
  2703. }
  2704. },
  2705. /**
  2706. * @param {string} name
  2707. * @return {?}
  2708. */
  2709. read : function(name) {
  2710. var sel;
  2711. try {
  2712. /** @type {string} */
  2713. sel = doc.cookie;
  2714. } catch (c) {
  2715. }
  2716. return sel && sel.match(new RegExp("(?:^|;\\s*)" + this._prepareName(name) + "=([^;]*)")) ? decodeURIComponent(RegExp.$1) : null;
  2717. },
  2718. /**
  2719. * @param {string} item
  2720. * @return {undefined}
  2721. */
  2722. erase : function(item) {
  2723. this.create(item, "", -1);
  2724. },
  2725. /**
  2726. * @return {?}
  2727. */
  2728. isEnabled : function() {
  2729. var enabled;
  2730. this.create("metrika_enabled", "1", 60);
  2731. /** @type {boolean} */
  2732. enabled = !!this.read("metrika_enabled");
  2733. this.erase("metrika_enabled");
  2734. return enabled;
  2735. },
  2736. /**
  2737. * @param {string} name
  2738. * @return {?}
  2739. */
  2740. _prepareName : function(name) {
  2741. return(this.skipPrefix ? "" : "_ym_") + name + (this.counterId ? "_" + this.counterId : "");
  2742. }
  2743. });
  2744. /**
  2745. * @return {?}
  2746. */
  2747. Controller.isEnabled = function() {
  2748. return(new Controller({
  2749. onlyCurrentDomain : true
  2750. })).isEnabled();
  2751. };
  2752. var instance = s3.inherit({
  2753. protocol : "",
  2754. host : "mc.yandex.ru",
  2755. resource : "",
  2756. counterId : "",
  2757. counterType : 0,
  2758. retry : false,
  2759. transports : [options, Browser, vb],
  2760. /**
  2761. * @return {undefined}
  2762. */
  2763. _initComponent : function() {
  2764. instance.superclass._initComponent.apply(this, arguments);
  2765. if (this.retry) {
  2766. this._storage = new Node;
  2767. }
  2768. },
  2769. /**
  2770. * @param {Object} data
  2771. * @param {number} opt_data
  2772. * @param {Function} serviceName
  2773. * @param {?} service
  2774. * @return {undefined}
  2775. */
  2776. send : function(data, opt_data, serviceName, service) {
  2777. var newState = this._registerRequest(data, opt_data);
  2778. this._sendSavedRequest(newState, data, opt_data, serviceName, service);
  2779. },
  2780. /**
  2781. * @param {string} expr
  2782. * @param {Object} d
  2783. * @param {Object} data
  2784. * @param {Function} matcherFunction
  2785. * @param {?} service
  2786. * @return {?}
  2787. */
  2788. _sendSavedRequest : function(expr, d, data, matcherFunction, service) {
  2789. var arg = win.Ya._metrika.firstReqStatus;
  2790. var _ref;
  2791. var previous;
  2792. if ("process" == arg) {
  2793. win.Ya._metrika.firstReqCallbacks = self.mergeArrays(win.Ya._metrika.firstReqCallbacks || [], [[this, arguments]]);
  2794. } else {
  2795. 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) {
  2796. if ("t" != params) {
  2797. self.mergeArrays(previous, [params, status]);
  2798. }
  2799. }), data.t && self.mergeArrays(previous, ["t", data.t])), previous.length && (arg["browser-info"] = previous.join(":")), instance.superclass.send.call(this, _ref, arg, function() {
  2800. var codeSegments;
  2801. var i;
  2802. /** @type {string} */
  2803. win.Ya._metrika.firstReqStatus = "complete";
  2804. this._unregisterRequest(expr);
  2805. codeSegments = win.Ya._metrika.firstReqCallbacks;
  2806. /** @type {null} */
  2807. win.Ya._metrika.firstReqCallbacks = null;
  2808. if (codeSegments) {
  2809. /** @type {number} */
  2810. i = 0;
  2811. for (;i < codeSegments.length;i++) {
  2812. codeSegments[i][0]._sendSavedRequest.apply(codeSegments[i][0], codeSegments[i][1]);
  2813. }
  2814. }
  2815. if (matcherFunction) {
  2816. matcherFunction.apply(service, arguments);
  2817. }
  2818. }, this);
  2819. }
  2820. },
  2821. /**
  2822. * @return {?}
  2823. */
  2824. _isRetryEnabled : function() {
  2825. return this.retry && (this._storage && this._storage.isEnabled());
  2826. },
  2827. /**
  2828. * @param {Object} data
  2829. * @param {number} opt_noCache
  2830. * @return {?}
  2831. */
  2832. _registerRequest : function(data, opt_noCache) {
  2833. var pdataOld;
  2834. var resource;
  2835. if (this._isRetryEnabled()) {
  2836. opt_noCache.rqnl = opt_noCache.rqnl || 0;
  2837. opt_noCache.rqnl++;
  2838. pdataOld = this._storage.get("retryReqs") || {};
  2839. /** @type {number} */
  2840. resource = 1;
  2841. for (;pdataOld[resource];) {
  2842. resource++;
  2843. }
  2844. pdataOld[resource] = {
  2845. protocol : this.protocol,
  2846. host : this.host,
  2847. resource : this.resource,
  2848. counterId : this.counterId,
  2849. counterType : this.counterType,
  2850. postParams : this.postParams,
  2851. params : data,
  2852. browserInfo : opt_noCache,
  2853. ghid : Ya._globalMetrikaHitId,
  2854. time : +new Date
  2855. };
  2856. this._storage.set("retryReqs", pdataOld);
  2857. return resource;
  2858. }
  2859. },
  2860. /**
  2861. * @param {string} key
  2862. * @return {undefined}
  2863. */
  2864. _unregisterRequest : function(key) {
  2865. var pdataOld;
  2866. if (key) {
  2867. if (this._isRetryEnabled()) {
  2868. pdataOld = this._storage.get("retryReqs") || {};
  2869. if (pdataOld[key]) {
  2870. delete pdataOld[key];
  2871. this._storage.set("retryReqs", pdataOld);
  2872. }
  2873. }
  2874. }
  2875. },
  2876. _getVersion : bind(function() {
  2877. return v;
  2878. }, "", true)
  2879. });
  2880. /**
  2881. * @return {undefined}
  2882. */
  2883. instance.initCookie = function() {
  2884. var utils = new Controller;
  2885. var index = utils.read("uid");
  2886. if (!index) {
  2887. /** @type {number} */
  2888. index = Math.round((new Date).getTime() / 1E3);
  2889. /** @type {string} */
  2890. index = index + "" + self.random();
  2891. utils.create("uid", index, 1036800);
  2892. }
  2893. instance._userID = index;
  2894. };
  2895. /**
  2896. * @return {undefined}
  2897. */
  2898. instance.retransmit = function() {
  2899. var control = new Node;
  2900. var which = control.get("retryReqs") || {};
  2901. var res;
  2902. control.remove("retryReqs");
  2903. self.forEachKey(which, function(dataAndEvents, req) {
  2904. if (!win.Ya._metrika.firstReqStatus) {
  2905. /** @type {string} */
  2906. win.Ya._metrika.firstReqStatus = "complete";
  2907. }
  2908. if (req.ghid) {
  2909. if (req.ghid != Ya._globalMetrikaHitId) {
  2910. if (req.time) {
  2911. if (req.time + 864E5 > +new Date) {
  2912. if (2 >= req.browserInfo.rqnl) {
  2913. res = new instance({
  2914. protocol : req.protocol,
  2915. host : req.host,
  2916. resource : req.resource,
  2917. counterId : req.counterId,
  2918. counterType : req.counterType,
  2919. postParams : req.postParams || [],
  2920. retry : true
  2921. });
  2922. res.send(req.params, req.browserInfo);
  2923. }
  2924. }
  2925. }
  2926. }
  2927. }
  2928. });
  2929. };
  2930. /**
  2931. * @param {string} data
  2932. * @return {?}
  2933. */
  2934. self.fletcher = function(data) {
  2935. var b = data.length;
  2936. /** @type {number} */
  2937. var i = 0;
  2938. /** @type {number} */
  2939. var buf = 255;
  2940. /** @type {number} */
  2941. var optsData = 255;
  2942. var a;
  2943. var c;
  2944. var encodedLenType;
  2945. for (;b;) {
  2946. a = 21 < b ? 21 : b;
  2947. b -= a;
  2948. do {
  2949. c = "string" == typeof data ? data.charCodeAt(i) : data[i];
  2950. i++;
  2951. if (255 < c) {
  2952. /** @type {number} */
  2953. encodedLenType = c >> 8;
  2954. c &= 255;
  2955. c ^= encodedLenType;
  2956. }
  2957. buf += c;
  2958. optsData += buf;
  2959. } while (--a);
  2960. /** @type {number} */
  2961. buf = (buf & 255) + (buf >> 8);
  2962. /** @type {number} */
  2963. optsData = (optsData & 255) + (optsData >> 8);
  2964. }
  2965. /** @type {number} */
  2966. data = (buf & 255) + (buf >> 8) << 8 | (optsData & 255) + (optsData >> 8);
  2967. return 65535 == data ? 0 : data;
  2968. };
  2969. var exports = {
  2970. abc : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
  2971. tail : "+/=",
  2972. tailSafe : "*-_",
  2973. /**
  2974. * @param {Array} data
  2975. * @param {boolean} dataAndEvents
  2976. * @return {?}
  2977. */
  2978. encode : function(data, dataAndEvents) {
  2979. /** @type {Array.<string>} */
  2980. var arr = (exports.abc + (dataAndEvents ? exports.tailSafe : exports.tail)).split("");
  2981. var length = data.length;
  2982. /** @type {Array} */
  2983. var previous = [];
  2984. /** @type {number} */
  2985. var j = length - length % 3;
  2986. var c;
  2987. var i;
  2988. /** @type {number} */
  2989. i = 0;
  2990. for (;i < j;i += 3) {
  2991. c = (data[i] << 16) + (data[i + 1] << 8) + data[i + 2];
  2992. self.mergeArrays(previous, [arr[c >> 18 & 63], arr[c >> 12 & 63], arr[c >> 6 & 63], arr[c & 63]]);
  2993. }
  2994. switch(length - j) {
  2995. case 1:
  2996. /** @type {number} */
  2997. c = data[j] << 4;
  2998. self.mergeArrays(previous, [arr[c >> 6 & 63], arr[c & 63], arr[64], arr[64]]);
  2999. break;
  3000. case 2:
  3001. /** @type {number} */
  3002. c = (data[j] << 10) + (data[j + 1] << 2);
  3003. self.mergeArrays(previous, [arr[c >> 12 & 63], arr[c >> 6 & 63], arr[c & 63], arr[64]]);
  3004. }
  3005. return previous.join("");
  3006. }
  3007. };
  3008. /**
  3009. * @param {string} str
  3010. * @param {number} length
  3011. * @return {?}
  3012. */
  3013. self.trim = function(str, length) {
  3014. /** @type {string} */
  3015. str = String(str).replace(/^\s+|\s+$/g, "");
  3016. if (length) {
  3017. if (str.length > length) {
  3018. /** @type {string} */
  3019. str = str.substr(0, length);
  3020. }
  3021. }
  3022. return str;
  3023. };
  3024. /**
  3025. * @param {?} f
  3026. * @return {?}
  3027. */
  3028. self.isFunction = function(f) {
  3029. return "function" === typeof f;
  3030. };
  3031. /**
  3032. * @param {?} target
  3033. * @return {?}
  3034. */
  3035. self.isString = function(target) {
  3036. return "[object String]" == Object.prototype.toString.call(target);
  3037. };
  3038. /**
  3039. * @param {Array} a
  3040. * @param {string} keepData
  3041. * @return {?}
  3042. */
  3043. self.arrayIndexOf = function(a, keepData) {
  3044. var i;
  3045. /** @type {number} */
  3046. i = 0;
  3047. for (;i < a.length;i++) {
  3048. if (a[i] === keepData) {
  3049. return i;
  3050. }
  3051. }
  3052. return-1;
  3053. };
  3054. /** @type {RegExp} */
  3055. self._playerRegexp = /^.+\.mtproxy\.yandex\.net$/;
  3056. /**
  3057. * @return {?}
  3058. */
  3059. self.isMetrikaPlayer = function() {
  3060. return "MetrikaPlayer" == win.name || this._playerRegexp.test(win.location.hostname);
  3061. };
  3062. var dom = {
  3063. /**
  3064. * @return {?}
  3065. */
  3066. getDocumentCharset : function() {
  3067. return("" + (doc.characterSet || (doc.charset || ""))).toLowerCase();
  3068. },
  3069. /**
  3070. * @return {?}
  3071. */
  3072. getRootElement : function() {
  3073. /** @type {Element} */
  3074. var head = doc.documentElement;
  3075. return "CSS1Compat" == doc.compatMode ? head : doc.body || head;
  3076. },
  3077. /**
  3078. * @return {?}
  3079. */
  3080. getViewportSize : function() {
  3081. var container = dom.getRootElement();
  3082. return[container.clientWidth || win.innerWidth, container.clientHeight || win.innerHeight];
  3083. },
  3084. /**
  3085. * @return {?}
  3086. */
  3087. getDocumentTitle : function() {
  3088. /** @type {string} */
  3089. var elem = doc.title;
  3090. if ("string" != typeof elem) {
  3091. elem = (elem = doc.getElementsByTagName("title")) && elem.length ? elem[0].innerHTML : "";
  3092. }
  3093. return elem;
  3094. }
  3095. };
  3096. var data = {
  3097. _silverlightVersion : "",
  3098. /**
  3099. * @return {?}
  3100. */
  3101. getSilverlightVersion : function() {
  3102. var config;
  3103. var callback;
  3104. var udataCur;
  3105. var typePattern;
  3106. if (!data._silverlightVersion) {
  3107. if (win.ActiveXObject) {
  3108. try {
  3109. udataCur = new ActiveXObject("AgControl.AgControl");
  3110. /**
  3111. * @param {?} value
  3112. * @param {Array} args
  3113. * @param {number} desiredNonCommentArgIndex
  3114. * @param {number} expectedNumberOfNonCommentArgs
  3115. * @return {undefined}
  3116. */
  3117. config = function(value, args, desiredNonCommentArgIndex, expectedNumberOfNonCommentArgs) {
  3118. for (;callback(value, args);) {
  3119. args[desiredNonCommentArgIndex] += expectedNumberOfNonCommentArgs;
  3120. }
  3121. args[desiredNonCommentArgIndex] -= expectedNumberOfNonCommentArgs;
  3122. };
  3123. /**
  3124. * @param {?} success
  3125. * @param {Array} _
  3126. * @return {?}
  3127. */
  3128. callback = function(success, _) {
  3129. return success.isVersionSupported(_[0] + "." + _[1] + "." + _[2] + "." + _[3]);
  3130. };
  3131. /** @type {Array} */
  3132. typePattern = [1, 0, 0, 0];
  3133. config(udataCur, typePattern, 0, 1);
  3134. config(udataCur, typePattern, 1, 1);
  3135. config(udataCur, typePattern, 2, 1E4);
  3136. config(udataCur, typePattern, 2, 1E3);
  3137. config(udataCur, typePattern, 2, 100);
  3138. config(udataCur, typePattern, 2, 10);
  3139. config(udataCur, typePattern, 2, 1);
  3140. config(udataCur, typePattern, 3, 1);
  3141. /** @type {string} */
  3142. data._silverlightVersion = typePattern.join(".");
  3143. } catch (e) {
  3144. }
  3145. } else {
  3146. if (config = win.navigator, config = config.plugins && config.plugins["Silverlight Plug-In"]) {
  3147. data._silverlightVersion = config.description;
  3148. }
  3149. }
  3150. }
  3151. return data._silverlightVersion || "";
  3152. },
  3153. _flashVersion : 0,
  3154. /**
  3155. * @return {?}
  3156. */
  3157. getFlashVersion : function() {
  3158. var config;
  3159. var v;
  3160. var flash;
  3161. if (!data._flashVersion) {
  3162. if (config = win.navigator, "undefined" != typeof config.plugins && "object" == typeof config.plugins["Shockwave Flash"]) {
  3163. if (v = config.plugins["Shockwave Flash"], flash = v.version, (v = v.description) || flash) {
  3164. if (config = config.mimeTypes, "undefined" == typeof config || (!config["application/x-shockwave-flash"] || config["application/x-shockwave-flash"].enabledPlugin)) {
  3165. if (flash) {
  3166. data._flashVersion = flash;
  3167. } else {
  3168. if (v) {
  3169. data._flashVersion = v.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".");
  3170. }
  3171. }
  3172. }
  3173. }
  3174. } else {
  3175. if ("undefined" != typeof win.ActiveXObject) {
  3176. try {
  3177. if (flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"), v = flash.GetVariable("$version")) {
  3178. data._flashVersion = v.split(" ")[1].replace(/,/g, ".").replace(/[^.\d]/g, "");
  3179. }
  3180. } catch (d) {
  3181. }
  3182. }
  3183. }
  3184. }
  3185. return data._flashVersion;
  3186. },
  3187. /**
  3188. * @return {?}
  3189. */
  3190. getLanguage : function() {
  3191. return(win.navigator ? navigator.language || (navigator.userLanguage || (navigator.browserLanguage || navigator.systemLanguage)) : "").toLowerCase();
  3192. },
  3193. /**
  3194. * @return {?}
  3195. */
  3196. getJavaEnabled : function() {
  3197. try {
  3198. return navigator.javaEnabled();
  3199. } catch (a) {
  3200. return false;
  3201. }
  3202. }
  3203. };
  3204. /**
  3205. * @param {string} object
  3206. * @return {?}
  3207. */
  3208. self.fnv32a = function(object) {
  3209. /** @type {number} */
  3210. var hint = 2166136261;
  3211. var i;
  3212. var length;
  3213. /** @type {number} */
  3214. i = 0;
  3215. length = object.length;
  3216. for (;i < length;++i) {
  3217. hint ^= object.charCodeAt(i);
  3218. hint += (hint << 1) + (hint << 4) + (hint << 7) + (hint << 8) + (hint << 24);
  3219. }
  3220. return hint >>> 0;
  3221. };
  3222. /**
  3223. * @return {?}
  3224. */
  3225. data.getFingerPrint = function() {
  3226. /** @type {Array} */
  3227. var previous = [];
  3228. var m;
  3229. var i;
  3230. if (navigator.plugins && navigator.plugins.length) {
  3231. /** @type {number} */
  3232. i = 0;
  3233. for (;i < navigator.plugins.length;i++) {
  3234. m = navigator.plugins[i];
  3235. self.mergeArrays(previous, [m.name, m.version, m.description, m.filename]);
  3236. }
  3237. }
  3238. if (navigator.mimeTypes && navigator.mimeTypes.length) {
  3239. /** @type {number} */
  3240. i = 0;
  3241. for (;i < navigator.mimeTypes.length;i++) {
  3242. m = navigator.mimeTypes[i];
  3243. self.mergeArrays(previous, [m.type, m.description, m.suffixes]);
  3244. }
  3245. }
  3246. return self.fnv32a(previous.join(";")) + "01";
  3247. };
  3248. /**
  3249. * @return {?}
  3250. */
  3251. data.getPlatform = function() {
  3252. /** @type {string} */
  3253. var ppath = "";
  3254. try {
  3255. /** @type {string} */
  3256. ppath = "" + navigator.platform;
  3257. } catch (b) {
  3258. }
  3259. return ppath;
  3260. };
  3261. /**
  3262. * @return {?}
  3263. */
  3264. data.getNotificationPermission = function() {
  3265. var permission;
  3266. try {
  3267. /** @type {string} */
  3268. permission = Notification.permission;
  3269. } catch (b) {
  3270. }
  3271. switch(permission) {
  3272. case "denied":
  3273. return 1;
  3274. case "granted":
  3275. return 2;
  3276. }
  3277. };
  3278. /**
  3279. * @return {?}
  3280. */
  3281. data.isIframe = function() {
  3282. try {
  3283. return win.top != win.self;
  3284. } catch (a) {
  3285. return false;
  3286. }
  3287. };
  3288. data._nMap = {
  3289. other : "0",
  3290. none : "1",
  3291. unknown : "2",
  3292. wifi : "3",
  3293. ethernet : "4",
  3294. bluetooth : "5",
  3295. cellular : "6",
  3296. wimax : "7",
  3297. mixed : "8"
  3298. };
  3299. /**
  3300. * @return {?}
  3301. */
  3302. data.netType = function() {
  3303. var s = (navigator.connection || {
  3304. type : ""
  3305. }).type;
  3306. return data._nMap[s] || s;
  3307. };
  3308. /**
  3309. * @return {?}
  3310. */
  3311. data.isSafari = function() {
  3312. try {
  3313. return navigator.vendor && (-1 < navigator.vendor.indexOf("Apple") && (navigator.userAgent && !navigator.userAgent.match("CriOS")));
  3314. } catch (a) {
  3315. }
  3316. return false;
  3317. };
  3318. /**
  3319. * @param {Object} node
  3320. * @return {undefined}
  3321. */
  3322. dom.removeNode = function(node) {
  3323. var p = node && node.parentNode;
  3324. if (p) {
  3325. p.removeChild(node);
  3326. }
  3327. };
  3328. var methods = {
  3329. url : "https://mc.yandex.ru/metrika/",
  3330. _value : null,
  3331. /**
  3332. * @return {undefined}
  3333. */
  3334. init : function() {
  3335. var udataCur = this._getLs().read("isad");
  3336. if (udataCur) {
  3337. this._set(udataCur);
  3338. } else {
  3339. if (!this._getReqStatus()) {
  3340. this._send();
  3341. }
  3342. }
  3343. },
  3344. /**
  3345. * @return {?}
  3346. */
  3347. getVal : function() {
  3348. return this._value;
  3349. },
  3350. /**
  3351. * @param {string} value
  3352. * @return {undefined}
  3353. */
  3354. _set : function(value) {
  3355. this._value = "1" == value || "2" == value ? value : null;
  3356. },
  3357. /**
  3358. * @return {undefined}
  3359. */
  3360. _send : function() {
  3361. /** @type {Element} */
  3362. var img = doc.createElement("img");
  3363. var _saveReq = this;
  3364. /**
  3365. * @return {undefined}
  3366. */
  3367. img.onload = function() {
  3368. _saveReq._saveReq(false);
  3369. dom.removeNode(this);
  3370. };
  3371. /**
  3372. * @return {undefined}
  3373. */
  3374. img.onerror = function() {
  3375. _saveReq._saveReq(true);
  3376. dom.removeNode(this);
  3377. };
  3378. this._setReqStatus("process");
  3379. /** @type {string} */
  3380. img.src = this.url + String.fromCharCode(97, 100, 118, 101, 114, 116, 46, 103, 105, 102);
  3381. if (data.isSafari()) {
  3382. /** @type {string} */
  3383. img.style.position = "absolute";
  3384. /** @type {string} */
  3385. img.style.visibility = "hidden";
  3386. /** @type {string} */
  3387. img.style.width = "0px";
  3388. /** @type {string} */
  3389. img.style.height = "0px";
  3390. dom.getRootElement().appendChild(img);
  3391. }
  3392. },
  3393. /**
  3394. * @param {boolean} isXML
  3395. * @return {undefined}
  3396. */
  3397. _saveReq : function(isXML) {
  3398. /** @type {string} */
  3399. this._value = isXML = isXML ? "1" : "2";
  3400. this._setReqStatus("complete");
  3401. this._getLs().create("isad", isXML, 1200);
  3402. },
  3403. /**
  3404. * @param {string} type
  3405. * @return {undefined}
  3406. */
  3407. _setReqStatus : function(type) {
  3408. try {
  3409. /** @type {string} */
  3410. win.Ya._metrika.adStatus = type;
  3411. } catch (b) {
  3412. }
  3413. },
  3414. /**
  3415. * @return {?}
  3416. */
  3417. _getReqStatus : function() {
  3418. try {
  3419. return win.Ya._metrika.adStatus;
  3420. } catch (a) {
  3421. return "complete";
  3422. }
  3423. },
  3424. /**
  3425. * @return {?}
  3426. */
  3427. _getLs : function() {
  3428. if (!this._ls) {
  3429. this._ls = new Controller;
  3430. }
  3431. return this._ls;
  3432. }
  3433. };
  3434. var Base64 = {
  3435. /**
  3436. * @param {string} input
  3437. * @return {?}
  3438. */
  3439. encode : function(input) {
  3440. /** @type {Array} */
  3441. var out = [];
  3442. var j;
  3443. var copies;
  3444. var jl;
  3445. /** @type {number} */
  3446. j = 0;
  3447. jl = input.length;
  3448. for (;j < jl;j++) {
  3449. copies = input.charCodeAt(j);
  3450. if (128 > copies) {
  3451. out.push(copies);
  3452. } else {
  3453. if (127 < copies && 2048 > copies) {
  3454. out.push(copies >> 6 | 192);
  3455. } else {
  3456. out.push(copies >> 12 | 224);
  3457. out.push(copies >> 6 & 63 | 128);
  3458. }
  3459. out.push(copies & 63 | 128);
  3460. }
  3461. }
  3462. return out;
  3463. },
  3464. /**
  3465. * @param {string} utftext
  3466. * @return {?}
  3467. */
  3468. decode : function(utftext) {
  3469. /** @type {string} */
  3470. var str = "";
  3471. /** @type {number} */
  3472. var i = 0;
  3473. var b;
  3474. var e;
  3475. var f;
  3476. for (;i < utftext.length;) {
  3477. b = utftext.charCodeAt(i);
  3478. if (128 > b) {
  3479. str += String.fromCharCode(b);
  3480. i++;
  3481. } else {
  3482. if (191 < b && 224 > b) {
  3483. e = utftext.charCodeAt(i + 1);
  3484. str += String.fromCharCode((b & 31) << 6 | e & 63);
  3485. i += 2;
  3486. } else {
  3487. e = utftext.charCodeAt(i + 1);
  3488. f = utftext.charCodeAt(i + 2);
  3489. str += String.fromCharCode((b & 15) << 12 | (e & 63) << 6 | f & 63);
  3490. i += 3;
  3491. }
  3492. }
  3493. }
  3494. return str;
  3495. }
  3496. };
  3497. /**
  3498. * @param {string} input
  3499. * @param {boolean} secure
  3500. * @return {?}
  3501. */
  3502. exports.decode = function(input, secure) {
  3503. /** @type {string} */
  3504. var excludes = exports.abc + (secure ? exports.tailSafe : exports.tail);
  3505. /** @type {number} */
  3506. var i = 0;
  3507. /** @type {string} */
  3508. var h = "";
  3509. var o1;
  3510. var o2;
  3511. var o3;
  3512. var number;
  3513. var auto;
  3514. for (;input.length % 4;) {
  3515. input += "=";
  3516. }
  3517. do {
  3518. /** @type {number} */
  3519. o1 = excludes.indexOf(input.charAt(i++));
  3520. /** @type {number} */
  3521. o2 = excludes.indexOf(input.charAt(i++));
  3522. /** @type {number} */
  3523. number = excludes.indexOf(input.charAt(i++));
  3524. /** @type {number} */
  3525. auto = excludes.indexOf(input.charAt(i++));
  3526. if (0 > o1 || (0 > o2 || (0 > number || 0 > auto))) {
  3527. return null;
  3528. }
  3529. /** @type {number} */
  3530. o3 = o1 << 18 | o2 << 12 | number << 6 | auto;
  3531. /** @type {number} */
  3532. o1 = o3 >> 16 & 255;
  3533. /** @type {number} */
  3534. o2 = o3 >> 8 & 255;
  3535. o3 &= 255;
  3536. /** @type {string} */
  3537. h = 64 == number ? h + String.fromCharCode(o1) : 64 == auto ? h + String.fromCharCode(o1, o2) : h + String.fromCharCode(o1, o2, o3);
  3538. } while (i < input.length);
  3539. return h;
  3540. };
  3541. var klass = instance.inherit({
  3542. hitId : 0,
  3543. trackHash : false,
  3544. trimParams : false,
  3545. webvisor : false,
  3546. counter : null,
  3547. counterNum : 0,
  3548. resource : "watch",
  3549. retry : true,
  3550. postParams : ["site-info"],
  3551. countersNoTitle : "22836271 1143050 29626870 9928105 26128362 29850769".split(" "),
  3552. fake : false,
  3553. sendTitle : true,
  3554. /**
  3555. * @return {undefined}
  3556. */
  3557. _initComponent : function() {
  3558. klass.superclass._initComponent.apply(this, arguments);
  3559. this._trackHash = this.trackHash;
  3560. if ("0" === "" + this.counterType) {
  3561. /** @type {boolean} */
  3562. this.sendTitle = -1 === self.arrayIndexOf(this.countersNoTitle, "" + this.counterId);
  3563. }
  3564. },
  3565. /**
  3566. * @param {boolean} edge
  3567. * @return {undefined}
  3568. */
  3569. setTrackHash : function(edge) {
  3570. /** @type {boolean} */
  3571. this._trackHash = edge;
  3572. },
  3573. /**
  3574. * @param {Object} options
  3575. * @return {undefined}
  3576. */
  3577. sendHit : function(options) {
  3578. this._hitExt({
  3579. url : options.url,
  3580. title : options.title,
  3581. referrer : options.referrer,
  3582. vParams : options.vParams,
  3583. modes : {
  3584. ar : true,
  3585. saveRef : true,
  3586. pv : true
  3587. },
  3588. callback : options.callback,
  3589. ctx : options.ctx
  3590. });
  3591. },
  3592. /**
  3593. * @param {Object} state
  3594. * @return {undefined}
  3595. */
  3596. sendExperiments : function(state) {
  3597. this._hitExt({
  3598. url : trigger().href,
  3599. title : "",
  3600. referrer : "",
  3601. modes : {
  3602. ex : true,
  3603. ar : true
  3604. },
  3605. experiments : state.experiments,
  3606. callback : state.callback,
  3607. ctx : state.ctx
  3608. });
  3609. },
  3610. /**
  3611. * @param {Object} doc
  3612. * @return {undefined}
  3613. */
  3614. sendPrerenderHit : function(doc) {
  3615. this._hitExt({
  3616. url : doc.url,
  3617. title : doc.title,
  3618. referrer : doc.referrer,
  3619. modes : {
  3620. ar : true,
  3621. pq : true
  3622. }
  3623. });
  3624. },
  3625. /**
  3626. * @param {Object} options
  3627. * @return {undefined}
  3628. */
  3629. sendAjaxHit : function(options) {
  3630. this._hitExt({
  3631. url : options.url,
  3632. title : options.title,
  3633. referrer : options.referrer,
  3634. modes : options.modes
  3635. });
  3636. },
  3637. /**
  3638. * @param {?} dataAndEvents
  3639. * @param {Function} callback
  3640. * @param {string} keepData
  3641. * @return {undefined}
  3642. */
  3643. sendParams : function(dataAndEvents, callback, keepData) {
  3644. this._hitExt({
  3645. url : trigger().href,
  3646. title : "",
  3647. referrer : "",
  3648. vParams : dataAndEvents,
  3649. modes : {
  3650. ar : true,
  3651. pa : true,
  3652. onlyData : true
  3653. },
  3654. /** @type {Function} */
  3655. callback : callback,
  3656. ctx : keepData
  3657. });
  3658. },
  3659. /**
  3660. * @param {boolean} url
  3661. * @param {Object} state
  3662. * @return {undefined}
  3663. */
  3664. sendGoal : function(url, state) {
  3665. var uri;
  3666. var MSG_CLOSURE_CUSTOM_COLOR_BUTTON;
  3667. var fileExt;
  3668. if (!/[\/&=?#]/.test(url)) {
  3669. uri = url ? "goal://" + trigger().hostname + "/" + encodeURIComponent(url) : trigger().href;
  3670. MSG_CLOSURE_CUSTOM_COLOR_BUTTON = dom.getDocumentTitle();
  3671. fileExt = url ? trigger().href : doc.referrer;
  3672. this._hitExt({
  3673. url : uri,
  3674. title : MSG_CLOSURE_CUSTOM_COLOR_BUTTON,
  3675. referrer : fileExt,
  3676. vParams : state.vParams,
  3677. modes : {
  3678. ar : true
  3679. },
  3680. callback : state.callback,
  3681. ctx : state.ctx
  3682. });
  3683. }
  3684. },
  3685. /**
  3686. * @param {Object} settings
  3687. * @return {undefined}
  3688. */
  3689. sendClickLink : function(settings) {
  3690. this._hitExt({
  3691. url : settings.url,
  3692. title : settings.title,
  3693. referrer : trigger().href,
  3694. modes : settings.modes
  3695. });
  3696. },
  3697. /**
  3698. * @param {Object} state
  3699. * @return {undefined}
  3700. */
  3701. sendExtLink : function(state) {
  3702. this._hitExt({
  3703. url : state.url,
  3704. title : state.title || "",
  3705. referrer : trigger().href,
  3706. vParams : state.vParams,
  3707. modes : {
  3708. ar : true,
  3709. ln : true,
  3710. ut : props
  3711. },
  3712. callback : state.callback,
  3713. ctx : state.ctx
  3714. });
  3715. },
  3716. /**
  3717. * @param {Object} state
  3718. * @return {undefined}
  3719. */
  3720. sendFileUpload : function(state) {
  3721. this._hitExt({
  3722. url : state.url,
  3723. title : state.title || "",
  3724. referrer : trigger().href,
  3725. vParams : state.vParams,
  3726. modes : {
  3727. ar : true,
  3728. ln : true,
  3729. dl : true
  3730. },
  3731. callback : state.callback,
  3732. ctx : state.ctx
  3733. });
  3734. },
  3735. /**
  3736. * @param {number} opt_fromIndex
  3737. * @param {Object} state
  3738. * @return {undefined}
  3739. */
  3740. sendNotBounce : function(opt_fromIndex, state) {
  3741. this._hitExt({
  3742. url : trigger().href,
  3743. title : "",
  3744. referrer : "",
  3745. modes : {
  3746. cl : opt_fromIndex,
  3747. ar : true,
  3748. nb : true,
  3749. onlyData : true
  3750. },
  3751. callback : state.callback,
  3752. ctx : state.ctx
  3753. });
  3754. },
  3755. /**
  3756. * @param {Object} options
  3757. * @return {undefined}
  3758. */
  3759. sendDevice : function(options) {
  3760. this._hitExt({
  3761. browserInfo : {
  3762. di : options.data,
  3763. dip : options.port
  3764. },
  3765. callback : options.callback,
  3766. ctx : options.ctx
  3767. });
  3768. },
  3769. /**
  3770. * @param {?} options
  3771. * @return {undefined}
  3772. */
  3773. _hitExt : function(options) {
  3774. /**
  3775. * @param {string} value
  3776. * @param {string} key
  3777. * @return {undefined}
  3778. */
  3779. function callback(value, key) {
  3780. if (key) {
  3781. /** @type {string} */
  3782. result[value] = key;
  3783. }
  3784. }
  3785. var state;
  3786. var data;
  3787. var e;
  3788. var value;
  3789. var str;
  3790. var result;
  3791. var k;
  3792. if (!self.isMetrikaPlayer()) {
  3793. state = options.modes || {};
  3794. data = options.browserInfo || {};
  3795. value = "undefined" != typeof options.referrer ? options.referrer : img.lastReferrer;
  3796. str = options.url || "";
  3797. result = {};
  3798. if (state.ar) {
  3799. if (!state.onlyData) {
  3800. value = null === value || "" === value ? "" : this._prepareHitUrl(value);
  3801. str = this._prepareHitUrl(options.url);
  3802. }
  3803. }
  3804. callback("page-ref", self.trim(value, length));
  3805. callback("page-url", self.trim(str, length));
  3806. if (success()) {
  3807. callback("ut", props);
  3808. } else {
  3809. if ("undefined" != typeof state.ut) {
  3810. callback("ut", self.trim(state.ut, extra));
  3811. }
  3812. }
  3813. callback("exp", options.experiments);
  3814. if (options.vParams) {
  3815. str = self.toJSON(options.vParams);
  3816. if (this.trimParams && str.length > chars) {
  3817. /** @type {boolean} */
  3818. k = true;
  3819. } else {
  3820. callback("site-info", str);
  3821. }
  3822. }
  3823. if (state.saveRef) {
  3824. img.lastReferrer = value;
  3825. }
  3826. if (!this.fake) {
  3827. e = this._getTechInfo(options.title, state, this.counterId, options.ts, options.tz, this._trackHash, this.hitId, this.webvisor, this.counter);
  3828. }
  3829. self.mixin(data, e, {});
  3830. this.send(result, data, function() {
  3831. if (k) {
  3832. this.counter.params(options.vParams);
  3833. }
  3834. if (options.userParams) {
  3835. this.counter.userParams(options.userParams);
  3836. }
  3837. if (self.isFunction(options.callback)) {
  3838. options.callback.apply(options.ctx, arguments);
  3839. }
  3840. }, this);
  3841. }
  3842. },
  3843. /**
  3844. * @param {string} t
  3845. * @return {?}
  3846. */
  3847. _prepareHitUrl : function(t) {
  3848. var s = trigger();
  3849. var data = s.host;
  3850. s = s.href;
  3851. var j;
  3852. if (!self.isString(t)) {
  3853. return s;
  3854. }
  3855. if (-1 != t.search(/^\w+:\/\//)) {
  3856. return t;
  3857. }
  3858. j = t.charAt(0);
  3859. if ("?" == j) {
  3860. return j = s.search(/\?/), -1 == j ? s + t : s.substr(0, j) + t;
  3861. }
  3862. if ("#" == j) {
  3863. return j = s.search(/#/), -1 == j ? s + t : s.substr(0, j) + t;
  3864. }
  3865. if ("/" == j) {
  3866. if (j = s.search(data), -1 != j) {
  3867. return s.substr(0, j + data.length) + t;
  3868. }
  3869. } else {
  3870. return data = s.split("/"), data[data.length - 1] = t, data.join("/");
  3871. }
  3872. return t;
  3873. },
  3874. /**
  3875. * @param {(Function|string)} inplace
  3876. * @param {Object} prop
  3877. * @param {(Function|string)} doc
  3878. * @param {number} i
  3879. * @param {Object} root
  3880. * @param {(number|string)} n
  3881. * @param {number} context
  3882. * @param {?} dataAndEvents
  3883. * @param {?} element
  3884. * @return {?}
  3885. */
  3886. _getTechInfo : function(inplace, prop, doc, i, root, n, context, dataAndEvents, element) {
  3887. /**
  3888. * @param {string} name
  3889. * @param {?} state
  3890. * @return {undefined}
  3891. */
  3892. function $(name, state) {
  3893. if (name) {
  3894. if (state) {
  3895. obj[name] = state;
  3896. }
  3897. }
  3898. }
  3899. /**
  3900. * @param {string} p
  3901. * @return {undefined}
  3902. */
  3903. function factory(p) {
  3904. if (prop[p]) {
  3905. $(p, "1");
  3906. }
  3907. }
  3908. var obj = {};
  3909. var parentXY;
  3910. prop = prop || {};
  3911. i = i || me.getTimestamp();
  3912. root = root || me.getTimezone();
  3913. $("j", data.getJavaEnabled() ? "1" : "");
  3914. $("nt", data.netType());
  3915. if (screen) {
  3916. $("s", screen.width + "x" + screen.height + "x" + (screen.colorDepth || screen.pixelDepth));
  3917. }
  3918. if (win.devicePixelRatio) {
  3919. $("sk", win.devicePixelRatio);
  3920. }
  3921. if (data.isIframe()) {
  3922. $("ifr", "1");
  3923. }
  3924. $("adb", methods.getVal());
  3925. $("f", data.getFlashVersion());
  3926. $("l", data.getSilverlightVersion());
  3927. $("fpr", data.getFingerPrint());
  3928. $("cn", this.counterNum);
  3929. if (!prop.pa) {
  3930. parentXY = dom.getViewportSize();
  3931. $("w", parentXY[0] + "x" + parentXY[1]);
  3932. }
  3933. $("z", root);
  3934. $("i", i);
  3935. $("et", Math.round((new Date).getTime() / 1E3));
  3936. $("en", dom.getDocumentCharset());
  3937. $("v", v);
  3938. $("c", navigator.cookieEnabled ? "1" : "");
  3939. $("la", data.getLanguage());
  3940. $("ntf", data.getNotificationPermission());
  3941. if (!self.random(100)) {
  3942. $("np", exports.encode(Base64.encode(self.trim(data.getPlatform(), 100))));
  3943. }
  3944. if (n) {
  3945. $("wh", "1");
  3946. }
  3947. /** @type {Array.<string>} */
  3948. root = "ar ln dl ad nb pa pq pv ex".split(" ");
  3949. /** @type {number} */
  3950. i = 0;
  3951. for (;i < root.length;i++) {
  3952. factory(root[i]);
  3953. }
  3954. /** @type {Array} */
  3955. root = ["va", "vt", "sn", "sa", "he"];
  3956. if (prop.nb) {
  3957. root.push("cl");
  3958. }
  3959. /** @type {number} */
  3960. i = 0;
  3961. for (;i < root.length;i++) {
  3962. n = root[i];
  3963. $(n, prop[n]);
  3964. }
  3965. root = new Node({
  3966. counterId : doc
  3967. });
  3968. if (root.isEnabled()) {
  3969. doc = root.getStorageId();
  3970. if (i = root.get("reqNum")) {
  3971. i++;
  3972. } else {
  3973. /** @type {number} */
  3974. i = 1;
  3975. }
  3976. root.set("reqNum", i);
  3977. if (root.get("reqNum") == i) {
  3978. $("ls", doc);
  3979. $("rqn", i);
  3980. } else {
  3981. root.remove("reqNum");
  3982. root.clearStorageId();
  3983. if (1 < i) {
  3984. $("ls", doc);
  3985. $("rqn", 0);
  3986. }
  3987. }
  3988. }
  3989. $("rn", self.random());
  3990. $("hid", context);
  3991. $("ds", getValue(element));
  3992. if (!element._firstPaint) {
  3993. element._firstPaint = calcFirstPaintTimeResults();
  3994. $("fp", element._firstPaint);
  3995. }
  3996. if (dataAndEvents) {
  3997. if (!win.name) {
  3998. /** @type {number} */
  3999. win.name = Math.round(65535 * Math.random());
  4000. }
  4001. if (context = +win.name) {
  4002. if (0 > context) {
  4003. context *= -1;
  4004. }
  4005. context %= 65535;
  4006. }
  4007. $("wn", context || self.fletcher(win.name));
  4008. try {
  4009. if (win.history) {
  4010. $("hl", String(win.history.length));
  4011. }
  4012. } catch (La) {
  4013. }
  4014. }
  4015. /** @type {string} */
  4016. context = "";
  4017. if (this.sendTitle) {
  4018. context = this._getTitle(inplace);
  4019. }
  4020. $("t", context);
  4021. return obj;
  4022. },
  4023. /**
  4024. * @param {(Function|string)} data
  4025. * @return {?}
  4026. */
  4027. _getTitle : function(data) {
  4028. data = "undefined" == typeof data ? (data = dom.getDocumentTitle()) ? self.trim(data, firstLength) : "" : self.trim(data, firstLength);
  4029. return data;
  4030. }
  4031. });
  4032. /**
  4033. * @param {Array} args
  4034. * @return {?}
  4035. */
  4036. self.array2Props = function(args) {
  4037. var len = args.length;
  4038. var aup = {};
  4039. var cur = aup;
  4040. var i;
  4041. var dir;
  4042. /** @type {number} */
  4043. i = 0;
  4044. for (;i < len - 1;i++) {
  4045. dir = args[i];
  4046. cur[dir] = {};
  4047. if (i < len - 2) {
  4048. cur = cur[dir];
  4049. }
  4050. }
  4051. cur[dir] = args[len - 1];
  4052. return aup;
  4053. };
  4054. var Game = $.inherit({
  4055. sampling : 1,
  4056. counterId : 26302566,
  4057. /**
  4058. * @return {undefined}
  4059. */
  4060. _initComponent : function() {
  4061. Game.superclass._initComponent.apply(this, arguments);
  4062. this._sender = new klass({
  4063. protocol : "https:",
  4064. counterId : this.counterId,
  4065. retry : false,
  4066. counter : {}
  4067. });
  4068. },
  4069. /**
  4070. * @return {undefined}
  4071. */
  4072. log : function() {
  4073. this.logParams(self.array2Props(arguments));
  4074. },
  4075. /**
  4076. * @param {?} opt_attributes
  4077. * @return {undefined}
  4078. */
  4079. logParams : function(opt_attributes) {
  4080. if (Math.random() < this.sampling) {
  4081. this._sender.sendHit({
  4082. url : params.href,
  4083. title : "",
  4084. referrer : "",
  4085. vParams : opt_attributes
  4086. });
  4087. }
  4088. }
  4089. });
  4090. var _initComponent = instance.inherit({
  4091. resource : "webvisor",
  4092. retry : true,
  4093. postParams : ["wv-data"],
  4094. /**
  4095. * @param {Object} packet
  4096. * @param {?} type
  4097. * @param {?} dataAndEvents
  4098. * @param {number} deepDataAndEvents
  4099. * @param {number} data
  4100. * @param {string} tel
  4101. * @param {Function} callback
  4102. * @param {?} $rootScope
  4103. * @return {?}
  4104. */
  4105. sendPacket : function(packet, type, dataAndEvents, deepDataAndEvents, data, tel, callback, $rootScope) {
  4106. var message;
  4107. var error;
  4108. if (!packet || !packet.length) {
  4109. return false;
  4110. }
  4111. message = exports.encode(packet, true);
  4112. if (0 == message.indexOf("AAAAAAAAADw")) {
  4113. if (win.Error) {
  4114. /** @type {Error} */
  4115. error = Error();
  4116. if ("string" == typeof error.stack) {
  4117. (new Game({
  4118. sampling : 0.1
  4119. })).log("bad visor packet 5", 1);
  4120. }
  4121. }
  4122. }
  4123. packet = {
  4124. rn : self.random(),
  4125. "page-url" : type,
  4126. wmode : 0,
  4127. "wv-type" : 0,
  4128. "wv-hit" : dataAndEvents,
  4129. "wv-part" : deepDataAndEvents + 1,
  4130. "wv-check" : self.fletcher(packet),
  4131. "wv-data" : message
  4132. };
  4133. data = {
  4134. v : this._getVersion(),
  4135. z : data,
  4136. i : tel
  4137. };
  4138. return this.send(packet, data, callback, $rootScope);
  4139. }
  4140. });
  4141. var t = ret.inherit({
  4142. protocol : "",
  4143. counterId : "",
  4144. counterType : "",
  4145. meta : null,
  4146. maxBufferSize : 7500,
  4147. flushTimeout : 3E4,
  4148. storageKey : "visorbuff",
  4149. active : false,
  4150. /**
  4151. * @return {undefined}
  4152. */
  4153. _initComponent : function() {
  4154. this.storage = new Node({
  4155. counterId : this.counterId
  4156. });
  4157. this._sender = new _initComponent({
  4158. protocol : this.protocol,
  4159. counterId : this.counterId,
  4160. counterType : this.counterType
  4161. });
  4162. t.superclass._initComponent.apply(this, arguments);
  4163. },
  4164. /**
  4165. * @param {Object} packet
  4166. * @param {Object} a
  4167. * @param {number} deepDataAndEvents
  4168. * @return {undefined}
  4169. */
  4170. onFlush : function(packet, a, deepDataAndEvents) {
  4171. this._sender.sendPacket(packet, a.url, a.hitId, deepDataAndEvents, a.timezone, a.timestamp);
  4172. }
  4173. });
  4174. var Repo = instance.inherit({
  4175. resource : "webvisor",
  4176. transports : [options, Model],
  4177. postParams : ["wv-data"],
  4178. /**
  4179. * @param {Object} str
  4180. * @param {string} keepData
  4181. * @param {?} deepDataAndEvents
  4182. * @param {number} value
  4183. * @param {string} val
  4184. * @param {Function} serviceName
  4185. * @param {?} $rootScope
  4186. * @return {?}
  4187. */
  4188. sendContent : function(str, keepData, deepDataAndEvents, value, val, serviceName, $rootScope) {
  4189. if (!str) {
  4190. return false;
  4191. }
  4192. if (-1 < str.indexOf("\r")) {
  4193. str = str.replace(/\r\n/g, "\n");
  4194. }
  4195. str = {
  4196. "wv-type" : 1,
  4197. "page-url" : trigger().href,
  4198. "wv-hit" : deepDataAndEvents,
  4199. "wv-data" : exports.encode(Base64.encode(str))
  4200. };
  4201. return 245E3 < str["wv-data"].length ? false : this.send(str, {
  4202. z : value,
  4203. i : val,
  4204. pct : keepData || ""
  4205. }, serviceName, $rootScope);
  4206. }
  4207. });
  4208. /**
  4209. * @param {Object} a
  4210. * @param {Object} object
  4211. * @return {?}
  4212. */
  4213. self.isEqual = function(a, object) {
  4214. /** @type {boolean} */
  4215. var all = true;
  4216. self.forEachKey(a, function(property, value) {
  4217. if (!(object.hasOwnProperty(property) && object[property] === value)) {
  4218. /** @type {boolean} */
  4219. all = false;
  4220. }
  4221. });
  4222. if (!all) {
  4223. return all;
  4224. }
  4225. self.forEachKey(object, function(key, value) {
  4226. if (!(a.hasOwnProperty(key) && a[key] === value)) {
  4227. /** @type {boolean} */
  4228. all = false;
  4229. }
  4230. });
  4231. return all;
  4232. };
  4233. var Event = $.inherit({
  4234. /**
  4235. * @return {undefined}
  4236. */
  4237. _initComponent : function() {
  4238. Event.superclass._initComponent.apply(this, arguments);
  4239. /** @type {Array} */
  4240. this._listeners = [];
  4241. },
  4242. /**
  4243. * @param {HTMLElement} el
  4244. * @param {string} type
  4245. * @param {Function} callback
  4246. * @param {Node} context
  4247. * @param {Object} ev
  4248. * @return {undefined}
  4249. */
  4250. on : function(el, type, callback, context, ev) {
  4251. ev = Event._getOpts(ev);
  4252. type = type.split(",");
  4253. var l = type.length;
  4254. var unloadListeners = this._listeners;
  4255. var sType;
  4256. var bound;
  4257. var i;
  4258. /** @type {number} */
  4259. i = 0;
  4260. for (;i < l;i++) {
  4261. sType = type[i];
  4262. bound = bind(function(e) {
  4263. callback.call(context || this, e || win.event);
  4264. }, "on" + sType);
  4265. /** @type {Array} */
  4266. unloadListeners[unloadListeners.length] = [el, sType, callback, context, ev, bound];
  4267. if (el.addEventListener) {
  4268. el.addEventListener(sType, bound, Event._prepOpts(ev));
  4269. } else {
  4270. if (el.attachEvent) {
  4271. el.attachEvent("on" + sType, bound);
  4272. }
  4273. }
  4274. }
  4275. },
  4276. /**
  4277. * @param {HTMLElement} item
  4278. * @param {string} type
  4279. * @param {Function} callback
  4280. * @param {?} dataAndEvents
  4281. * @param {Object} fn
  4282. * @return {undefined}
  4283. */
  4284. un : function(item, type, callback, dataAndEvents, fn) {
  4285. fn = Event._getOpts(fn);
  4286. var listeners = this._listeners;
  4287. var jl = listeners.length;
  4288. var j;
  4289. var a;
  4290. /** @type {number} */
  4291. j = 0;
  4292. for (;j < jl;j++) {
  4293. if (a = listeners[j], a[0] == item && (a[1] == type && (a[2] == callback && (a[3] == dataAndEvents && self.isEqual(a[4], fn))))) {
  4294. listeners.splice(j, 1);
  4295. this._removeListener(item, type, a[5], fn);
  4296. break;
  4297. }
  4298. }
  4299. },
  4300. /**
  4301. * @return {undefined}
  4302. */
  4303. unAll : function() {
  4304. var listeners = this._listeners;
  4305. var jl = listeners.length;
  4306. var listener;
  4307. var j;
  4308. /** @type {number} */
  4309. j = 0;
  4310. for (;j < jl;j++) {
  4311. listener = listeners[j];
  4312. this._removeListener(listener[0], listener[1], listener[5], listener[4]);
  4313. }
  4314. /** @type {number} */
  4315. listeners.length = 0;
  4316. },
  4317. /**
  4318. * @param {Object} element
  4319. * @param {string} type
  4320. * @param {?} func
  4321. * @param {boolean} ev
  4322. * @return {undefined}
  4323. */
  4324. _removeListener : function(element, type, func, ev) {
  4325. if (element.removeEventListener) {
  4326. element.removeEventListener(type, func, Event._prepOpts(ev));
  4327. } else {
  4328. if (element.detachEvent) {
  4329. element.detachEvent("on" + type, func);
  4330. }
  4331. }
  4332. }
  4333. });
  4334. /**
  4335. * @return {?}
  4336. */
  4337. Event.supportsPassive = function() {
  4338. var useCapture;
  4339. if (Event._supportsPassive !== value) {
  4340. return Event._supportsPassive;
  4341. }
  4342. /** @type {boolean} */
  4343. Event._supportsPassive = false;
  4344. try {
  4345. /** @type {Object} */
  4346. useCapture = Object.defineProperty({}, "passive", {
  4347. /**
  4348. * @return {undefined}
  4349. */
  4350. get : function() {
  4351. /** @type {boolean} */
  4352. Event._supportsPassive = true;
  4353. }
  4354. });
  4355. win.addEventListener("test", null, useCapture);
  4356. } catch (b) {
  4357. }
  4358. return Event._supportsPassive;
  4359. };
  4360. /**
  4361. * @param {Object} args
  4362. * @return {?}
  4363. */
  4364. Event._getOpts = function(args) {
  4365. return self.mixin({
  4366. capture : true,
  4367. passive : true
  4368. }, args || {});
  4369. };
  4370. /**
  4371. * @param {boolean} ui
  4372. * @return {?}
  4373. */
  4374. Event._prepOpts = function(ui) {
  4375. return Event.supportsPassive() ? ui : !!ui.capture;
  4376. };
  4377. /**
  4378. * @return {undefined}
  4379. */
  4380. Event.on = function() {
  4381. if (!Event._instance) {
  4382. Event._instance = new Event;
  4383. }
  4384. Event._instance.on.apply(Event._instance, arguments);
  4385. };
  4386. /**
  4387. * @return {undefined}
  4388. */
  4389. Event.un = function() {
  4390. if (Event._instance) {
  4391. Event._instance.un.apply(Event._instance, arguments);
  4392. }
  4393. };
  4394. /**
  4395. * @return {?}
  4396. */
  4397. dom.getDocumentHTML = function() {
  4398. var root;
  4399. /** @type {string} */
  4400. var value = "";
  4401. /** @type {Element} */
  4402. root = doc.documentElement;
  4403. /** @type {string} */
  4404. var data = root.outerHTML;
  4405. var expires;
  4406. var i;
  4407. var p;
  4408. if (data) {
  4409. /** @type {string} */
  4410. root = data;
  4411. } else {
  4412. /** @type {(NamedNodeMap|null)} */
  4413. data = root.attributes;
  4414. /** @type {string} */
  4415. expires = "";
  4416. /** @type {number} */
  4417. i = 0;
  4418. for (;i < data.length;i++) {
  4419. if (p = data[i]) {
  4420. expires += " " + p.name + '="' + (p.value || "") + '"';
  4421. }
  4422. }
  4423. /** @type {string} */
  4424. root = "<html" + expires + ">" + root.innerHTML + "</html>";
  4425. }
  4426. if (data = doc.doctype) {
  4427. /** @type {string} */
  4428. value = data.publicId ? ' PUBLIC "' + data.publicId + '"' : "";
  4429. /** @type {string} */
  4430. expires = data.systemId ? ' "' + data.systemId + '"' : "";
  4431. /** @type {string} */
  4432. value = "<!DOCTYPE " + data.name + value + expires + ">\n";
  4433. }
  4434. return value + root;
  4435. };
  4436. /**
  4437. * @return {?}
  4438. */
  4439. dom.getDocumentScroll = function() {
  4440. 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))];
  4441. };
  4442. /**
  4443. * @param {(Object|string)} element
  4444. * @return {?}
  4445. */
  4446. dom.getElementParent = function(element) {
  4447. var src;
  4448. if (!element || element == doc.documentElement) {
  4449. return null;
  4450. }
  4451. if (element == doc.body) {
  4452. return doc.documentElement;
  4453. }
  4454. /** @type {null} */
  4455. src = null;
  4456. try {
  4457. src = element.parentNode;
  4458. } catch (c) {
  4459. }
  4460. return src;
  4461. };
  4462. /**
  4463. * @param {Element} element
  4464. * @param {boolean} name
  4465. * @return {?}
  4466. */
  4467. dom.getElementChildren = function(element, name) {
  4468. /** @type {Array} */
  4469. var children = [];
  4470. var nodes;
  4471. var node;
  4472. var h;
  4473. var _i;
  4474. var _len;
  4475. if (element && (nodes = element.childNodes)) {
  4476. /** @type {number} */
  4477. _i = 0;
  4478. _len = nodes.length;
  4479. for (;_i < _len;_i++) {
  4480. node = nodes[_i];
  4481. if (!(h = "INPUT" == node.nodeName && (node.type && "hidden" == node.type.toLocaleLowerCase()))) {
  4482. if (!(name && node.nodeName != name)) {
  4483. self.mergeArrays(children, [node]);
  4484. }
  4485. }
  4486. }
  4487. }
  4488. return children;
  4489. };
  4490. /**
  4491. * @param {string} element
  4492. * @return {?}
  4493. */
  4494. dom.getElementNeighborPosition = function(element) {
  4495. var nodes = dom.getElementParent(element);
  4496. var className;
  4497. var attr;
  4498. var getElementNeighborPosition;
  4499. var i;
  4500. if (nodes) {
  4501. /** @type {number} */
  4502. getElementNeighborPosition = 0;
  4503. nodes = nodes.childNodes;
  4504. attr = element && element.nodeName;
  4505. /** @type {number} */
  4506. i = 0;
  4507. for (;i < nodes.length;i++) {
  4508. if (className = nodes[i] && nodes[i].nodeName, attr == className) {
  4509. if (element == nodes[i]) {
  4510. return getElementNeighborPosition;
  4511. }
  4512. getElementNeighborPosition++;
  4513. }
  4514. }
  4515. }
  4516. return 0;
  4517. };
  4518. /**
  4519. * @param {Element} el
  4520. * @return {?}
  4521. */
  4522. dom.getElementXY = function(el) {
  4523. var offsetLeft;
  4524. var offsetTop;
  4525. if (!el || (!el.ownerDocument || ("PARAM" == el.tagName || (el == doc.body || el == doc.documentElement)))) {
  4526. return[0, 0];
  4527. }
  4528. if (el.getBoundingClientRect) {
  4529. return el = el.getBoundingClientRect(), offsetLeft = dom.getDocumentScroll(), [Math.round(el.left + offsetLeft[0]), Math.round(el.top + offsetLeft[1])];
  4530. }
  4531. /** @type {number} */
  4532. offsetTop = offsetLeft = 0;
  4533. for (;el;) {
  4534. offsetLeft += el.offsetLeft;
  4535. offsetTop += el.offsetTop;
  4536. el = el.offsetParent;
  4537. }
  4538. return[offsetLeft, offsetTop];
  4539. };
  4540. /**
  4541. * @return {?}
  4542. */
  4543. dom.getDocumentSize = function() {
  4544. var doc = dom.getRootElement();
  4545. var points = dom.getViewportSize();
  4546. return[Math.max(doc.scrollWidth, points[0]), Math.max(doc.scrollHeight, points[1])];
  4547. };
  4548. /**
  4549. * @param {string} el
  4550. * @return {?}
  4551. */
  4552. dom.getElementSize = function(el) {
  4553. var $cont;
  4554. return el == doc.body || el == doc.documentElement ? dom.getDocumentSize() : ($cont = el.getBoundingClientRect && el.getBoundingClientRect()) ? [$cont.width, $cont.height] : [el.offsetWidth, el.offsetHeight];
  4555. };
  4556. /**
  4557. * @param {string} element
  4558. * @return {?}
  4559. */
  4560. dom.getElementRegion = function(element) {
  4561. var elementRect = dom.getElementXY(element);
  4562. element = dom.getElementSize(element);
  4563. return[elementRect[0], elementRect[1], element[0], element[1]];
  4564. };
  4565. /**
  4566. * @param {Object} node
  4567. * @return {?}
  4568. */
  4569. dom.calcChildrenChecksum = function(node) {
  4570. return self.fletcher((node.innerHTML || "").replace(/(<[^>]*>|[\u0000-\u0020])/g, ""));
  4571. };
  4572. /**
  4573. * @param {HTMLFormElement} dataAndEvents
  4574. * @return {?}
  4575. */
  4576. dom.getFormNumber = function(dataAndEvents) {
  4577. /** @type {NodeList} */
  4578. var codeSegments = doc.getElementsByTagName("form");
  4579. var i;
  4580. var valsLength;
  4581. /** @type {number} */
  4582. i = 0;
  4583. /** @type {number} */
  4584. valsLength = codeSegments.length;
  4585. for (;i < valsLength;i++) {
  4586. if (codeSegments[i] == dataAndEvents) {
  4587. return i;
  4588. }
  4589. }
  4590. return-1;
  4591. };
  4592. /**
  4593. * @param {Element} a
  4594. * @return {?}
  4595. */
  4596. dom.isEmptyField = function(a) {
  4597. 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;
  4598. };
  4599. /**
  4600. * @param {Node} children
  4601. * @return {?}
  4602. */
  4603. dom.calcTextChecksum = function(children) {
  4604. /** @type {string} */
  4605. var textContent = "";
  4606. children = children.childNodes;
  4607. var i;
  4608. var valsLength;
  4609. /** @type {number} */
  4610. i = 0;
  4611. valsLength = children.length;
  4612. for (;i < valsLength;i++) {
  4613. if (children[i]) {
  4614. if (3 == children[i].nodeType) {
  4615. textContent += children[i].nodeValue;
  4616. }
  4617. }
  4618. }
  4619. return self.fletcher(textContent.replace(/[\u0000-\u0020]+/g, ""));
  4620. };
  4621. /**
  4622. * @param {Element} el
  4623. * @return {?}
  4624. */
  4625. dom.calcAttribChecksum = function(el) {
  4626. /** @type {string} */
  4627. var qs = "";
  4628. /** @type {Array.<string>} */
  4629. var codeSegments = "width height align title alt name".split(" ");
  4630. var i;
  4631. if ("IMG" == el.tagName) {
  4632. qs += el.src.toLowerCase();
  4633. }
  4634. if ("A" == el.tagName) {
  4635. qs += el.href.toLowerCase();
  4636. }
  4637. qs += String(el.className || "").toLowerCase();
  4638. /** @type {number} */
  4639. i = 0;
  4640. for (;i < codeSegments.length;i++) {
  4641. if (el.getAttribute) {
  4642. qs += String(el.getAttribute(codeSegments[i]) || "").toLowerCase();
  4643. }
  4644. }
  4645. return self.fletcher(qs.replace(/[\u0000-\u0020]+/g, ""));
  4646. };
  4647. /**
  4648. * @param {Object} v02
  4649. * @param {string} dataAndEvents
  4650. * @return {?}
  4651. */
  4652. dom.classNameExists = function(v02, dataAndEvents) {
  4653. try {
  4654. return(new RegExp("(?:^|\\s)" + dataAndEvents + "(?:\\s|$)")).test(v02.className);
  4655. } catch (c) {
  4656. return false;
  4657. }
  4658. };
  4659. /**
  4660. * @param {string} node
  4661. * @param {Object} context
  4662. * @return {?}
  4663. */
  4664. dom.getElementsByClassName = function(node, context) {
  4665. var codeSegments;
  4666. var retnode;
  4667. var i;
  4668. context = context || doc;
  4669. codeSegments = context.getElementsByTagName("*");
  4670. /** @type {Array} */
  4671. retnode = [];
  4672. /** @type {number} */
  4673. i = 0;
  4674. for (;i < codeSegments.length;i++) {
  4675. if (dom.classNameExists(codeSegments[i], node)) {
  4676. retnode.push(codeSegments[i]);
  4677. }
  4678. }
  4679. return retnode;
  4680. };
  4681. var lb = !check(/webkit/) && check(/gecko/);
  4682. var Class = $.inherit({
  4683. hid : 0,
  4684. tz : 0,
  4685. ts : 0,
  4686. counterId : 0,
  4687. counterType : 0,
  4688. url : "",
  4689. protocol : "",
  4690. enabled : false,
  4691. /**
  4692. * @return {undefined}
  4693. */
  4694. _initComponent : function() {
  4695. var controller;
  4696. var c;
  4697. if (this.isEnabled()) {
  4698. controller = this._getStorage();
  4699. c = controller.read("visorc");
  4700. if ("b" != c) {
  4701. if ("w" != c) {
  4702. /** @type {string} */
  4703. c = "";
  4704. }
  4705. }
  4706. if (!controller.isEnabled() || check("opera mini")) {
  4707. /** @type {string} */
  4708. c = "b";
  4709. }
  4710. this._vc = c;
  4711. if ("b" != c) {
  4712. this._recorder = new init(this.protocol, this.counterId, this.counterType, this.hid, this.counter);
  4713. }
  4714. Class.superclass._initComponent.apply(this, arguments);
  4715. }
  4716. },
  4717. /**
  4718. * @param {Object} d
  4719. * @return {undefined}
  4720. */
  4721. start : function(d) {
  4722. var b;
  4723. var width;
  4724. if (this.isEnabled() && this._recorder) {
  4725. d = d || {};
  4726. /** @type {number} */
  4727. b = +d.recp;
  4728. if (!isFinite(b) || (0 > b || 1 < b)) {
  4729. /** @type {string} */
  4730. width = "w";
  4731. }
  4732. if (!width) {
  4733. /** @type {string} */
  4734. width = this.hid % 1E4 / 1E4 < b ? "w" : "b";
  4735. }
  4736. this._getStorage().create("visorc", width, 30);
  4737. if ("w" == width) {
  4738. this._recorder.start();
  4739. b = d.arch_type;
  4740. if (d = d.urls) {
  4741. if (b) {
  4742. if ("none" != b) {
  4743. this._recorder.uploadPages(d, b);
  4744. }
  4745. }
  4746. }
  4747. } else {
  4748. this._recorder.stop();
  4749. }
  4750. }
  4751. },
  4752. /**
  4753. * @return {?}
  4754. */
  4755. isEnabled : function() {
  4756. return this.enabled;
  4757. },
  4758. /**
  4759. * @return {?}
  4760. */
  4761. getVc : function() {
  4762. return this._vc;
  4763. },
  4764. /**
  4765. * @return {?}
  4766. */
  4767. _getStorage : function() {
  4768. if (!this._storage) {
  4769. this._storage = new Controller({
  4770. counterId : this.counterId
  4771. });
  4772. }
  4773. return this._storage;
  4774. }
  4775. });
  4776. var Request = options.inherit({
  4777. id : "RawBodyXHR",
  4778. postParams : ["body"],
  4779. /**
  4780. * @return {undefined}
  4781. */
  4782. _setHeaders : function() {
  4783. },
  4784. /**
  4785. * @param {Object} data
  4786. * @return {?}
  4787. */
  4788. _preparePostParams : function(data) {
  4789. return data.post.body || "";
  4790. }
  4791. });
  4792. /**
  4793. * @param {Array} array
  4794. * @param {Function} callable
  4795. * @param {?} thisObj
  4796. * @return {?}
  4797. */
  4798. self.arrayFilter = function(array, callable, thisObj) {
  4799. /** @type {Array} */
  4800. var result = [];
  4801. var i;
  4802. /** @type {number} */
  4803. i = 0;
  4804. for (;i < array.length;i++) {
  4805. if (callable.call(thisObj, array[i], i, array)) {
  4806. result.push(array[i]);
  4807. }
  4808. }
  4809. return result;
  4810. };
  4811. /**
  4812. * @param {?} other
  4813. * @param {?} value
  4814. * @return {?}
  4815. */
  4816. self.arrDiff = function(other, value) {
  4817. return self.arrayFilter(other, function(key) {
  4818. return-1 === self.arrayIndexOf(value, key);
  4819. });
  4820. };
  4821. /**
  4822. * @param {Object} jsonString
  4823. * @return {?}
  4824. */
  4825. JSON.parse = function(jsonString) {
  4826. try {
  4827. return JSON.parse(jsonString);
  4828. } catch (b) {
  4829. return null;
  4830. }
  4831. };
  4832. /**
  4833. * @return {?}
  4834. */
  4835. self.getTld = function() {
  4836. var codeSegments;
  4837. if (!this._tld) {
  4838. codeSegments = params.hostname.split(".");
  4839. this._tld = codeSegments[codeSegments.length - 1];
  4840. }
  4841. return this._tld;
  4842. };
  4843. s3 = request.inherit({
  4844. id : "script",
  4845. /**
  4846. * @param {Element} el
  4847. * @param {Object} data
  4848. * @param {Function} callback
  4849. * @param {?} scope
  4850. * @return {?}
  4851. */
  4852. request : function(el, data, callback, scope) {
  4853. var key;
  4854. var script = self.getNativeFunction("createElement", doc)("script");
  4855. if (!script) {
  4856. return callback.call(scope, false), false;
  4857. }
  4858. /** @type {string} */
  4859. key = "_ymjsp" + self.random();
  4860. win[key] = bind(function() {
  4861. try {
  4862. delete win[key];
  4863. } catch (l) {
  4864. /** @type {(Function|string)} */
  4865. win[key] = value;
  4866. }
  4867. callback.apply(scope, self.mergeArrays([true], arguments));
  4868. if (script.parentNode) {
  4869. script.parentNode.removeChild(script);
  4870. }
  4871. }, "transport.script");
  4872. /** @type {string} */
  4873. script.type = "text/javascript";
  4874. script.src = this._buildUrl(el, self.mixin({
  4875. wmode : 5,
  4876. callback : key
  4877. }, data));
  4878. el = doc.getElementsByTagName("head")[0];
  4879. if (!el) {
  4880. /** @type {Element} */
  4881. el = doc.createElement("head");
  4882. doc.documentElement.appendChild(el);
  4883. }
  4884. el.insertBefore(script, el.firstChild);
  4885. return true;
  4886. }
  4887. });
  4888. var Comment = klass.inherit({
  4889. transports : [s3],
  4890. trimParams : true,
  4891. /**
  4892. * @return {undefined}
  4893. */
  4894. _initComponent : function() {
  4895. Comment.superclass._initComponent.apply(this, arguments);
  4896. this._ilStorage = new Node({
  4897. counterId : this.counterId
  4898. });
  4899. },
  4900. /**
  4901. * @param {Object} args
  4902. * @return {undefined}
  4903. */
  4904. sendHit : function(args) {
  4905. var map = {};
  4906. var str = this._ilStorage.get("il");
  4907. if (args.visitColor) {
  4908. map.vc = args.visitColor;
  4909. }
  4910. if (args.hasPrerender) {
  4911. /** @type {number} */
  4912. map.pr = 1;
  4913. }
  4914. if (str) {
  4915. this._ilStorage.remove("il");
  4916. map.ilt = exports.encode(Base64.encode(self.trim(str, raw)));
  4917. }
  4918. this._hitExt({
  4919. url : args.url,
  4920. title : args.title,
  4921. referrer : args.referrer,
  4922. vParams : args.vParams,
  4923. userParams : args.userParams,
  4924. experiments : args.experiments,
  4925. modes : args.modes,
  4926. browserInfo : map,
  4927. ts : args.ts,
  4928. tz : args.tz,
  4929. callback : args.callback,
  4930. ctx : args.ctx
  4931. });
  4932. }
  4933. });
  4934. var _cn = $.inherit({
  4935. cid : 3,
  4936. cnt : 0,
  4937. /**
  4938. * @return {undefined}
  4939. */
  4940. _initComponent : function() {
  4941. this._storage = new Node;
  4942. },
  4943. /**
  4944. * @param {Function} f
  4945. * @return {undefined}
  4946. */
  4947. hit : function(f) {
  4948. var self = this;
  4949. var e = this._storage.get("wasSynced");
  4950. if (e && e.time + 864E5 > +new Date || win.Ya._metrika.fakeHit) {
  4951. f();
  4952. } else {
  4953. /** @type {boolean} */
  4954. win.Ya._metrika.fakeHit = true;
  4955. this._getSender().sendHit({
  4956. /**
  4957. * @return {undefined}
  4958. */
  4959. callback : function() {
  4960. self._storage.set("wasSynced", {
  4961. time : +new Date
  4962. });
  4963. f();
  4964. }
  4965. });
  4966. }
  4967. },
  4968. /**
  4969. * @return {?}
  4970. */
  4971. _getSender : function() {
  4972. if (!this._sender) {
  4973. this._sender = new Comment({
  4974. protocol : "https:",
  4975. counterType : this.cnt,
  4976. counterId : this.cid,
  4977. sendTitle : false,
  4978. dontSendRequests : this.dontSendRequests,
  4979. fake : true
  4980. });
  4981. }
  4982. return this._sender;
  4983. }
  4984. });
  4985. var Async = $.inherit({
  4986. baseUrl : "https://mc.yandex.",
  4987. baseTld : "ru",
  4988. syncTlds : ["ua", "by", "kz", "com.tr"],
  4989. langToDomain : {
  4990. uk : "ua",
  4991. be : "by",
  4992. tr : "com.tr",
  4993. kk : "kz"
  4994. },
  4995. /**
  4996. * @param {?} callback
  4997. * @return {undefined}
  4998. */
  4999. sync : function(callback) {
  5000. var jQuery = this;
  5001. var memory = this._need();
  5002. if (!this._is() && memory) {
  5003. this._setStatus(true);
  5004. if (success()) {
  5005. this._getCn().hit(function() {
  5006. jQuery._sync(memory, callback);
  5007. });
  5008. } else {
  5009. callback(function() {
  5010. jQuery._sync(memory);
  5011. });
  5012. }
  5013. } else {
  5014. callback();
  5015. }
  5016. },
  5017. /**
  5018. * @return {?}
  5019. */
  5020. _is : function() {
  5021. try {
  5022. return!!win.Ya._metrika.startSync;
  5023. } catch (a) {
  5024. return false;
  5025. }
  5026. },
  5027. /**
  5028. * @param {boolean} dataAndEvents
  5029. * @return {undefined}
  5030. */
  5031. _setStatus : function(dataAndEvents) {
  5032. try {
  5033. /** @type {boolean} */
  5034. win.Ya._metrika.startSync = dataAndEvents;
  5035. } catch (b) {
  5036. }
  5037. },
  5038. /**
  5039. * @return {?}
  5040. */
  5041. _need : function() {
  5042. var key = this._getDomainByLang();
  5043. var name = this._getTld();
  5044. var buf;
  5045. /** @type {Array} */
  5046. var keys = [];
  5047. if (-1 != self.arrayIndexOf(this.syncTlds, key)) {
  5048. keys.push(key);
  5049. }
  5050. if (-1 != self.arrayIndexOf(this.syncTlds, name)) {
  5051. if (-1 == self.arrayIndexOf(keys, name)) {
  5052. keys.push(name);
  5053. }
  5054. }
  5055. buf = this._getLs().get("synced") || {};
  5056. keys = self.arrayFilter(keys, function(off) {
  5057. return(buf[off] || 1) + 864E5 < +new Date;
  5058. });
  5059. return keys.length && keys || false;
  5060. },
  5061. /**
  5062. * @param {string} options
  5063. * @param {Function} callback
  5064. * @return {undefined}
  5065. */
  5066. _sync : function(options, callback) {
  5067. var codeSegments;
  5068. var self;
  5069. var remote = this;
  5070. if (options.length) {
  5071. self = new Request({
  5072. method : "GET"
  5073. });
  5074. callback = callback || function() {
  5075. };
  5076. self.request(this.baseUrl + this.baseTld + "/sync_cookie_get", null, function(dataAndEvents, s) {
  5077. var i;
  5078. var n;
  5079. var data_user;
  5080. /** @type {number} */
  5081. var a = 0;
  5082. /** @type {number} */
  5083. var bup = 0;
  5084. var browser;
  5085. var authHeader;
  5086. if (dataAndEvents) {
  5087. i = JSON.parse(s);
  5088. try {
  5089. n = i.sync_token;
  5090. authHeader = i.sync_ok;
  5091. } catch (Gb) {
  5092. return callback(), false;
  5093. }
  5094. codeSegments = self.arrDiff(options, authHeader);
  5095. if (a = codeSegments.length) {
  5096. data_user = remote._getLs();
  5097. browser = new Browser;
  5098. /** @type {number} */
  5099. i = 0;
  5100. for (;i < codeSegments.length;i++) {
  5101. (function(path) {
  5102. browser.request(remote.baseUrl + path + "/sync_cookie_image_check", {
  5103. body : n
  5104. }, function(udataCur) {
  5105. bup++;
  5106. if (a === bup) {
  5107. callback();
  5108. }
  5109. if (udataCur) {
  5110. udataCur = data_user.get("synced") || {};
  5111. /** @type {number} */
  5112. udataCur[path] = +new Date;
  5113. data_user.set("synced", udataCur);
  5114. }
  5115. });
  5116. })(codeSegments[i]);
  5117. }
  5118. } else {
  5119. callback();
  5120. }
  5121. } else {
  5122. callback();
  5123. }
  5124. });
  5125. } else {
  5126. callback();
  5127. }
  5128. },
  5129. /**
  5130. * @return {?}
  5131. */
  5132. _getCn : function() {
  5133. if (!this._cn) {
  5134. this._cn = new _cn({
  5135. fake : true,
  5136. dontSendRequests : this.dontSendRequests
  5137. });
  5138. }
  5139. return this._cn;
  5140. },
  5141. /**
  5142. * @return {?}
  5143. */
  5144. _getLs : function() {
  5145. if (!this._ls) {
  5146. this._ls = new Node;
  5147. }
  5148. return this._ls;
  5149. },
  5150. /**
  5151. * @return {?}
  5152. */
  5153. _getTld : function() {
  5154. var name = self.getTld();
  5155. return{
  5156. tr : "com.tr",
  5157. "\u0443\u043a\u0440" : "ua",
  5158. "xn--j1amh" : "ua",
  5159. "\u0431\u0435\u043b" : "by",
  5160. "xn--90ais" : "by"
  5161. }[name] || name;
  5162. },
  5163. /**
  5164. * @return {?}
  5165. */
  5166. _getDomainByLang : function() {
  5167. var line;
  5168. if (!win.navigator) {
  5169. return "ru";
  5170. }
  5171. try {
  5172. line = navigator.languages ? navigator.languages[0] : data.getLanguage();
  5173. } catch (b) {
  5174. }
  5175. line = (line || "").toLowerCase().split("-")[0];
  5176. return this.langToDomain[line] || "ru";
  5177. }
  5178. });
  5179. data.isAndroid = bind(function() {
  5180. /** @type {string} */
  5181. var ua = navigator.userAgent.toLowerCase();
  5182. return-1 < ua.indexOf("android") && (-1 < ua.indexOf("mobile") && navigator.platform.match(/^android|linux armv/i));
  5183. }, "", true);
  5184. /**
  5185. * @return {?}
  5186. */
  5187. self.isDev = function() {
  5188. var tag;
  5189. if (self._isDevSetted) {
  5190. return self._isDev;
  5191. }
  5192. try {
  5193. /** @type {boolean} */
  5194. self._isDevSetted = true;
  5195. /** @type {Image} */
  5196. tag = new Image;
  5197. Object.defineProperty(tag, "id", {
  5198. /**
  5199. * @return {undefined}
  5200. */
  5201. get : function() {
  5202. /** @type {boolean} */
  5203. self._isDev = true;
  5204. }
  5205. });
  5206. } catch (b) {
  5207. }
  5208. };
  5209. var me = {
  5210. /**
  5211. * @return {?}
  5212. */
  5213. getMinutes : function() {
  5214. return Math.floor(+new Date / 1E3 / 60);
  5215. }
  5216. };
  5217. var inst = {
  5218. _url : "https://mc.yandex.ru/user_storage_set?",
  5219. _params : {},
  5220. /**
  5221. * @param {Object} params
  5222. * @return {undefined}
  5223. */
  5224. init : function(params) {
  5225. this._params = params || {};
  5226. },
  5227. /**
  5228. * @param {string} key
  5229. * @param {string} value
  5230. * @return {undefined}
  5231. */
  5232. save : function(key, value) {
  5233. this._getReq().request(this._url + store.stringify({
  5234. key : key,
  5235. value : self.toJSON(value)
  5236. }));
  5237. this._getLs().set(key, value);
  5238. },
  5239. /**
  5240. * @param {string} id
  5241. * @return {?}
  5242. */
  5243. get : function(id) {
  5244. return{
  5245. remote : this._params[id],
  5246. local : this._getLs().get(id)
  5247. };
  5248. },
  5249. /**
  5250. * @param {Object} attr
  5251. * @return {?}
  5252. */
  5253. getNum : function(attr) {
  5254. attr = this.get(attr);
  5255. return Math.max(+attr.remote || 0, +attr.local || 0);
  5256. },
  5257. /**
  5258. * @return {?}
  5259. */
  5260. _getLs : function() {
  5261. if (!this._ls) {
  5262. this._ls = new Node;
  5263. }
  5264. return this._ls;
  5265. },
  5266. /**
  5267. * @return {?}
  5268. */
  5269. _getReq : function() {
  5270. if (!this._req) {
  5271. this._req = new Browser;
  5272. }
  5273. return this._req;
  5274. }
  5275. };
  5276. var model = {
  5277. sync : bind(function() {
  5278. /** @type {Array} */
  5279. var props = ["30102", "29009"];
  5280. var c = {
  5281. t : 'UV|L7,!"T[rwe&D_>ZIb\\aW#98Y.PC6k'
  5282. };
  5283. var self;
  5284. var _len2;
  5285. if (this._enabled()) {
  5286. this._setStatus(true);
  5287. self = new Request({
  5288. method : "GET",
  5289. withCredentials : false
  5290. });
  5291. /** @type {number} */
  5292. _len2 = props.length;
  5293. (function save(key) {
  5294. var p = props[key];
  5295. if (key < _len2) {
  5296. self.request("http://127.0.0.1:" + p + "/p", c, function(walkers, inplace) {
  5297. if (walkers) {
  5298. this._save(walkers, inplace, p);
  5299. } else {
  5300. save.call(this, key + 1);
  5301. }
  5302. }, this);
  5303. } else {
  5304. this._save(false);
  5305. }
  5306. }).call(this, 0);
  5307. }
  5308. }, "ds"),
  5309. /**
  5310. * @param {boolean} obj
  5311. * @param {string} data
  5312. * @param {number} options
  5313. * @return {undefined}
  5314. */
  5315. _save : function(obj, data, options) {
  5316. var udataCur = me.getMinutes();
  5317. if (obj) {
  5318. (new klass({
  5319. protocol : "https:",
  5320. counterType : 0,
  5321. counterId : 42822899,
  5322. sendTitle : false,
  5323. fake : true
  5324. })).sendDevice({
  5325. data : self.trim(data),
  5326. port : options
  5327. });
  5328. } else {
  5329. udataCur -= 45;
  5330. }
  5331. inst.save("ds", udataCur);
  5332. },
  5333. /**
  5334. * @return {?}
  5335. */
  5336. _is : function() {
  5337. try {
  5338. return!!win.Ya._metrika.dSync;
  5339. } catch (a) {
  5340. return false;
  5341. }
  5342. },
  5343. /**
  5344. * @return {?}
  5345. */
  5346. _enabled : function() {
  5347. 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())));
  5348. },
  5349. /**
  5350. * @param {boolean} dataAndEvents
  5351. * @return {undefined}
  5352. */
  5353. _setStatus : function(dataAndEvents) {
  5354. try {
  5355. /** @type {boolean} */
  5356. win.Ya._metrika.dSync = dataAndEvents;
  5357. } catch (b) {
  5358. }
  5359. }
  5360. };
  5361. var that = {
  5362. /**
  5363. * @param {Object} e
  5364. * @return {?}
  5365. */
  5366. getPos : function(e) {
  5367. var doc = dom.getRootElement();
  5368. var nearby = dom.getDocumentScroll();
  5369. return[e.pageX || (e.clientX + nearby[0] - (doc.clientLeft || 0) || 0), e.pageY || (e.clientY + nearby[1] - (doc.clientTop || 0) || 0)];
  5370. },
  5371. /**
  5372. * @param {Object} obj
  5373. * @return {?}
  5374. */
  5375. getTarget : function(obj) {
  5376. /** @type {null} */
  5377. var el = null;
  5378. try {
  5379. if (el = obj.target || obj.srcElement) {
  5380. if (!el.ownerDocument) {
  5381. if (el.documentElement) {
  5382. el = el.documentElement;
  5383. }
  5384. }
  5385. }
  5386. } catch (c) {
  5387. }
  5388. return el;
  5389. },
  5390. /**
  5391. * @param {Object} e
  5392. * @return {?}
  5393. */
  5394. getMouseButton : function(e) {
  5395. return e.which || e.button == value ? e.which : e.button & 1 ? 1 : e.button & 2 ? 3 : e.button & 4 ? 2 : 0;
  5396. },
  5397. /**
  5398. * @param {Object} event
  5399. * @return {undefined}
  5400. */
  5401. prevent : function(event) {
  5402. event = event || win.event;
  5403. if (event.preventDefault) {
  5404. event.preventDefault();
  5405. } else {
  5406. /** @type {boolean} */
  5407. event.returnValue = false;
  5408. }
  5409. }
  5410. };
  5411. that.dispatchCustomEvent = bind(function(name, ctx) {
  5412. var e;
  5413. ctx = ctx || doc;
  5414. if (e = self.getNativeFunction("createEvent", doc)("Event")) {
  5415. e.initEvent(name, false, false);
  5416. self.getNativeFunction("dispatchEvent", ctx)(e);
  5417. }
  5418. }, "evt.dispatch");
  5419. /**
  5420. * @param {Function} callback
  5421. * @return {undefined}
  5422. */
  5423. Event.ready = function(callback) {
  5424. /** @type {(Performance|null)} */
  5425. var data = win.performance;
  5426. var handler;
  5427. if ("object" == typeof data && (data.timing && data.timing.domContentLoadedEventStart)) {
  5428. callback();
  5429. } else {
  5430. /**
  5431. * @return {undefined}
  5432. */
  5433. handler = function() {
  5434. Event.un(doc, "DOMContentLoaded", handler);
  5435. Event.un(win, "load", handler);
  5436. callback();
  5437. };
  5438. Event.on(doc, "DOMContentLoaded", handler);
  5439. Event.on(win, "load", handler);
  5440. }
  5441. };
  5442. var img = {
  5443. lastReferrer : null
  5444. };
  5445. /**
  5446. * @param {boolean} o
  5447. * @return {?}
  5448. */
  5449. self.isObject = function(o) {
  5450. try {
  5451. return o && (null !== o && "[object Object]" == Object.prototype.toString.call(o));
  5452. } catch (b) {
  5453. return false;
  5454. }
  5455. };
  5456. /**
  5457. * @param {?} n
  5458. * @return {?}
  5459. */
  5460. self.isNumber = function(n) {
  5461. return isFinite(n) && (!isNaN(n) && "[object Number]" == Object.prototype.toString.call(n));
  5462. };
  5463. /**
  5464. * @param {?} timeoutKey
  5465. * @return {?}
  5466. */
  5467. self.clearTimeout = function(timeoutKey) {
  5468. return self.getNativeFunction("clearTimeout")(timeoutKey);
  5469. };
  5470. /** @type {null} */
  5471. self._urlParser = null;
  5472. /**
  5473. * @param {?} urlString
  5474. * @return {?}
  5475. */
  5476. self.parseUrl = function(urlString) {
  5477. if (!this._urlParser) {
  5478. try {
  5479. /** @type {Element} */
  5480. this._urlParser = doc.createElement("a");
  5481. } catch (b) {
  5482. }
  5483. }
  5484. return this._urlParser ? (this._urlParser.href = urlString, {
  5485. protocol : this._urlParser.protocol,
  5486. host : this._urlParser.host,
  5487. port : this._urlParser.port,
  5488. hostname : this._urlParser.hostname,
  5489. hash : this._urlParser.hash,
  5490. search : this._urlParser.search,
  5491. query : this._urlParser.search.replace(/^\?/, ""),
  5492. pathname : this._urlParser.pathname || "/",
  5493. path : (this._urlParser.pathname || "/") + this._urlParser.search,
  5494. href : this._urlParser.href
  5495. }) : {};
  5496. };
  5497. /**
  5498. * @return {?}
  5499. */
  5500. data.isIE = function() {
  5501. return doc && !doc.addEventListener || false;
  5502. };
  5503. var console = {};
  5504. console._cookie = new Controller({
  5505. onlyCurrentDomain : true
  5506. });
  5507. console.log = bind(function() {
  5508. var a = -1 < params.href.indexOf("_ym_debug=1") || win._ym_debug;
  5509. if (a) {
  5510. this._cookie.create("debug", "1");
  5511. }
  5512. if (win.console) {
  5513. if (console.log) {
  5514. if (a || "1" === this._cookie.read("debug")) {
  5515. console.log.apply(console, arguments);
  5516. }
  5517. }
  5518. }
  5519. }, "DebugConsole.log");
  5520. var _sender = instance.inherit({
  5521. resource : "clmap",
  5522. retry : true,
  5523. transports : [Browser],
  5524. /**
  5525. * @param {?} event
  5526. * @param {string} element
  5527. * @param {Function} serviceName
  5528. * @param {?} $rootScope
  5529. * @return {undefined}
  5530. */
  5531. sendClick : function(event, element, serviceName, $rootScope) {
  5532. this.send({
  5533. "page-url" : event,
  5534. "pointer-click" : element
  5535. }, {}, serviceName, $rootScope);
  5536. }
  5537. });
  5538. var Server = $.inherit({
  5539. filter : null,
  5540. ignoreTags : [],
  5541. quota : 0,
  5542. isTrackHash : false,
  5543. protocol : "",
  5544. counterId : 0,
  5545. counterType : 0,
  5546. startTime : 0,
  5547. dontSendRequests : false,
  5548. MAX_LEN_PATH : 128,
  5549. TIMEOUT_CLICK : 50,
  5550. TIMEOUT_SAME_CLICKS : 1E3,
  5551. DELTA_SAME_CLICKS : 2,
  5552. 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(" "),
  5553. /**
  5554. * @return {undefined}
  5555. */
  5556. _initComponent : function() {
  5557. var f;
  5558. var chr;
  5559. var i;
  5560. /** @type {null} */
  5561. this._lastClick = null;
  5562. /** @type {boolean} */
  5563. this.hasQuota = !!this.quota;
  5564. this._quota = this.quota;
  5565. /** @type {Array} */
  5566. this._ignoreTags = [];
  5567. if (this.ignoreTags) {
  5568. /** @type {number} */
  5569. f = 0;
  5570. for (;f < this.ignoreTags.length;f++) {
  5571. if (this.ignoreTags[f]) {
  5572. self.mergeArrays(this._ignoreTags, [String(this.ignoreTags[f]).toUpperCase()]);
  5573. }
  5574. }
  5575. }
  5576. this._cacheTags = {};
  5577. /** @type {number} */
  5578. f = 59;
  5579. /** @type {function (...[number]): string} */
  5580. chr = String.fromCharCode;
  5581. /** @type {number} */
  5582. i = 0;
  5583. for (;i < this.tags.length;i++) {
  5584. /** @type {string} */
  5585. this._cacheTags[this.tags[i]] = chr(f);
  5586. chr(f);
  5587. f++;
  5588. }
  5589. this._sender = new _sender({
  5590. dontSendRequests : this.dontSendRequests,
  5591. protocol : this.protocol,
  5592. counterId : this.counterId,
  5593. counterType : this.counterType
  5594. });
  5595. /** @type {boolean} */
  5596. this._start = false;
  5597. this.start();
  5598. },
  5599. /**
  5600. * @return {undefined}
  5601. */
  5602. destroy : function() {
  5603. this.stop();
  5604. },
  5605. /**
  5606. * @return {undefined}
  5607. */
  5608. start : function() {
  5609. if (!this._start) {
  5610. Event.on(doc, "click", this._handler, this);
  5611. }
  5612. /** @type {boolean} */
  5613. this._start = true;
  5614. },
  5615. /**
  5616. * @return {undefined}
  5617. */
  5618. stop : function() {
  5619. if (this._start) {
  5620. Event.un(doc, "click", this._handler, this);
  5621. }
  5622. /** @type {boolean} */
  5623. this._start = false;
  5624. },
  5625. /**
  5626. * @param {?} edge
  5627. * @return {undefined}
  5628. */
  5629. setTrackHash : function(edge) {
  5630. this.isTrackHash = edge;
  5631. },
  5632. /**
  5633. * @param {Error} a
  5634. * @return {?}
  5635. */
  5636. _isIgnore : function(a) {
  5637. return dom.classNameExists(a, "(ym-disable-clickmap|ym-clickmap-ignore)");
  5638. },
  5639. /**
  5640. * @param {Object} e
  5641. * @return {undefined}
  5642. */
  5643. _handler : function(e) {
  5644. e = {
  5645. el : that.getTarget(e),
  5646. pos : that.getPos(e),
  5647. button : that.getMouseButton(e),
  5648. time : +new Date
  5649. };
  5650. var previous;
  5651. var original;
  5652. if (this._isTrackingClick(e)) {
  5653. previous = dom.getElementSize(e.el);
  5654. original = dom.getElementXY(e.el);
  5655. /** @type {Array} */
  5656. 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)];
  5657. original = trigger().href;
  5658. if (this.isTrackHash) {
  5659. self.mergeArrays(previous, ["wh", "1"]);
  5660. } else {
  5661. original = original.split("#")[0];
  5662. }
  5663. this._sender.sendClick(self.trim(original, length), previous.join(":"));
  5664. /** @type {Object} */
  5665. this._lastClick = e;
  5666. }
  5667. },
  5668. /**
  5669. * @param {Object} e
  5670. * @return {?}
  5671. */
  5672. _isTrackingClick : function(e) {
  5673. var element;
  5674. var i;
  5675. var num;
  5676. if (win.ymDisabledClickmap || (self.isMetrikaPlayer() || !e.el)) {
  5677. return false;
  5678. }
  5679. element = e.el.tagName;
  5680. if ((2 == e.button || 3 == e.button) && "A" != element || this.filter && !this.filter(e.el, element)) {
  5681. return false;
  5682. }
  5683. /** @type {number} */
  5684. i = 0;
  5685. for (;i < this._ignoreTags.length;i++) {
  5686. if (this._ignoreTags[i] == element) {
  5687. return false;
  5688. }
  5689. }
  5690. element = e.el;
  5691. for (;element;) {
  5692. if (this._isIgnore(element)) {
  5693. return false;
  5694. }
  5695. element = element.parentNode;
  5696. }
  5697. if (this._lastClick) {
  5698. if (e.time - this._lastClick.time < this.TIMEOUT_CLICK) {
  5699. return false;
  5700. }
  5701. /** @type {number} */
  5702. element = Math.abs(this._lastClick.pos[0] - e.pos[0]);
  5703. /** @type {number} */
  5704. i = Math.abs(this._lastClick.pos[1] - e.pos[1]);
  5705. /** @type {number} */
  5706. num = e.time - this._lastClick.time;
  5707. if (this._lastClick.el == e.el && (element < this.DELTA_SAME_CLICKS && (i < this.DELTA_SAME_CLICKS && num < this.TIMEOUT_SAME_CLICKS))) {
  5708. return false;
  5709. }
  5710. }
  5711. if (this.hasQuota) {
  5712. if (!this._quota) {
  5713. return false;
  5714. }
  5715. this._quota--;
  5716. }
  5717. return true;
  5718. },
  5719. /**
  5720. * @param {Object} element
  5721. * @return {?}
  5722. */
  5723. _getElPath : function(element) {
  5724. /** @type {string} */
  5725. var str = "";
  5726. for (;element && (element.parentNode && ("BODY" != element.tagName && "HTML" != element.tagName));) {
  5727. str += this._cacheTags[element.tagName] || "*";
  5728. str += dom.getElementNeighborPosition(element) || "";
  5729. element = element.parentNode;
  5730. }
  5731. return self.trim(str, this.MAX_LEN_PATH);
  5732. }
  5733. });
  5734. /**
  5735. * @param {?} o
  5736. * @param {Object} e
  5737. * @return {?}
  5738. */
  5739. dom.loadScript = function(o, e) {
  5740. e = e || win;
  5741. var options = self.mixin({
  5742. type : "text/javascript",
  5743. charset : "utf-8",
  5744. async : true
  5745. }, o);
  5746. var doc = e.document;
  5747. var $ = self.getNativeFunction("createElement", doc);
  5748. var script = $("script");
  5749. var p;
  5750. var a;
  5751. if (script) {
  5752. script.type = options.type;
  5753. script.charset = options.charset;
  5754. script.src = options.src;
  5755. if (options.async) {
  5756. /** @type {boolean} */
  5757. script.async = true;
  5758. }
  5759. try {
  5760. return p = doc.getElementsByTagName("head")[0], p || (a = doc.getElementsByTagName("html")[0], p = $("head"), a && a.appendChild(p)), p.insertBefore(script, p.firstChild), script;
  5761. } catch (t) {
  5762. }
  5763. }
  5764. };
  5765. var sbp = $.inherit({
  5766. /**
  5767. * @return {undefined}
  5768. */
  5769. _initComponent : function() {
  5770. sbp.superclass._initComponent.apply(this, arguments);
  5771. this._executedMsgs = {};
  5772. Event.on(win, "message", this._onMessage, this);
  5773. },
  5774. /**
  5775. * @param {string} scriptLocation
  5776. * @return {undefined}
  5777. */
  5778. _buildRemoteIframe : function(scriptLocation) {
  5779. var element = self.getNativeFunction("createElement", doc)("div");
  5780. /** @type {Element} */
  5781. var parent = doc.body || doc.documentElement;
  5782. var node;
  5783. if (parent) {
  5784. /** @type {string} */
  5785. element.innerHTML = '<iframe name="RemoteIframe" allowtransparency="true" style="position: absolute; left: -999px; top: -999px; width: 1px; height: 1px;"></iframe>';
  5786. node = element.firstChild;
  5787. /**
  5788. * @return {undefined}
  5789. */
  5790. node.onload = function() {
  5791. dom.loadScript({
  5792. src : scriptLocation
  5793. }, node.contentWindow);
  5794. };
  5795. win._ym__remoteIframeEl = node;
  5796. if (element.createShadowRoot || element.webkitCreateShadowRoot) {
  5797. parent.appendChild(element);
  5798. element.removeChild(node);
  5799. if (parent = element.createShadowRoot ? element.createShadowRoot() : element.webkitCreateShadowRoot()) {
  5800. parent.appendChild(node);
  5801. }
  5802. win._ym__remoteIframeContainer = element;
  5803. } else {
  5804. parent.appendChild(node);
  5805. win._ym__remoteIframeContainer = node;
  5806. }
  5807. }
  5808. },
  5809. /**
  5810. * @param {string} key
  5811. * @return {?}
  5812. */
  5813. _isAllowedLang : function(key) {
  5814. return-1 !== self.arrayIndexOf(["ru", "uk", "en", "tr"], key);
  5815. },
  5816. /**
  5817. * @param {?} a
  5818. * @return {?}
  5819. */
  5820. _isAllowedOrigin : function(a) {
  5821. return/^http:\/\/(.+\.)?webvisor\.com\/?$/.test(a);
  5822. },
  5823. /**
  5824. * @param {?} qualifier
  5825. * @return {?}
  5826. */
  5827. _isAllowedStatic : function(qualifier) {
  5828. return/^https?:\/\/(((.+\.)?dev\.webvisor\.com)|(yastatic\.net))(\/.*)?$/.test(qualifier);
  5829. },
  5830. /**
  5831. * @param {MessageEvent} e
  5832. * @return {undefined}
  5833. */
  5834. _onMessage : function(e) {
  5835. var d;
  5836. try {
  5837. d = e.origin;
  5838. } catch (c) {
  5839. }
  5840. if (d) {
  5841. if (this._isAllowedOrigin(d)) {
  5842. if (d = JSON.parse(e.data)) {
  5843. if ("appendremote" === d.action) {
  5844. if (this._isAllowedStatic(d.domain)) {
  5845. if (this._isAllowedLang(d.lang)) {
  5846. if (!this._executedMsgs[d.id]) {
  5847. /** @type {boolean} */
  5848. this._executedMsgs[d.id] = true;
  5849. /** @type {MessageEvent} */
  5850. win._ym__postMessageEvent = e;
  5851. win._ym__inpageMode = d.inpageMode;
  5852. win._ym__initMessage = d.initMessage;
  5853. this._buildRemoteIframe(d.domain + "/cdn/inpage-remote/inpage-remote." + d.lang + ".js");
  5854. }
  5855. }
  5856. }
  5857. }
  5858. }
  5859. }
  5860. }
  5861. }
  5862. });
  5863. /**
  5864. * @param {number} n
  5865. * @return {?}
  5866. */
  5867. self.pad = function(n) {
  5868. return(10 > n ? "0" : "") + n;
  5869. };
  5870. /**
  5871. * @return {?}
  5872. */
  5873. me.getTimestamp = function() {
  5874. /** @type {Date} */
  5875. var ts = new Date;
  5876. /** @type {Array} */
  5877. ts = [ts.getFullYear(), ts.getMonth() + 1, ts.getDate(), ts.getHours(), ts.getMinutes(), ts.getSeconds()];
  5878. /** @type {string} */
  5879. var optsData = "";
  5880. var i;
  5881. /** @type {number} */
  5882. i = 0;
  5883. for (;i < ts.length;i++) {
  5884. optsData += self.pad(ts[i]);
  5885. }
  5886. return optsData;
  5887. };
  5888. /**
  5889. * @return {?}
  5890. */
  5891. me.getTimezone = function() {
  5892. return-(new Date).getTimezoneOffset();
  5893. };
  5894. /**
  5895. * @param {Function} fn
  5896. * @param {(Document|string)} context
  5897. * @return {?}
  5898. */
  5899. self.bind = function(fn, context) {
  5900. return function() {
  5901. return fn.apply(context || this, arguments);
  5902. };
  5903. };
  5904. var TabBody = $.inherit({
  5905. counter : null,
  5906. prefsEcommerce : null,
  5907. dataLayerName : "dataLayer",
  5908. allowedEvents : ["add", "delete", "remove", "purchase", "detail"],
  5909. /**
  5910. * @return {undefined}
  5911. */
  5912. _initComponent : function() {
  5913. /** @type {string} */
  5914. var text = "customArr";
  5915. TabBody.superclass._initComponent.apply(this, arguments);
  5916. if (!this._overridePush(this.prefsEcommerce)) {
  5917. if (self.isString(this.prefsEcommerce)) {
  5918. this.dataLayerName = this.prefsEcommerce;
  5919. }
  5920. text = this.dataLayerName;
  5921. this._tryTimeout = self.bind(this._tryTimeout, this);
  5922. this._tryTimeout();
  5923. }
  5924. this.counter._ecommerce = text;
  5925. },
  5926. /**
  5927. * @param {Object} options
  5928. * @return {?}
  5929. */
  5930. _overridePush : function(options) {
  5931. var self;
  5932. var matcherFunction;
  5933. return options && "function" == typeof options.push ? (self = this, self._send(options), matcherFunction = options.push, options.push = function() {
  5934. self._send([].slice.call(arguments, 0));
  5935. matcherFunction.apply(this, arguments);
  5936. }, true) : false;
  5937. },
  5938. /**
  5939. * @return {undefined}
  5940. */
  5941. _tryTimeout : function() {
  5942. if (!this._overridePush(win[this.dataLayerName])) {
  5943. self.setTimeout(this._tryTimeout, 1E3, "dlObserver");
  5944. }
  5945. },
  5946. /**
  5947. * @param {Array} options
  5948. * @return {undefined}
  5949. */
  5950. _send : function(options) {
  5951. /** @type {Array} */
  5952. var configList = [];
  5953. var a = this.allowedEvents;
  5954. var i;
  5955. var xhr;
  5956. var flags;
  5957. var h;
  5958. var precision;
  5959. /** @type {number} */
  5960. i = 0;
  5961. precision = options.length;
  5962. for (;i < precision;i++) {
  5963. if (xhr = options[i]) {
  5964. if (xhr.ecommerce) {
  5965. flags = {};
  5966. /** @type {boolean} */
  5967. h = false;
  5968. self.forEachKey(xhr.ecommerce, function(key, value) {
  5969. if (0 <= self.arrayIndexOf(a, key)) {
  5970. /** @type {boolean} */
  5971. h = true;
  5972. flags[key] = value;
  5973. }
  5974. });
  5975. if (h) {
  5976. configList.push(flags);
  5977. }
  5978. }
  5979. }
  5980. }
  5981. if (configList.length) {
  5982. this.counter.params({
  5983. __ym : {
  5984. ecommerce : configList
  5985. }
  5986. });
  5987. }
  5988. }
  5989. });
  5990. var query = {
  5991. /**
  5992. * @return {undefined}
  5993. */
  5994. match : function() {
  5995. if (this.enabled()) {
  5996. Event.ready(function() {
  5997. var iframe = self.getNativeFunction("createElement", doc)("iframe");
  5998. /**
  5999. * @return {undefined}
  6000. */
  6001. iframe.onload = function() {
  6002. inst.save("cm", me.getMinutes());
  6003. dom.removeNode(iframe);
  6004. };
  6005. iframe.setAttribute("style", "position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden;visibility:hidden");
  6006. /** @type {string} */
  6007. iframe.src = "https://mc.yandex.ru/metrika/watch_match.html";
  6008. doc.documentElement.appendChild(iframe);
  6009. });
  6010. }
  6011. },
  6012. /**
  6013. * @return {?}
  6014. */
  6015. enabled : function() {
  6016. return 1440 < me.getMinutes() - inst.getNum("cm") && "tr" == self.getTld();
  6017. }
  6018. };
  6019. /**
  6020. * @param {string} string
  6021. * @return {?}
  6022. */
  6023. self.safeDecodeURIComponent = function(string) {
  6024. try {
  6025. return decodeURIComponent(string);
  6026. } catch (b) {
  6027. return "";
  6028. }
  6029. };
  6030. /**
  6031. * @param {Object} s
  6032. * @param {boolean} execResult
  6033. * @return {?}
  6034. */
  6035. store.parse = function(s, execResult) {
  6036. var obj = {};
  6037. var codeSegments;
  6038. var val;
  6039. var name;
  6040. var i;
  6041. s = s && s.replace(/^\?/, "") || "";
  6042. if (s.length) {
  6043. codeSegments = s.split("&");
  6044. /** @type {number} */
  6045. i = 0;
  6046. for (;i < codeSegments.length;i++) {
  6047. if (codeSegments[i]) {
  6048. val = codeSegments[i].split("=");
  6049. if (val[0]) {
  6050. name = self.safeDecodeURIComponent(val[0]);
  6051. val = self.safeDecodeURIComponent((val[1] || "").replace(/\+/g, "%20"));
  6052. if (execResult && name in obj) {
  6053. if (self.isArray(obj[name])) {
  6054. obj[name].push(val);
  6055. } else {
  6056. /** @type {Array} */
  6057. obj[name] = [obj[name], val];
  6058. }
  6059. } else {
  6060. obj[name] = val;
  6061. }
  6062. }
  6063. }
  6064. }
  6065. }
  6066. return obj;
  6067. };
  6068. /** @type {Array} */
  6069. var codeSegments = [];
  6070. var params = trigger();
  6071. var udataCur = me.getTimezone();
  6072. var now = me.getTimestamp();
  6073. var screen = win.screen;
  6074. /** @type {string} */
  6075. var v = "787";
  6076. /** @type {number} */
  6077. var extra = 64;
  6078. /** @type {number} */
  6079. var length = data.isIE() ? 512 : 2048;
  6080. /** @type {number} */
  6081. var chars = data.isIE() ? 512 : 2048;
  6082. /** @type {number} */
  6083. var firstLength = data.isIE() ? 100 : 400;
  6084. /** @type {number} */
  6085. var raw = 100;
  6086. /** @type {string} */
  6087. var props = "noindex";
  6088. /** @type {RegExp} */
  6089. 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;
  6090. /** @type {number} */
  6091. var currentTime = +new Date;
  6092. var aux;
  6093. var max;
  6094. var dontSendRequests;
  6095. win.Ya = win.Ya || {};
  6096. Ya._metrika = Ya._metrika || {};
  6097. Ya._metrika.counters = Ya._metrika.counters || {};
  6098. Ya._metrika.hitParam = Ya._metrika.hitParam || {};
  6099. Ya._metrika.counterNum = Ya._metrika.counterNum || 0;
  6100. Ya._metrika.hitId = Ya._metrika.hitId || self.random();
  6101. Ya._globalMetrikaHitId = self.random();
  6102. /** @type {string} */
  6103. Ya._metrika.v = v;
  6104. /** @type {boolean} */
  6105. dontSendRequests = !!Ya._metrika.oo;
  6106. /**
  6107. * @param {Object} data
  6108. * @param {(Function|string)} count
  6109. * @param {number} ret
  6110. * @param {(RegExp|string)} opt_length
  6111. * @return {?}
  6112. */
  6113. win.Ya.Metrika = function(data, count, ret, opt_length) {
  6114. var that = this;
  6115. return bind(function() {
  6116. /**
  6117. * @param {boolean} recurring
  6118. * @return {?}
  6119. */
  6120. function trigger(recurring) {
  6121. /** @type {boolean} */
  6122. var self = false;
  6123. var tmp;
  6124. var next;
  6125. if (Ya._metrika.hitParam[counterIndex]) {
  6126. if (1 != ret || Ya._metrika.counters[counterIndex]) {
  6127. return false;
  6128. }
  6129. /** @type {boolean} */
  6130. self = true;
  6131. }
  6132. Ya._metrika.counters[counterIndex] = that;
  6133. /** @type {number} */
  6134. Ya._metrika.hitParam[counterIndex] = 1;
  6135. that._webvisor = !opt_length && (!dontSendRequests && (options && options.webvisor || false));
  6136. that._directCampaign = options && options.directCampaign;
  6137. if (options) {
  6138. if (options.trackHash) {
  6139. show(true);
  6140. }
  6141. }
  6142. if (!opt_length) {
  6143. if (!self) {
  6144. tmp = new Class({
  6145. protocol : "https:",
  6146. counterId : data,
  6147. counterType : ret,
  6148. hid : hid,
  6149. tz : udataCur,
  6150. ts : now,
  6151. url : params.href,
  6152. enabled : that._webvisor
  6153. });
  6154. that.replacePhones();
  6155. self = new Async({
  6156. dontSendRequests : dontSendRequests
  6157. });
  6158. /**
  6159. * @param {?} done
  6160. * @return {undefined}
  6161. */
  6162. next = function(done) {
  6163. var model = new Comment({
  6164. protocol : "https:",
  6165. counterType : ret,
  6166. counterId : data,
  6167. trackHash : e,
  6168. hitId : hid,
  6169. webvisor : that._webvisor,
  6170. counter : that,
  6171. dontSendRequests : dontSendRequests,
  6172. counterNum : counterNum
  6173. });
  6174. var modes = {
  6175. ut : module,
  6176. he : options ? ~~options.httpError : 0,
  6177. ad : 1 == ret && (win.Ya && win.Ya.Direct),
  6178. pv : true,
  6179. saveRef : true
  6180. };
  6181. /** @type {number} */
  6182. aux = +new Date;
  6183. model.sendHit({
  6184. url : params.href,
  6185. title : dom.getDocumentTitle(),
  6186. referrer : doc.referrer,
  6187. vParams : count,
  6188. userParams : dataText,
  6189. experiments : image,
  6190. modes : modes,
  6191. visitColor : tmp.getVc(),
  6192. hasPrerender : recurring,
  6193. ts : now,
  6194. tz : udataCur,
  6195. /**
  6196. * @param {Object} opt_attributes
  6197. * @param {string} update
  6198. * @return {undefined}
  6199. */
  6200. callback : function(opt_attributes, update) {
  6201. inst.init(update);
  6202. query.match();
  6203. model.sync();
  6204. console.log("PageView. Counter ", data, ". URL: ", params.href, ". Referrer: " + doc.referrer, ". Params: ", count);
  6205. if (!max) {
  6206. /** @type {number} */
  6207. max = +new Date;
  6208. }
  6209. opt_attributes = opt_attributes || {};
  6210. tmp.start(opt_attributes.webvisor);
  6211. var options = opt_attributes.mp2;
  6212. var v;
  6213. var controller;
  6214. controller = new Controller({
  6215. counterId : data
  6216. });
  6217. controller.erase("mp2_substs");
  6218. if (options) {
  6219. b: {
  6220. v = options.conditions;
  6221. var j;
  6222. if (v && v.length) {
  6223. /** @type {number} */
  6224. j = 0;
  6225. for (;j < v.length;j++) {
  6226. var a;
  6227. a = v[j];
  6228. if ("ref" == a.type) {
  6229. a = load(a);
  6230. } else {
  6231. if ("adv" == a.type) {
  6232. var i;
  6233. var f;
  6234. var c;
  6235. var b;
  6236. var n;
  6237. i = a;
  6238. b = Ya._metrika.counter._directCampaign;
  6239. f = i.ServiceNamePattern;
  6240. var config = i.RefererPattern;
  6241. a = b ? i.direct_orders : i.direct_camp;
  6242. /** @type {string} */
  6243. var q = doc.referrer;
  6244. var iterable = store.parse(params.search);
  6245. var t = write(params.search, params.hash);
  6246. var object = {};
  6247. /** @type {Array} */
  6248. c = ["source", "medium", "campaign", "term", "content"];
  6249. /** @type {number} */
  6250. n = 0;
  6251. for (;n < c.length;n++) {
  6252. if (iterable["utm_" + c[n]]) {
  6253. object[c[n]] = iterable["utm_" + c[n]];
  6254. }
  6255. }
  6256. var nType = b ? "direct.yandex.ru" : t && t.service || object.source;
  6257. /** @type {boolean} */
  6258. n = false;
  6259. if (!n && (f && f.length)) {
  6260. /** @type {number} */
  6261. c = 0;
  6262. for (;c < f.length;c++) {
  6263. if ((new RegExp(f[c], "i")).test(nType)) {
  6264. /** @type {boolean} */
  6265. n = true;
  6266. break;
  6267. }
  6268. }
  6269. }
  6270. if (!n && (!i.yandex_direct && (config && config.length))) {
  6271. /** @type {number} */
  6272. f = 0;
  6273. for (;f < config.length;f++) {
  6274. if ((new RegExp(config[f], "i")).test(q)) {
  6275. /** @type {boolean} */
  6276. n = true;
  6277. break;
  6278. }
  6279. }
  6280. }
  6281. if (!n) {
  6282. if (i.google_adwords) {
  6283. if (iterable.gclid) {
  6284. /** @type {boolean} */
  6285. n = true;
  6286. }
  6287. }
  6288. }
  6289. if (n && (a && (a.length && (n = false, b = b || (t && t.campaign || object && object.campaign))))) {
  6290. /** @type {number} */
  6291. i = 0;
  6292. for (;i < a.length;i++) {
  6293. if (a[i] == b) {
  6294. /** @type {boolean} */
  6295. n = true;
  6296. break;
  6297. }
  6298. }
  6299. }
  6300. /** @type {boolean} */
  6301. a = n;
  6302. } else {
  6303. /** @type {boolean} */
  6304. a = false;
  6305. }
  6306. }
  6307. if (a) {
  6308. if (v[j].track_id) {
  6309. controller.create("mp2_track", v[j].track_id, 43200);
  6310. }
  6311. break b;
  6312. }
  6313. }
  6314. }
  6315. }
  6316. v = controller.read("mp2_track");
  6317. options = options.substs && options.substs[v];
  6318. if (v && options) {
  6319. controller.create("mp2_substs", self.toJSON(options));
  6320. controller = add(options);
  6321. that.params("__ym", controller ? "mp_trackid" : "mp_trackid_bad", v);
  6322. } else {
  6323. _next();
  6324. }
  6325. } else {
  6326. _next();
  6327. }
  6328. Event.on(win, "load", that.replacePhones, that);
  6329. /** @type {boolean} */
  6330. that._inited = true;
  6331. if (done) {
  6332. done();
  6333. }
  6334. }
  6335. });
  6336. };
  6337. self.sync(next);
  6338. }
  6339. }
  6340. confirm();
  6341. if (options) {
  6342. if (options.enableAll) {
  6343. setup(true);
  6344. fn(true);
  6345. create();
  6346. } else {
  6347. if (options.clickmap) {
  6348. fn(options.clickmap);
  6349. }
  6350. if (options.trackLinks) {
  6351. setup(options.trackLinks);
  6352. }
  6353. if (options.accurateTrackBounce) {
  6354. create(options.accurateTrackBounce);
  6355. }
  6356. }
  6357. if (options.ecommerce || options.useDataLayer) {
  6358. new TabBody({
  6359. counter : that,
  6360. prefsEcommerce : options.ecommerce
  6361. });
  6362. }
  6363. if (options.triggerEvent) {
  6364. defer(function() {
  6365. that.dispatchCustomEvent("yacounter" + data + "inited");
  6366. }, 0);
  6367. }
  6368. }
  6369. }
  6370. /**
  6371. * @param {boolean} val
  6372. * @return {undefined}
  6373. */
  6374. function setup(val) {
  6375. var attr = {};
  6376. switch(typeof val) {
  6377. case "string":
  6378. /** @type {boolean} */
  6379. attr.on = true;
  6380. break;
  6381. case "object":
  6382. /** @type {boolean} */
  6383. attr.on = true;
  6384. break;
  6385. case "boolean":
  6386. /** @type {boolean} */
  6387. attr.on = val;
  6388. break;
  6389. default:
  6390. return;
  6391. }
  6392. that._trackLinks = attr;
  6393. }
  6394. /**
  6395. * @return {undefined}
  6396. */
  6397. function confirm() {
  6398. setup(false);
  6399. Event.on(doc, "click", function(e) {
  6400. if (that._trackLinks) {
  6401. if (that._trackLinks.on) {
  6402. next(e);
  6403. }
  6404. }
  6405. });
  6406. }
  6407. /**
  6408. * @param {?} i
  6409. * @return {undefined}
  6410. */
  6411. function next(i) {
  6412. var a = handle(i);
  6413. var value;
  6414. var c;
  6415. var handler;
  6416. var res;
  6417. if (a) {
  6418. /** @type {boolean} */
  6419. i = false;
  6420. /** @type {string} */
  6421. c = (value = "" + a.href) ? value.split(/\?/)[0] : "";
  6422. /**
  6423. * @param {(Object|string)} d
  6424. * @return {undefined}
  6425. */
  6426. handler = function(d) {
  6427. var className = get(a);
  6428. $.sendClickLink({
  6429. url : value,
  6430. title : value == className ? "" : className,
  6431. modes : d
  6432. });
  6433. };
  6434. if (rchecked.test(c) || (rchecked.test(value) || (walk(value, key) || walk(c, key)))) {
  6435. /** @type {boolean} */
  6436. i = true;
  6437. }
  6438. res = dom.classNameExists(a, "ym-disable-tracklink");
  6439. c = dom.classNameExists(a, "ym-external-link");
  6440. if (!res) {
  6441. res = {
  6442. ln : true,
  6443. dl : i
  6444. };
  6445. if (c) {
  6446. handler(res);
  6447. } else {
  6448. c = a.hostname || (self.parseUrl(a.href).hostname || "");
  6449. if (_init(trigger().hostname, c)) {
  6450. if (i) {
  6451. /** @type {boolean} */
  6452. res.ln = false;
  6453. handler(res);
  6454. } else {
  6455. if (i = get(a)) {
  6456. if (i != value) {
  6457. n.set("il", self.trim(i, raw));
  6458. }
  6459. }
  6460. }
  6461. } else {
  6462. if (!(value && -1 != value.search(/^ *(data|javascript):/i))) {
  6463. /** @type {string} */
  6464. res.ut = props;
  6465. handler(res);
  6466. }
  6467. }
  6468. }
  6469. }
  6470. }
  6471. }
  6472. /**
  6473. * @param {boolean} deepDataAndEvents
  6474. * @return {undefined}
  6475. */
  6476. function fn(deepDataAndEvents) {
  6477. if ("undefined" == typeof deepDataAndEvents) {
  6478. /** @type {boolean} */
  6479. deepDataAndEvents = true;
  6480. }
  6481. if (true === deepDataAndEvents) {
  6482. deepDataAndEvents = {};
  6483. }
  6484. if (that._clickmap) {
  6485. that._clickmap.destroy();
  6486. }
  6487. if (deepDataAndEvents) {
  6488. that._clickmap = new Server({
  6489. dontSendRequests : dontSendRequests,
  6490. filter : deepDataAndEvents.filter,
  6491. ignoreTags : deepDataAndEvents.ignoreTags,
  6492. quota : deepDataAndEvents.quota,
  6493. isTrackHash : deepDataAndEvents.isTrackHash,
  6494. protocol : "https:",
  6495. counterId : data,
  6496. counterType : ret,
  6497. startTime : currentTime
  6498. });
  6499. }
  6500. }
  6501. /**
  6502. * @param {Function} callback
  6503. * @param {number} time
  6504. * @return {undefined}
  6505. */
  6506. function init(callback, time) {
  6507. /**
  6508. * @return {undefined}
  6509. */
  6510. function check() {
  6511. var ms;
  6512. if (!t) {
  6513. if (timeoutKey) {
  6514. self.clearTimeout(timeoutKey);
  6515. }
  6516. ms = list ? i : i + +new Date - off;
  6517. /** @type {number} */
  6518. ms = time - ms;
  6519. if (0 > ms) {
  6520. /** @type {number} */
  6521. ms = 0;
  6522. }
  6523. timeoutKey = self.setTimeout(function() {
  6524. /** @type {boolean} */
  6525. t = true;
  6526. cb(false);
  6527. callback();
  6528. }, ms, "trackUserTime");
  6529. }
  6530. }
  6531. /**
  6532. * @return {undefined}
  6533. */
  6534. function end() {
  6535. if (!memory) {
  6536. /** @type {boolean} */
  6537. stack = true;
  6538. /** @type {boolean} */
  6539. list = false;
  6540. /** @type {boolean} */
  6541. memory = true;
  6542. check();
  6543. }
  6544. }
  6545. /**
  6546. * @param {boolean} recurring
  6547. * @return {undefined}
  6548. */
  6549. function cb(recurring) {
  6550. var i;
  6551. /** @type {number} */
  6552. i = 0;
  6553. for (;i < items.length;i += 3) {
  6554. if (recurring) {
  6555. Event.on(items[i], items[i + 1], items[i + 2]);
  6556. } else {
  6557. Event.un(items[i], items[i + 1], items[i + 2]);
  6558. }
  6559. }
  6560. }
  6561. /** @type {boolean} */
  6562. var stack = false;
  6563. /** @type {boolean} */
  6564. var memory = false;
  6565. /** @type {boolean} */
  6566. var list = true;
  6567. /** @type {number} */
  6568. var i = 0;
  6569. /** @type {number} */
  6570. var off = +new Date;
  6571. /** @type {null} */
  6572. var timeoutKey = null;
  6573. /** @type {boolean} */
  6574. var t = false;
  6575. var items;
  6576. if (data.isIE()) {
  6577. self.setTimeout(callback, time, "trackUserTime");
  6578. } else {
  6579. /** @type {Array} */
  6580. items = [win, "blur", function() {
  6581. /** @type {boolean} */
  6582. list = stack = memory = true;
  6583. i += +new Date - off;
  6584. /** @type {number} */
  6585. off = +new Date;
  6586. check();
  6587. }, win, "focus", function() {
  6588. if (!stack) {
  6589. if (!memory) {
  6590. /** @type {number} */
  6591. i = 0;
  6592. }
  6593. }
  6594. /** @type {number} */
  6595. off = +new Date;
  6596. /** @type {boolean} */
  6597. stack = memory = true;
  6598. /** @type {boolean} */
  6599. list = false;
  6600. check();
  6601. }, doc, "click", end, doc, "mousemove", end, doc, "keydown", end, doc, "scroll", end];
  6602. cb(true);
  6603. check();
  6604. }
  6605. }
  6606. /**
  6607. * @param {number} id
  6608. * @return {undefined}
  6609. */
  6610. function create(id) {
  6611. var end;
  6612. var daysToDayOfWeek;
  6613. if ("number" != typeof id) {
  6614. /** @type {number} */
  6615. id = 15E3;
  6616. }
  6617. if (!that._isAccurateTrackBounce) {
  6618. /** @type {boolean} */
  6619. that._isAccurateTrackBounce = true;
  6620. end = new Node({
  6621. counterId : data
  6622. });
  6623. daysToDayOfWeek = end.get("lastHit");
  6624. end.set("lastHit", +new Date);
  6625. if ((end = end.get("lastHit")) && (!daysToDayOfWeek || daysToDayOfWeek < end - 18E5) || (!extend(doc.referrer, trigger().href) || 0.1 > Math.random())) {
  6626. init(function() {
  6627. that.notBounce();
  6628. }, id);
  6629. }
  6630. }
  6631. }
  6632. /**
  6633. * @param {?} next
  6634. * @return {undefined}
  6635. */
  6636. function after(next) {
  6637. /**
  6638. * @return {?}
  6639. */
  6640. var go = function() {
  6641. var key = trigger().hash.split("#")[1];
  6642. var lastNestingSeparator;
  6643. if ("undefined" == typeof key) {
  6644. return false;
  6645. }
  6646. lastNestingSeparator = key.indexOf("?");
  6647. if (0 < lastNestingSeparator) {
  6648. key = key.substring(0, lastNestingSeparator);
  6649. }
  6650. return key;
  6651. };
  6652. var skip;
  6653. skip = go();
  6654. (function after() {
  6655. var val = go();
  6656. if (val !== skip) {
  6657. next();
  6658. skip = val;
  6659. }
  6660. timeoutKey = self.setTimeout(after, 200, "trackHash");
  6661. })();
  6662. }
  6663. /**
  6664. * @param {?} callback
  6665. * @return {undefined}
  6666. */
  6667. function show(callback) {
  6668. if (false === callback) {
  6669. if (e) {
  6670. if ("onhashchange" in win) {
  6671. Event.un(win, "hashchange", handleClick);
  6672. } else {
  6673. self.clearTimeout(timeoutKey);
  6674. }
  6675. /** @type {boolean} */
  6676. e = false;
  6677. }
  6678. } else {
  6679. if (callback = handleClick, !e) {
  6680. if ("onhashchange" in win) {
  6681. Event.on(win, "hashchange", callback);
  6682. } else {
  6683. after(callback);
  6684. }
  6685. /** @type {boolean} */
  6686. e = true;
  6687. }
  6688. }
  6689. $.setTrackHash(e);
  6690. /** @type {boolean} */
  6691. that._trackHash = e;
  6692. }
  6693. /**
  6694. * @return {undefined}
  6695. */
  6696. function handleClick() {
  6697. var modes = {
  6698. ut : module,
  6699. ad : 1 == ret && (win.Ya && win.Ya.Direct),
  6700. wh : true,
  6701. saveRef : true,
  6702. pv : true
  6703. };
  6704. optsData = img.lastReferrer = h;
  6705. $.sendAjaxHit({
  6706. url : trigger().href,
  6707. title : dom.getDocumentTitle(),
  6708. referrer : optsData,
  6709. modes : modes
  6710. });
  6711. h = trigger().href;
  6712. }
  6713. /**
  6714. * @param {string} key
  6715. * @param {Array} k
  6716. * @param {Object} obj
  6717. * @return {undefined}
  6718. */
  6719. function loop(key, k, obj) {
  6720. key = jQuery.parseValidate(key, k);
  6721. /** @type {Array} */
  6722. k = [];
  6723. if (key) {
  6724. k.push(key);
  6725. obj = obj || {};
  6726. if (self.isFunction(obj.callback)) {
  6727. k.push(obj.callback);
  6728. if (obj.ctx) {
  6729. k.push(obj.ctx);
  6730. }
  6731. }
  6732. }
  6733. if (k.length) {
  6734. that.params.apply(that, k);
  6735. }
  6736. }
  6737. var counterIndex;
  6738. /** @type {string} */
  6739. var module = "";
  6740. var image;
  6741. var dataText;
  6742. var options;
  6743. /** @type {string} */
  6744. var optsData = "";
  6745. var h = img.lastReferrer = params.href;
  6746. var counterNum;
  6747. var $;
  6748. var key;
  6749. var controller;
  6750. var n;
  6751. var e;
  6752. var callback;
  6753. var herecomment;
  6754. var hid;
  6755. if (!Ya._metrika.counter) {
  6756. Ya._metrika.counter = that;
  6757. }
  6758. if ("object" == typeof data) {
  6759. /** @type {Object} */
  6760. options = data;
  6761. opt_length = data.defer;
  6762. module = data.ut;
  6763. ret = data.type;
  6764. count = data.params;
  6765. dataText = data.userParams;
  6766. image = options.experiments;
  6767. herecomment = options.nck;
  6768. data = data.id;
  6769. }
  6770. data = data || 0;
  6771. if (!/^\d+$/.test(data)) {
  6772. /** @type {number} */
  6773. data = 0;
  6774. }
  6775. ret = ret || 0;
  6776. /** @type {string} */
  6777. counterIndex = data + ":" + ret;
  6778. if (Ya._metrika.counters[counterIndex]) {
  6779. return Ya._metrika.counters[counterIndex];
  6780. }
  6781. hid = Ya._metrika.hitId;
  6782. Ya._metrika.counterNum++;
  6783. counterNum = Ya._metrika.counterNum;
  6784. if (!herecomment) {
  6785. instance.initCookie();
  6786. methods.init();
  6787. }
  6788. instance.retransmit();
  6789. $ = new klass({
  6790. protocol : "https:",
  6791. counterType : ret,
  6792. counterId : data,
  6793. hitId : hid,
  6794. counter : that,
  6795. dontSendRequests : dontSendRequests,
  6796. counterNum : counterNum
  6797. });
  6798. that.replacePhones = bind(function() {
  6799. var jsonString;
  6800. var prefix;
  6801. try {
  6802. if (jsonString = (new Controller({
  6803. counterId : data
  6804. })).read("mp2_substs")) {
  6805. if (prefix = JSON.parse(jsonString)) {
  6806. add(prefix, true);
  6807. }
  6808. }
  6809. } catch (B) {
  6810. }
  6811. return that;
  6812. }, "counter.replacePhones");
  6813. that.reachGoal = bind(function(urls, c, callback, contextOverride) {
  6814. if (2 <= arguments.length) {
  6815. if ("function" === typeof c) {
  6816. /** @type {(Function|string)} */
  6817. contextOverride = callback;
  6818. /** @type {(Function|string)} */
  6819. callback = c;
  6820. /** @type {(Function|string)} */
  6821. c = value;
  6822. }
  6823. }
  6824. console.log("Reach goal. Counter: " + data + ". Goal id: " + urls + ". Params: ", c);
  6825. $.sendGoal(urls, {
  6826. vParams : c,
  6827. callback : callback,
  6828. /** @type {Function} */
  6829. ctx : contextOverride
  6830. });
  6831. return that;
  6832. }, "counter.reachGoal");
  6833. that.trackLinks = bind(function(next) {
  6834. setup(next);
  6835. return that;
  6836. }, "counter.trackLinks");
  6837. n = new Node({
  6838. counterId : data
  6839. });
  6840. that.hit = bind(function(file, opts, text, config, callback, txn) {
  6841. if (file) {
  6842. if (self.isObject(opts)) {
  6843. text = opts.referer;
  6844. config = opts.params;
  6845. callback = opts.callback;
  6846. txn = opts.ctx;
  6847. opts = opts.title;
  6848. }
  6849. console.log("PageView. Counter " + data, ". URL: " + file, ". Referrer: " + text, ". Params: ", config);
  6850. $.sendHit({
  6851. url : file,
  6852. title : opts,
  6853. referrer : text,
  6854. /** @type {Function} */
  6855. vParams : config,
  6856. callback : callback,
  6857. ctx : txn
  6858. });
  6859. }
  6860. return that;
  6861. }, "counter.hit");
  6862. that.params = bind(function(dataAndEvents) {
  6863. /** @type {number} */
  6864. var len = arguments.length;
  6865. /** @type {number} */
  6866. var i = len;
  6867. var which;
  6868. var key;
  6869. /** @type {Array.<?>} */
  6870. var arg = [].slice.call(arguments, 0);
  6871. if (dataAndEvents) {
  6872. if (1 < arguments.length) {
  6873. if (self.isFunction(arguments[len - 1])) {
  6874. which = arguments[len - 1];
  6875. /** @type {number} */
  6876. i = len - 1;
  6877. } else {
  6878. if (self.isFunction(arguments[len - 2])) {
  6879. which = arguments[len - 2];
  6880. key = arguments[len - 1];
  6881. /** @type {number} */
  6882. i = len - 2;
  6883. }
  6884. }
  6885. /** @type {Array.<?>} */
  6886. arg = [].slice.call(arg, 0, i);
  6887. if (1 < arg.length) {
  6888. /** @type {Array} */
  6889. arg = [self.array2Props(arg)];
  6890. }
  6891. }
  6892. console.log("User params. Counter " + data + ". Params: ", arg[0]);
  6893. $.sendParams(arg[0], which, key);
  6894. }
  6895. return that;
  6896. }, "counter.params");
  6897. that.file = bind(function(requestUrl, options) {
  6898. if (requestUrl) {
  6899. options = options || {};
  6900. $.sendFileUpload({
  6901. url : requestUrl,
  6902. title : options.title,
  6903. vParams : options.params,
  6904. callback : options.callback,
  6905. ctx : options.ctx
  6906. });
  6907. }
  6908. return that;
  6909. }, "counter.file");
  6910. that.extLink = bind(function(requestUrl, options) {
  6911. if (requestUrl) {
  6912. options = options || {};
  6913. $.sendExtLink({
  6914. url : requestUrl,
  6915. title : options.title,
  6916. vParams : options.params,
  6917. callback : options.callback,
  6918. ctx : options.ctx
  6919. });
  6920. }
  6921. return that;
  6922. }, "counter.extLink");
  6923. that.notBounce = bind(function(options) {
  6924. /** @type {number} */
  6925. var diff = 0;
  6926. options = options || {};
  6927. if (aux) {
  6928. if (max) {
  6929. /** @type {number} */
  6930. diff = max - aux;
  6931. }
  6932. }
  6933. $.sendNotBounce(diff, {
  6934. callback : options.callback,
  6935. ctx : options.ctx
  6936. });
  6937. return that;
  6938. }, "counter.notBounce");
  6939. /** @type {Array} */
  6940. key = [];
  6941. /**
  6942. * @param {?} path
  6943. * @return {?}
  6944. */
  6945. that.addFileExtension = function(path) {
  6946. if ("string" == typeof path) {
  6947. key.push(path);
  6948. } else {
  6949. key = key.concat(path);
  6950. }
  6951. return that;
  6952. };
  6953. /**
  6954. * @param {boolean} deepDataAndEvents
  6955. * @return {?}
  6956. */
  6957. that.clickmap = function(deepDataAndEvents) {
  6958. fn(deepDataAndEvents);
  6959. return that;
  6960. };
  6961. /**
  6962. * @param {number} moduleId
  6963. * @return {?}
  6964. */
  6965. that.accurateTrackBounce = function(moduleId) {
  6966. create(moduleId);
  6967. return that;
  6968. };
  6969. /** @type {null} */
  6970. var timeoutKey = null;
  6971. /** @type {boolean} */
  6972. e = false;
  6973. /**
  6974. * @param {?} next_callback
  6975. * @return {?}
  6976. */
  6977. that.trackHash = function(next_callback) {
  6978. show(next_callback);
  6979. return that;
  6980. };
  6981. /**
  6982. * @param {Array} arr
  6983. * @param {Function} fn
  6984. * @param {?} thisv
  6985. * @return {?}
  6986. */
  6987. self.arrayEvery = function(arr, fn, thisv) {
  6988. var i;
  6989. /** @type {number} */
  6990. i = 0;
  6991. for (;i < arr.length;i++) {
  6992. if (!fn.call(thisv, arr[i], i, arr)) {
  6993. return false;
  6994. }
  6995. }
  6996. return true;
  6997. };
  6998. var jQuery = {
  6999. requiredEcommerceFields : ["currency", "goods"],
  7000. /**
  7001. * @param {string} event
  7002. * @param {Object} data
  7003. * @return {?}
  7004. */
  7005. parseValidate : function(event, data) {
  7006. var obj = this.validate(event, data);
  7007. var key;
  7008. if (!obj.isValid) {
  7009. return console && console.log(obj.message), false;
  7010. }
  7011. obj = {};
  7012. obj[event] = {};
  7013. if (data.currency) {
  7014. obj.currencyCode = data.currency;
  7015. }
  7016. if (data.goods) {
  7017. obj[event].products = data.goods;
  7018. }
  7019. for (key in data) {
  7020. if (data.hasOwnProperty(key)) {
  7021. if (-1 === self.arrayIndexOf(this.requiredEcommerceFields, key)) {
  7022. if (!obj[event].actionField) {
  7023. obj[event].actionField = {};
  7024. }
  7025. obj[event].actionField[key] = data[key];
  7026. }
  7027. }
  7028. }
  7029. return{
  7030. __ym : {
  7031. ecommerce : [obj]
  7032. }
  7033. };
  7034. },
  7035. /**
  7036. * @param {string} type
  7037. * @param {Object} collection
  7038. * @return {?}
  7039. */
  7040. validate : function(type, collection) {
  7041. /** @type {boolean} */
  7042. var isValid = false;
  7043. /** @type {string} */
  7044. var output = "";
  7045. if (self.isObject(collection)) {
  7046. switch(type) {
  7047. case "detail":
  7048. ;
  7049. case "add":
  7050. ;
  7051. case "remove":
  7052. if (self.isArray(collection.goods) && collection.goods.length) {
  7053. if (!(isValid = self.arrayEvery(collection.goods, function(result) {
  7054. return self.isObject(result) && (self.isString(result.id) || (self.isNumber(result.id) || (self.isString(result.name) || self.isString(result.name))));
  7055. }))) {
  7056. /** @type {string} */
  7057. output = "All items in 'goods' should be objects and contain 'id' or 'name' field";
  7058. }
  7059. } else {
  7060. /** @type {string} */
  7061. output = "Ecommerce data should contain 'goods' non-empty array";
  7062. }
  7063. break;
  7064. case "purchase":
  7065. if (self.isNumber(collection.id) || self.isString(collection.id)) {
  7066. /** @type {boolean} */
  7067. isValid = true;
  7068. } else {
  7069. /** @type {string} */
  7070. output = "Purchase object should contain string or number 'id' field";
  7071. }
  7072. ;
  7073. }
  7074. } else {
  7075. /** @type {string} */
  7076. output = "Ecommerce data should be an object";
  7077. }
  7078. return{
  7079. isValid : isValid,
  7080. message : output
  7081. };
  7082. }
  7083. };
  7084. that.ecommerceDetail = bind(function(k, walkers) {
  7085. loop("detail", k, walkers);
  7086. return that;
  7087. }, "ecommerce.detail");
  7088. that.ecommerceAdd = bind(function(k, walkers) {
  7089. loop("add", k, walkers);
  7090. return that;
  7091. }, "ecommerce.add");
  7092. that.ecommerceRemove = bind(function(k, walkers) {
  7093. loop("remove", k, walkers);
  7094. return that;
  7095. }, "ecommerce.remove");
  7096. that.ecommercePurchase = bind(function(k, walkers) {
  7097. loop("purchase", k, walkers);
  7098. return that;
  7099. }, "ecommerce.purchase");
  7100. that.userParams = bind(function(group, remote, rtt) {
  7101. if (self.isObject(group)) {
  7102. that.params({
  7103. __ymu : group
  7104. }, remote || function() {
  7105. }, rtt);
  7106. }
  7107. return that;
  7108. }, "uparams");
  7109. that.experiments = bind(function(dataAndEvents, callback, contextOverride) {
  7110. $.sendExperiments({
  7111. /** @type {Function} */
  7112. callback : callback,
  7113. ctx : contextOverride,
  7114. experiments : dataAndEvents
  7115. });
  7116. return that;
  7117. }, "exps");
  7118. that.id = that.setUserID = bind(function(i, remote, rtt) {
  7119. if (self.isString(i) || self.isNumber(i)) {
  7120. that.params({
  7121. __ym : {
  7122. user_id : i
  7123. }
  7124. }, remote || function() {
  7125. }, rtt);
  7126. }
  7127. return that;
  7128. }, "id");
  7129. controller = new Controller;
  7130. that.getClientID = bind(function() {
  7131. return controller.read("uid");
  7132. }, "guid");
  7133. /**
  7134. * @return {?}
  7135. */
  7136. that.enableAll = function() {
  7137. setup(true);
  7138. fn(true);
  7139. create();
  7140. return that;
  7141. };
  7142. /**
  7143. * @return {undefined}
  7144. */
  7145. that.uploadPage = function() {
  7146. };
  7147. /** @type {function (): ?} */
  7148. that._performanceTiming = parents;
  7149. if (data) {
  7150. if ("prerender" == doc.webkitVisibilityState) {
  7151. $.sendPrerenderHit({
  7152. url : params.href,
  7153. title : dom.getDocumentTitle(),
  7154. referrer : doc.referrer
  7155. });
  7156. /**
  7157. * @return {undefined}
  7158. */
  7159. callback = function() {
  7160. if ("prerender" != doc.webkitVisibilityState) {
  7161. Event.un(doc, "webkitvisibilitychange", callback);
  7162. trigger(true);
  7163. }
  7164. };
  7165. Event.on(doc, "webkitvisibilitychange", callback);
  7166. } else {
  7167. trigger(false);
  7168. }
  7169. }
  7170. }, "init")();
  7171. };
  7172. (function() {
  7173. if (win.performance && "function" === typeof performance.getEntries) {
  7174. var c = {
  7175. 2343947156 : 1,
  7176. 1996539654 : 1,
  7177. 2065498185 : 1,
  7178. 823651274 : 1,
  7179. 12282461 : 1,
  7180. 1555719328 : 1,
  7181. 1417229093 : 1,
  7182. 138396985 : 1
  7183. };
  7184. var codeSegments = performance.getEntries();
  7185. var old = {};
  7186. var t;
  7187. var name;
  7188. var eventName;
  7189. var i;
  7190. /** @type {number} */
  7191. i = 0;
  7192. for (;i < codeSegments.length;i++) {
  7193. t = codeSegments[i];
  7194. name = t.name.replace(/^https?:\/\//, "").split("?")[0];
  7195. eventName = self.fnv32a(name);
  7196. if (c[eventName]) {
  7197. if (!old[name]) {
  7198. if (0 < t.duration) {
  7199. old[name] = {
  7200. dns : Math.round(t.domainLookupEnd - t.domainLookupStart),
  7201. tcp : Math.round(t.connectEnd - t.connectStart),
  7202. duration : Math.round(t.duration),
  7203. response : Math.round(t.responseEnd - t.requestStart),
  7204. pages : params.href
  7205. };
  7206. }
  7207. }
  7208. }
  7209. }
  7210. (new Game({
  7211. sampling : 0.001
  7212. })).logParams({
  7213. timings8 : old
  7214. });
  7215. }
  7216. })();
  7217. if (!win.Ya._metrika.remoteCtrlInited) {
  7218. /** @type {boolean} */
  7219. win.Ya._metrika.remoteCtrlInited = true;
  7220. new sbp;
  7221. }
  7222. /**
  7223. * @return {?}
  7224. */
  7225. win.Ya.Metrika.counters = function() {
  7226. /** @type {Array} */
  7227. var results = [];
  7228. self.forEachKey(win.Ya._metrika.counters, function(pair, e) {
  7229. var d = pair.split(":");
  7230. results.push({
  7231. id : +d[0],
  7232. type : +d[1],
  7233. accurateTrackBounce : e._isAccurateTrackBounce,
  7234. clickmap : e._clickmap && e._clickmap._start,
  7235. oldCode : !!win.ya_cid,
  7236. trackHash : !!e._trackHash,
  7237. trackLinks : e._trackLinks && e._trackLinks.on,
  7238. webvisor : !!e._webvisor
  7239. });
  7240. });
  7241. return results;
  7242. };
  7243. if (win.ya_cid) {
  7244. if (Ya.Metrika) {
  7245. new Ya.Metrika(win.ya_cid, win.ya_params, win.ya_class);
  7246. }
  7247. }
  7248. if (win.ya_cid) {
  7249. if (!win.ya_hit) {
  7250. /**
  7251. * @param {?} deepDataAndEvents
  7252. * @param {?} opt_obj2
  7253. * @return {undefined}
  7254. */
  7255. win.ya_hit = function(deepDataAndEvents, opt_obj2) {
  7256. if (Ya._metrika.counter) {
  7257. Ya._metrika.counter.reachGoal(deepDataAndEvents, opt_obj2);
  7258. }
  7259. };
  7260. }
  7261. }
  7262. (function() {
  7263. /**
  7264. * @param {string} key
  7265. * @return {undefined}
  7266. */
  7267. function promote(key) {
  7268. try {
  7269. delete win[key];
  7270. } catch (m) {
  7271. /** @type {(Function|string)} */
  7272. win[key] = value;
  7273. }
  7274. }
  7275. var i = win.yandex_metrika_callback;
  7276. var codeSegments = win.yandex_metrika_callbacks;
  7277. var part;
  7278. if ("function" == typeof i) {
  7279. i();
  7280. }
  7281. if ("object" == typeof codeSegments) {
  7282. /** @type {number} */
  7283. i = 0;
  7284. for (;i < codeSegments.length;i++) {
  7285. if (part = codeSegments[i]) {
  7286. /** @type {null} */
  7287. codeSegments[i] = null;
  7288. part();
  7289. }
  7290. }
  7291. }
  7292. promote("yandex_metrika_callback");
  7293. promote("yandex_metrika_callbacks");
  7294. })();
  7295. /**
  7296. * @param {?} opt_attributes
  7297. * @return {undefined}
  7298. */
  7299. win.Ya.Metrika.informer = function(opt_attributes) {
  7300. /** @type {boolean} */
  7301. var b = !!Ya.Metrika._informer;
  7302. Ya.Metrika._informer = opt_attributes;
  7303. if (!b) {
  7304. dom.loadScript({
  7305. src : "https://informer.yandex.ru/metrika/informer.js"
  7306. });
  7307. }
  7308. };
  7309. Event.on(doc, "click", bind(function(event) {
  7310. var el = that.getTarget(event);
  7311. var _langCode;
  7312. var id;
  7313. if (el) {
  7314. if ("ym-advanced-informer" == el.className) {
  7315. _langCode = el.getAttribute("data-lang");
  7316. id = el.getAttribute("data-cid");
  7317. Ya.Metrika.informer({
  7318. i : el,
  7319. id : +id,
  7320. lang : _langCode
  7321. });
  7322. that.prevent(event);
  7323. }
  7324. }
  7325. }, "adv-inf"), null, {
  7326. passive : false
  7327. });
  7328. })(this, this.document);
Add Comment
Please, Sign In to add comment