heatmap-log-1.0.11-min.js.下载 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory();
  4. else if(typeof define === 'function' && define.amd)
  5. define([], factory);
  6. else {
  7. var a = factory();
  8. for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
  9. }
  10. })(this, function() {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, {
  50. /******/ configurable: false,
  51. /******/ enumerable: true,
  52. /******/ get: getter
  53. /******/ });
  54. /******/ }
  55. /******/ };
  56. /******/
  57. /******/ // getDefaultExport function for compatibility with non-harmony modules
  58. /******/ __webpack_require__.n = function(module) {
  59. /******/ var getter = module && module.__esModule ?
  60. /******/ function getDefault() { return module['default']; } :
  61. /******/ function getModuleExports() { return module; };
  62. /******/ __webpack_require__.d(getter, 'a', getter);
  63. /******/ return getter;
  64. /******/ };
  65. /******/
  66. /******/ // Object.prototype.hasOwnProperty.call
  67. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  68. /******/
  69. /******/ // __webpack_public_path__
  70. /******/ __webpack_require__.p = "";
  71. /******/
  72. /******/ // Load entry module and return exports
  73. /******/ return __webpack_require__(__webpack_require__.s = 13);
  74. /******/ })
  75. /************************************************************************/
  76. /******/ ([
  77. /* 0 */
  78. /***/ (function(module, exports, __webpack_require__) {
  79. "use strict";
  80. module.exports = {
  81. xmetres: 20,
  82. ymetres: 80,
  83. fm: 'hot_click'
  84. };
  85. /***/ }),
  86. /* 1 */
  87. /***/ (function(module, exports, __webpack_require__) {
  88. "use strict";
  89. Object.defineProperty(exports, "__esModule", {
  90. value: true
  91. });
  92. var _config = __webpack_require__(0);
  93. var _config2 = _interopRequireDefault(_config);
  94. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  95. var getCount = function getCount(length, clientLength, metres) {
  96. return Math.round(length * metres / clientLength);
  97. };
  98. var getPx = function getPx(count, clientLength, metres) {
  99. return window.parseInt(count / metres * clientLength);
  100. };
  101. var isFixed = function isFixed(target) {
  102. return (window.getComputedStyle(target) || {}).position === 'fixed';
  103. };
  104. var matrix = {
  105. getCountPosition: function getCountPosition(event) {
  106. var target = event.target;
  107. var width = window.innerWidth;
  108. var height = window.innerHeight;
  109. if (matrix.checkInFixDom(target)) {
  110. return {
  111. x: getCount(event.clientX, width, _config2.default.xmetres),
  112. y: getCount(event.clientY, height, _config2.default.ymetres)
  113. };
  114. }
  115. return {
  116. x: getCount(event.clientX, width, _config2.default.xmetres),
  117. // 兼容ie
  118. y: getCount(event.clientY + document.documentElement.scrollTop, width, _config2.default.xmetres)
  119. };
  120. },
  121. getFlowPx: function getFlowPx(item, width) {
  122. item.x = getPx(item.loc_x, width, _config2.default.xmetres);
  123. item.y = getPx(item.loc_y, width, _config2.default.xmetres);
  124. return item;
  125. },
  126. getFixPx: function getFixPx(item, width, height) {
  127. item.x = getPx(item.loc_x, width, _config2.default.xmetres);
  128. item.y = getPx(item.loc_y, height, _config2.default.ymetres);
  129. return item;
  130. },
  131. getPxList: function getPxList(list, width, screenHeight) {
  132. var result = {
  133. flow: [],
  134. fix: []
  135. };
  136. var max = 0;
  137. list.forEach(function (item) {
  138. if (item.click_pv > max) {
  139. max = item.click_pv;
  140. }
  141. });
  142. if (max === 0) {
  143. return result;
  144. }
  145. list.forEach(function (item) {
  146. item.value = window.parseInt(item.click_pv / max * 100);
  147. if (item.is_fix * 1 === 0) {
  148. result.flow.push(matrix.getFlowPx(item, width));
  149. } else {
  150. result.fix.push(matrix.getFixPx(item, width, screenHeight));
  151. }
  152. });
  153. result.max = 100;
  154. return result;
  155. },
  156. checkInFixDom: function checkInFixDom(target) {
  157. var result = 0;
  158. if (isFixed(target)) {
  159. result = 1;
  160. } else {
  161. while (target.parentElement) {
  162. target = target.parentElement;
  163. if (isFixed(target)) {
  164. result = 1;
  165. break;
  166. }
  167. }
  168. }
  169. return result;
  170. }
  171. };
  172. exports.default = matrix;
  173. /***/ }),
  174. /* 2 */
  175. /***/ (function(module, exports, __webpack_require__) {
  176. "use strict";
  177. Object.defineProperty(exports, "__esModule", {
  178. value: true
  179. });
  180. exports.middle = undefined;
  181. exports.default = getXPath;
  182. exports.shouldRerender = shouldRerender;
  183. exports.getShowBoundary = getShowBoundary;
  184. var _constants = __webpack_require__(3);
  185. /* eslint-disable */
  186. function getXPath(elm) {
  187. try {
  188. var allNodes = document.getElementsByTagName('*');
  189. for (var segs = []; elm && elm.nodeType == 1; elm = elm.parentNode) {
  190. if (elm.hasAttribute('id')) {
  191. var uniqueIdCount = 0;
  192. for (var n = 0; n < allNodes.length; n++) {
  193. if (allNodes[n].hasAttribute('id') && allNodes[n].id == elm.id) uniqueIdCount++;
  194. if (uniqueIdCount > 1) break;
  195. }
  196. if (uniqueIdCount == 1) {
  197. segs.unshift('//*[@id="' + elm.getAttribute('id') + '"]');
  198. return segs.join('/');
  199. } else {
  200. return false;
  201. }
  202. } else {
  203. for (var i = 1, sib = elm.previousSibling; sib; sib = sib.previousSibling) {
  204. if (sib.localName == elm.localName) i++;
  205. }
  206. if (i == 1) {
  207. if (elm.nextElementSibling) {
  208. if (elm.nextElementSibling.localName != elm.localName) {
  209. segs.unshift(elm.localName.toLowerCase());
  210. } else {
  211. segs.unshift(elm.localName.toLowerCase() + '[' + i + ']');
  212. }
  213. } else {
  214. segs.unshift(elm.localName.toLowerCase());
  215. }
  216. } else {
  217. segs.unshift(elm.localName.toLowerCase() + '[' + i + ']');
  218. }
  219. var title = elm.getAttribute('title');
  220. if (title) {
  221. segs[0] = segs[0] + '[@title="' + title + '"]';
  222. }
  223. }
  224. }
  225. return segs.length ? '/' + segs.join('/') : null;
  226. } catch (err) {
  227. console.log(err);
  228. return null;
  229. }
  230. }
  231. var lastPageY = void 0,
  232. lastBodyHeight = void 0;
  233. function shouldRerender(boundary) {
  234. var body = document.body.getBoundingClientRect();
  235. if (lastBodyHeight && lastBodyHeight !== body.height) {
  236. lastBodyHeight = body.height;
  237. return true;
  238. }
  239. lastBodyHeight = body.height;
  240. var pageY = window.pageYOffset;
  241. if (lastPageY === pageY) {
  242. return false;
  243. }
  244. var isScrollUp = pageY > lastPageY;
  245. lastPageY = pageY;
  246. if (!isScrollUp && pageY < boundary[0] + _constants.BLOCK_BUFFER && boundary[0] > 0) {
  247. return true;
  248. }
  249. if (isScrollUp && pageY > boundary[1] - _constants.BLOCK_BUFFER && boundary[1] < document.body.getBoundingClientRect().height) {
  250. return true;
  251. }
  252. return false;
  253. }
  254. function getShowBoundary() {
  255. var body = document.body.getBoundingClientRect();
  256. if (body.height <= _constants.MAX_HEIGHT) {
  257. return [0, body.height];
  258. }
  259. var pageY = window.pageYOffset;
  260. var top = Math.max(pageY - _constants.BLOCK_HEIGHT / 2 - _constants.BLOCK_BUFFER, 0);
  261. var bottom = Math.min(pageY + _constants.BLOCK_HEIGHT / 2 + _constants.BLOCK_BUFFER, body.height);
  262. return [top, bottom];
  263. }
  264. var middle = exports.middle = function middle(a, b, c) {
  265. return [a, b, c].sort(function (a, b) {
  266. return a - b;
  267. })[1];
  268. };
  269. /***/ }),
  270. /* 3 */
  271. /***/ (function(module, exports, __webpack_require__) {
  272. "use strict";
  273. Object.defineProperty(exports, "__esModule", {
  274. value: true
  275. });
  276. // https://stackoverflow.com/questions/12642222/canvascontext-fillrect-throws-ns-error-failure-exception-in-firefox
  277. // 对于超长的页面,每次仅绘制部分数据
  278. var MAX_HEIGHT = exports.MAX_HEIGHT = 7000;
  279. var BLOCK_HEIGHT = exports.BLOCK_HEIGHT = 5000;
  280. // 绘制的缓冲区域
  281. var BLOCK_BUFFER = exports.BLOCK_BUFFER = 1000;
  282. /***/ }),
  283. /* 4 */,
  284. /* 5 */,
  285. /* 6 */,
  286. /* 7 */,
  287. /* 8 */,
  288. /* 9 */,
  289. /* 10 */,
  290. /* 11 */,
  291. /* 12 */,
  292. /* 13 */
  293. /***/ (function(module, exports, __webpack_require__) {
  294. "use strict";
  295. var _log = __webpack_require__(14);
  296. var _log2 = _interopRequireDefault(_log);
  297. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  298. window.document.addEventListener('click', _log2.default, true);
  299. /***/ }),
  300. /* 14 */
  301. /***/ (function(module, exports, __webpack_require__) {
  302. "use strict";
  303. Object.defineProperty(exports, "__esModule", {
  304. value: true
  305. });
  306. var _matrix = __webpack_require__(1);
  307. var _matrix2 = _interopRequireDefault(_matrix);
  308. var _config = __webpack_require__(0);
  309. var _spm = __webpack_require__(15);
  310. var _spm2 = _interopRequireDefault(_spm);
  311. var _util = __webpack_require__(2);
  312. var _util2 = _interopRequireDefault(_util);
  313. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  314. function log(event) {
  315. if (!event || !event.target || event.target.tagName === 'CANVAS') {
  316. return;
  317. }
  318. var spm = (0, _spm2.default)();
  319. var loc = _matrix2.default.getCountPosition(event);
  320. var isFixed = _matrix2.default.checkInFixDom(event.target);
  321. // 点击位置node
  322. var targetNode = event.target || event.srcElement;
  323. var xPath = (0, _util2.default)(targetNode) || '';
  324. // 目前有微页面在用,yzlogInstance 也是微页面的 logger 实例
  325. if (window.yzlogInstance) {
  326. window.yzlogInstance.log({
  327. et: 'custom',
  328. ei: 'hot_click',
  329. en: '热力图点击',
  330. params: {
  331. fm: _config.fm,
  332. spm: spm,
  333. is_fix: isFixed,
  334. loc_x: loc.x,
  335. loc_y: loc.y,
  336. xpath: xPath
  337. }
  338. });
  339. }
  340. };
  341. exports.default = log;
  342. /***/ }),
  343. /* 15 */
  344. /***/ (function(module, exports, __webpack_require__) {
  345. "use strict";
  346. Object.defineProperty(exports, "__esModule", {
  347. value: true
  348. });
  349. var _querystring = __webpack_require__(16);
  350. var _global = window._global || {};
  351. var getLastSpm = function getLastSpm() {
  352. if (!_global.spm) {
  353. return 'fake';
  354. }
  355. return _global.spm.logType + _global.spm.logId || 'fake' + _global.kdt_id;
  356. };
  357. function spm() {
  358. var spm = (0, _querystring.decode)(window.href).spam;
  359. var arr = [];
  360. if (spm) {
  361. arr = spm.split('_');
  362. if (arr.length > 2) {
  363. spm = arr[0] + '_' + arr[arr.length - 1];
  364. }
  365. spm += '_' + getLastSpm();
  366. } else {
  367. spm = getLastSpm();
  368. }
  369. return spm;
  370. }
  371. exports.default = spm;
  372. /***/ }),
  373. /* 16 */
  374. /***/ (function(module, exports, __webpack_require__) {
  375. "use strict";
  376. exports.decode = exports.parse = __webpack_require__(17);
  377. exports.encode = exports.stringify = __webpack_require__(18);
  378. /***/ }),
  379. /* 17 */
  380. /***/ (function(module, exports, __webpack_require__) {
  381. "use strict";
  382. // Copyright Joyent, Inc. and other Node contributors.
  383. //
  384. // Permission is hereby granted, free of charge, to any person obtaining a
  385. // copy of this software and associated documentation files (the
  386. // "Software"), to deal in the Software without restriction, including
  387. // without limitation the rights to use, copy, modify, merge, publish,
  388. // distribute, sublicense, and/or sell copies of the Software, and to permit
  389. // persons to whom the Software is furnished to do so, subject to the
  390. // following conditions:
  391. //
  392. // The above copyright notice and this permission notice shall be included
  393. // in all copies or substantial portions of the Software.
  394. //
  395. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  396. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  397. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  398. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  399. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  400. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  401. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  402. // If obj.hasOwnProperty has been overridden, then calling
  403. // obj.hasOwnProperty(prop) will break.
  404. // See: https://github.com/joyent/node/issues/1707
  405. function hasOwnProperty(obj, prop) {
  406. return Object.prototype.hasOwnProperty.call(obj, prop);
  407. }
  408. module.exports = function(qs, sep, eq, options) {
  409. sep = sep || '&';
  410. eq = eq || '=';
  411. var obj = {};
  412. if (typeof qs !== 'string' || qs.length === 0) {
  413. return obj;
  414. }
  415. var regexp = /\+/g;
  416. qs = qs.split(sep);
  417. var maxKeys = 1000;
  418. if (options && typeof options.maxKeys === 'number') {
  419. maxKeys = options.maxKeys;
  420. }
  421. var len = qs.length;
  422. // maxKeys <= 0 means that we should not limit keys count
  423. if (maxKeys > 0 && len > maxKeys) {
  424. len = maxKeys;
  425. }
  426. for (var i = 0; i < len; ++i) {
  427. var x = qs[i].replace(regexp, '%20'),
  428. idx = x.indexOf(eq),
  429. kstr, vstr, k, v;
  430. if (idx >= 0) {
  431. kstr = x.substr(0, idx);
  432. vstr = x.substr(idx + 1);
  433. } else {
  434. kstr = x;
  435. vstr = '';
  436. }
  437. k = decodeURIComponent(kstr);
  438. v = decodeURIComponent(vstr);
  439. if (!hasOwnProperty(obj, k)) {
  440. obj[k] = v;
  441. } else if (isArray(obj[k])) {
  442. obj[k].push(v);
  443. } else {
  444. obj[k] = [obj[k], v];
  445. }
  446. }
  447. return obj;
  448. };
  449. var isArray = Array.isArray || function (xs) {
  450. return Object.prototype.toString.call(xs) === '[object Array]';
  451. };
  452. /***/ }),
  453. /* 18 */
  454. /***/ (function(module, exports, __webpack_require__) {
  455. "use strict";
  456. // Copyright Joyent, Inc. and other Node contributors.
  457. //
  458. // Permission is hereby granted, free of charge, to any person obtaining a
  459. // copy of this software and associated documentation files (the
  460. // "Software"), to deal in the Software without restriction, including
  461. // without limitation the rights to use, copy, modify, merge, publish,
  462. // distribute, sublicense, and/or sell copies of the Software, and to permit
  463. // persons to whom the Software is furnished to do so, subject to the
  464. // following conditions:
  465. //
  466. // The above copyright notice and this permission notice shall be included
  467. // in all copies or substantial portions of the Software.
  468. //
  469. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  470. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  471. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  472. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  473. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  474. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  475. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  476. var stringifyPrimitive = function(v) {
  477. switch (typeof v) {
  478. case 'string':
  479. return v;
  480. case 'boolean':
  481. return v ? 'true' : 'false';
  482. case 'number':
  483. return isFinite(v) ? v : '';
  484. default:
  485. return '';
  486. }
  487. };
  488. module.exports = function(obj, sep, eq, name) {
  489. sep = sep || '&';
  490. eq = eq || '=';
  491. if (obj === null) {
  492. obj = undefined;
  493. }
  494. if (typeof obj === 'object') {
  495. return map(objectKeys(obj), function(k) {
  496. var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;
  497. if (isArray(obj[k])) {
  498. return map(obj[k], function(v) {
  499. return ks + encodeURIComponent(stringifyPrimitive(v));
  500. }).join(sep);
  501. } else {
  502. return ks + encodeURIComponent(stringifyPrimitive(obj[k]));
  503. }
  504. }).join(sep);
  505. }
  506. if (!name) return '';
  507. return encodeURIComponent(stringifyPrimitive(name)) + eq +
  508. encodeURIComponent(stringifyPrimitive(obj));
  509. };
  510. var isArray = Array.isArray || function (xs) {
  511. return Object.prototype.toString.call(xs) === '[object Array]';
  512. };
  513. function map (xs, f) {
  514. if (xs.map) return xs.map(f);
  515. var res = [];
  516. for (var i = 0; i < xs.length; i++) {
  517. res.push(f(xs[i], i));
  518. }
  519. return res;
  520. }
  521. var objectKeys = Object.keys || function (obj) {
  522. var res = [];
  523. for (var key in obj) {
  524. if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key);
  525. }
  526. return res;
  527. };
  528. /***/ })
  529. /******/ ]);
  530. });