We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(function (win, doc, undef){ var _win = win, _doc = doc, _undef = undef; Function.prototype.map = function (callback) { var len = this.length for(var i = 0 ; i < len ; i ++) { this[i] = callback.call(this, this[i], i, this) } return this; } Function.prototype.reduce = function (callback, initValue) { var len = this.length var sum = initValue || this[0] for(var i = 0 ; i < len ; i ++) { if(!initValue && i === 0) { continue; } sum = callback.call(this, sum, this[i], i, this) } return this; } var type = (function () { return ['Object', 'Array'].reduce(function (prev, next){ prev[next] = function (value) { return Object.prototype.toString.call(value) === '[object '+ next +']' } return prev }, {}) })(); function handleClickEvent (e) { var target = e.currentTarget; sendReporter(e.clientX, e.clientY, e.screenX , e.screenY) } window.handleClickEvent = handleClickEvent function getRandomId () { return ('' + Math.random()).slice(2, 10) } function handleUserScrollEvent (element) { var timeout = 200; var randomId = getRandomId() var xlist = [] var ylist = [] var sxlist = [] var sylist = [] function getEventList (e, x, y , sx, sy) { // console.log(e) e = e.targetTouches[0] x.push(e.clientX) y.push(e.clientY) sx.push(e.screenX) sy.push(e.screenY) } function handleTouchEventStart (e) { getEventList(e, xlist, ylist, sxlist, sylist) } function handleTouchEventScrolling (e) { getEventList(e, xlist, ylist, sxlist, sylist) } function handleTouchEventEnd (e) { sendReporter(xlist,ylist,sxlist,sylist) xlist = ylist = sxlist = sylist = [] } window.document.addEventListener('touchstart', handleTouchEventStart) window.document.addEventListener('touchmove', handleTouchEventScrolling) window.document.addEventListener('touchend', handleTouchEventEnd) } window.handleUserScrollEvent = handleUserScrollEvent function object2Query (obj) { return Object.keys(obj).map(function (item ){ if(type.Array(obj[item])) { return [item, obj[item].join(',')].join('=') } return [item, obj[item]].join('=') }).join('&') } function sendReporter(x, y, screenX , screenY) { function createReporterUrl(link, callback, errorcallback) { var image = new Image() image.src = link image.error = errorcallback image.onsuccess = callback; } var host = window.location.host var link = host + '?' + object2Query({ x,y,screenX ,screenY,link }) createReporterUrl(link, null, null) } })(window, document, undefined);
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> </head> <body> <button id="btn">testtest</button> <script src="./index.js"></script> <script> window.onload = function (){ // document.querySelector('#btn').addEventListener('click', window.handleClickEvent) window.handleUserScrollEvent() } </script> </body> </html>
done
The text was updated successfully, but these errors were encountered:
No branches or pull requests
done
The text was updated successfully, but these errors were encountered: