123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647 |
- (function webpackUniversalModuleDefinition(root, factory) {
- if(typeof exports === 'object' && typeof module === 'object')
- module.exports = factory();
- else if(typeof define === 'function' && define.amd)
- define([], factory);
- else {
- var a = factory();
- for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
- }
- })(this, function() {
- return /******/ (function(modules) { // webpackBootstrap
- /******/ // The module cache
- /******/ var installedModules = {};
- /******/
- /******/ // The require function
- /******/ function __webpack_require__(moduleId) {
- /******/
- /******/ // Check if module is in cache
- /******/ if(installedModules[moduleId]) {
- /******/ return installedModules[moduleId].exports;
- /******/ }
- /******/ // Create a new module (and put it into the cache)
- /******/ var module = installedModules[moduleId] = {
- /******/ i: moduleId,
- /******/ l: false,
- /******/ exports: {}
- /******/ };
- /******/
- /******/ // Execute the module function
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
- /******/
- /******/ // Flag the module as loaded
- /******/ module.l = true;
- /******/
- /******/ // Return the exports of the module
- /******/ return module.exports;
- /******/ }
- /******/
- /******/
- /******/ // expose the modules object (__webpack_modules__)
- /******/ __webpack_require__.m = modules;
- /******/
- /******/ // expose the module cache
- /******/ __webpack_require__.c = installedModules;
- /******/
- /******/ // define getter function for harmony exports
- /******/ __webpack_require__.d = function(exports, name, getter) {
- /******/ if(!__webpack_require__.o(exports, name)) {
- /******/ Object.defineProperty(exports, name, {
- /******/ configurable: false,
- /******/ enumerable: true,
- /******/ get: getter
- /******/ });
- /******/ }
- /******/ };
- /******/
- /******/ // getDefaultExport function for compatibility with non-harmony modules
- /******/ __webpack_require__.n = function(module) {
- /******/ var getter = module && module.__esModule ?
- /******/ function getDefault() { return module['default']; } :
- /******/ function getModuleExports() { return module; };
- /******/ __webpack_require__.d(getter, 'a', getter);
- /******/ return getter;
- /******/ };
- /******/
- /******/ // Object.prototype.hasOwnProperty.call
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
- /******/
- /******/ // __webpack_public_path__
- /******/ __webpack_require__.p = "";
- /******/
- /******/ // Load entry module and return exports
- /******/ return __webpack_require__(__webpack_require__.s = 13);
- /******/ })
- /************************************************************************/
- /******/ ([
- /* 0 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- module.exports = {
- xmetres: 20,
- ymetres: 80,
- fm: 'hot_click'
- };
- /***/ }),
- /* 1 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- var _config = __webpack_require__(0);
- var _config2 = _interopRequireDefault(_config);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- var getCount = function getCount(length, clientLength, metres) {
- return Math.round(length * metres / clientLength);
- };
- var getPx = function getPx(count, clientLength, metres) {
- return window.parseInt(count / metres * clientLength);
- };
- var isFixed = function isFixed(target) {
- return (window.getComputedStyle(target) || {}).position === 'fixed';
- };
- var matrix = {
- getCountPosition: function getCountPosition(event) {
- var target = event.target;
- var width = window.innerWidth;
- var height = window.innerHeight;
- if (matrix.checkInFixDom(target)) {
- return {
- x: getCount(event.clientX, width, _config2.default.xmetres),
- y: getCount(event.clientY, height, _config2.default.ymetres)
- };
- }
- return {
- x: getCount(event.clientX, width, _config2.default.xmetres),
- // 兼容ie
- y: getCount(event.clientY + document.documentElement.scrollTop, width, _config2.default.xmetres)
- };
- },
- getFlowPx: function getFlowPx(item, width) {
- item.x = getPx(item.loc_x, width, _config2.default.xmetres);
- item.y = getPx(item.loc_y, width, _config2.default.xmetres);
- return item;
- },
- getFixPx: function getFixPx(item, width, height) {
- item.x = getPx(item.loc_x, width, _config2.default.xmetres);
- item.y = getPx(item.loc_y, height, _config2.default.ymetres);
- return item;
- },
- getPxList: function getPxList(list, width, screenHeight) {
- var result = {
- flow: [],
- fix: []
- };
- var max = 0;
- list.forEach(function (item) {
- if (item.click_pv > max) {
- max = item.click_pv;
- }
- });
- if (max === 0) {
- return result;
- }
- list.forEach(function (item) {
- item.value = window.parseInt(item.click_pv / max * 100);
- if (item.is_fix * 1 === 0) {
- result.flow.push(matrix.getFlowPx(item, width));
- } else {
- result.fix.push(matrix.getFixPx(item, width, screenHeight));
- }
- });
- result.max = 100;
- return result;
- },
- checkInFixDom: function checkInFixDom(target) {
- var result = 0;
- if (isFixed(target)) {
- result = 1;
- } else {
- while (target.parentElement) {
- target = target.parentElement;
- if (isFixed(target)) {
- result = 1;
- break;
- }
- }
- }
- return result;
- }
- };
- exports.default = matrix;
- /***/ }),
- /* 2 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.middle = undefined;
- exports.default = getXPath;
- exports.shouldRerender = shouldRerender;
- exports.getShowBoundary = getShowBoundary;
- var _constants = __webpack_require__(3);
- /* eslint-disable */
- function getXPath(elm) {
- try {
- var allNodes = document.getElementsByTagName('*');
- for (var segs = []; elm && elm.nodeType == 1; elm = elm.parentNode) {
- if (elm.hasAttribute('id')) {
- var uniqueIdCount = 0;
- for (var n = 0; n < allNodes.length; n++) {
- if (allNodes[n].hasAttribute('id') && allNodes[n].id == elm.id) uniqueIdCount++;
- if (uniqueIdCount > 1) break;
- }
- if (uniqueIdCount == 1) {
- segs.unshift('//*[@id="' + elm.getAttribute('id') + '"]');
- return segs.join('/');
- } else {
- return false;
- }
- } else {
- for (var i = 1, sib = elm.previousSibling; sib; sib = sib.previousSibling) {
- if (sib.localName == elm.localName) i++;
- }
- if (i == 1) {
- if (elm.nextElementSibling) {
- if (elm.nextElementSibling.localName != elm.localName) {
- segs.unshift(elm.localName.toLowerCase());
- } else {
- segs.unshift(elm.localName.toLowerCase() + '[' + i + ']');
- }
- } else {
- segs.unshift(elm.localName.toLowerCase());
- }
- } else {
- segs.unshift(elm.localName.toLowerCase() + '[' + i + ']');
- }
- var title = elm.getAttribute('title');
- if (title) {
- segs[0] = segs[0] + '[@title="' + title + '"]';
- }
- }
- }
- return segs.length ? '/' + segs.join('/') : null;
- } catch (err) {
- console.log(err);
- return null;
- }
- }
- var lastPageY = void 0,
- lastBodyHeight = void 0;
- function shouldRerender(boundary) {
- var body = document.body.getBoundingClientRect();
- if (lastBodyHeight && lastBodyHeight !== body.height) {
- lastBodyHeight = body.height;
- return true;
- }
- lastBodyHeight = body.height;
- var pageY = window.pageYOffset;
- if (lastPageY === pageY) {
- return false;
- }
- var isScrollUp = pageY > lastPageY;
- lastPageY = pageY;
- if (!isScrollUp && pageY < boundary[0] + _constants.BLOCK_BUFFER && boundary[0] > 0) {
- return true;
- }
- if (isScrollUp && pageY > boundary[1] - _constants.BLOCK_BUFFER && boundary[1] < document.body.getBoundingClientRect().height) {
- return true;
- }
- return false;
- }
- function getShowBoundary() {
- var body = document.body.getBoundingClientRect();
- if (body.height <= _constants.MAX_HEIGHT) {
- return [0, body.height];
- }
- var pageY = window.pageYOffset;
- var top = Math.max(pageY - _constants.BLOCK_HEIGHT / 2 - _constants.BLOCK_BUFFER, 0);
- var bottom = Math.min(pageY + _constants.BLOCK_HEIGHT / 2 + _constants.BLOCK_BUFFER, body.height);
- return [top, bottom];
- }
- var middle = exports.middle = function middle(a, b, c) {
- return [a, b, c].sort(function (a, b) {
- return a - b;
- })[1];
- };
- /***/ }),
- /* 3 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- // https://stackoverflow.com/questions/12642222/canvascontext-fillrect-throws-ns-error-failure-exception-in-firefox
- // 对于超长的页面,每次仅绘制部分数据
- var MAX_HEIGHT = exports.MAX_HEIGHT = 7000;
- var BLOCK_HEIGHT = exports.BLOCK_HEIGHT = 5000;
- // 绘制的缓冲区域
- var BLOCK_BUFFER = exports.BLOCK_BUFFER = 1000;
- /***/ }),
- /* 4 */,
- /* 5 */,
- /* 6 */,
- /* 7 */,
- /* 8 */,
- /* 9 */,
- /* 10 */,
- /* 11 */,
- /* 12 */,
- /* 13 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _log = __webpack_require__(14);
- var _log2 = _interopRequireDefault(_log);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- window.document.addEventListener('click', _log2.default, true);
- /***/ }),
- /* 14 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- var _matrix = __webpack_require__(1);
- var _matrix2 = _interopRequireDefault(_matrix);
- var _config = __webpack_require__(0);
- var _spm = __webpack_require__(15);
- var _spm2 = _interopRequireDefault(_spm);
- var _util = __webpack_require__(2);
- var _util2 = _interopRequireDefault(_util);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- function log(event) {
- if (!event || !event.target || event.target.tagName === 'CANVAS') {
- return;
- }
- var spm = (0, _spm2.default)();
- var loc = _matrix2.default.getCountPosition(event);
- var isFixed = _matrix2.default.checkInFixDom(event.target);
- // 点击位置node
- var targetNode = event.target || event.srcElement;
- var xPath = (0, _util2.default)(targetNode) || '';
- // 目前有微页面在用,yzlogInstance 也是微页面的 logger 实例
- if (window.yzlogInstance) {
- window.yzlogInstance.log({
- et: 'custom',
- ei: 'hot_click',
- en: '热力图点击',
- params: {
- fm: _config.fm,
- spm: spm,
- is_fix: isFixed,
- loc_x: loc.x,
- loc_y: loc.y,
- xpath: xPath
- }
- });
- }
- };
- exports.default = log;
- /***/ }),
- /* 15 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- var _querystring = __webpack_require__(16);
- var _global = window._global || {};
- var getLastSpm = function getLastSpm() {
- if (!_global.spm) {
- return 'fake';
- }
- return _global.spm.logType + _global.spm.logId || 'fake' + _global.kdt_id;
- };
- function spm() {
- var spm = (0, _querystring.decode)(window.href).spam;
- var arr = [];
- if (spm) {
- arr = spm.split('_');
- if (arr.length > 2) {
- spm = arr[0] + '_' + arr[arr.length - 1];
- }
- spm += '_' + getLastSpm();
- } else {
- spm = getLastSpm();
- }
- return spm;
- }
- exports.default = spm;
- /***/ }),
- /* 16 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- exports.decode = exports.parse = __webpack_require__(17);
- exports.encode = exports.stringify = __webpack_require__(18);
- /***/ }),
- /* 17 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- // Copyright Joyent, Inc. and other Node contributors.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a
- // copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to permit
- // persons to whom the Software is furnished to do so, subject to the
- // following conditions:
- //
- // The above copyright notice and this permission notice shall be included
- // in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
- // If obj.hasOwnProperty has been overridden, then calling
- // obj.hasOwnProperty(prop) will break.
- // See: https://github.com/joyent/node/issues/1707
- function hasOwnProperty(obj, prop) {
- return Object.prototype.hasOwnProperty.call(obj, prop);
- }
- module.exports = function(qs, sep, eq, options) {
- sep = sep || '&';
- eq = eq || '=';
- var obj = {};
- if (typeof qs !== 'string' || qs.length === 0) {
- return obj;
- }
- var regexp = /\+/g;
- qs = qs.split(sep);
- var maxKeys = 1000;
- if (options && typeof options.maxKeys === 'number') {
- maxKeys = options.maxKeys;
- }
- var len = qs.length;
- // maxKeys <= 0 means that we should not limit keys count
- if (maxKeys > 0 && len > maxKeys) {
- len = maxKeys;
- }
- for (var i = 0; i < len; ++i) {
- var x = qs[i].replace(regexp, '%20'),
- idx = x.indexOf(eq),
- kstr, vstr, k, v;
- if (idx >= 0) {
- kstr = x.substr(0, idx);
- vstr = x.substr(idx + 1);
- } else {
- kstr = x;
- vstr = '';
- }
- k = decodeURIComponent(kstr);
- v = decodeURIComponent(vstr);
- if (!hasOwnProperty(obj, k)) {
- obj[k] = v;
- } else if (isArray(obj[k])) {
- obj[k].push(v);
- } else {
- obj[k] = [obj[k], v];
- }
- }
- return obj;
- };
- var isArray = Array.isArray || function (xs) {
- return Object.prototype.toString.call(xs) === '[object Array]';
- };
- /***/ }),
- /* 18 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- // Copyright Joyent, Inc. and other Node contributors.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a
- // copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to permit
- // persons to whom the Software is furnished to do so, subject to the
- // following conditions:
- //
- // The above copyright notice and this permission notice shall be included
- // in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
- var stringifyPrimitive = function(v) {
- switch (typeof v) {
- case 'string':
- return v;
- case 'boolean':
- return v ? 'true' : 'false';
- case 'number':
- return isFinite(v) ? v : '';
- default:
- return '';
- }
- };
- module.exports = function(obj, sep, eq, name) {
- sep = sep || '&';
- eq = eq || '=';
- if (obj === null) {
- obj = undefined;
- }
- if (typeof obj === 'object') {
- return map(objectKeys(obj), function(k) {
- var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;
- if (isArray(obj[k])) {
- return map(obj[k], function(v) {
- return ks + encodeURIComponent(stringifyPrimitive(v));
- }).join(sep);
- } else {
- return ks + encodeURIComponent(stringifyPrimitive(obj[k]));
- }
- }).join(sep);
- }
- if (!name) return '';
- return encodeURIComponent(stringifyPrimitive(name)) + eq +
- encodeURIComponent(stringifyPrimitive(obj));
- };
- var isArray = Array.isArray || function (xs) {
- return Object.prototype.toString.call(xs) === '[object Array]';
- };
- function map (xs, f) {
- if (xs.map) return xs.map(f);
- var res = [];
- for (var i = 0; i < xs.length; i++) {
- res.push(f(xs[i], i));
- }
- return res;
- }
- var objectKeys = Object.keys || function (obj) {
- var res = [];
- for (var key in obj) {
- if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key);
- }
- return res;
- };
- /***/ })
- /******/ ]);
- });
|