Warning: Undefined array key "HTTP_ACCEPT_LANGUAGE" in /www/htdocs/w009a2fb/robertengelhardt.com/mapr.robertengelhardt.com/script.php on line 50
Warning: Cannot modify header information - headers already sent by (output started at /www/htdocs/w009a2fb/robertengelhardt.com/mapr.robertengelhardt.com/script.php:50) in /www/htdocs/w009a2fb/robertengelhardt.com/mapr.robertengelhardt.com/script.php on line 60
(function (window, document, token, url) {
var scollers = {};
var timer = {
scroll : null,
request : null
};
var collect = {
token : token,
url : url,
time : (new Date()).getTime() / 1000,
render : null,
screen : window.screen.width + 'x' + window.screen.height,
touch : !!('ontouchstart' in window || window.DocumentTouch && document instanceof DocumentTouch),
events : {}
};
function request (data, callback) {
var timeout, request, header = {};
if (window.XMLHttpRequest) {
request = new XMLHttpRequest();
} else if (window.ActiveXObject) {
request = new ActiveXObject("Microsoft.XMLHTTP");
}
if (request === void 0) {
return false;
}
request.open('POST', url + 'update', true);
request.setRequestHeader('Content-Type', 'application/json');
request.onreadystatechange = function () {
var status = this.status;
if (this.readyState === 4) {
window.clearTimeout(timeout);
if (typeof callback === 'function') {
if (status === 0) {
callback('timeout');
}
if (status >= 200 && status < 400) {
callback('done');
}
if (status >= 100 && status < 200 || status >= 400) {
callback('error');
}
}
}
};
timeout = window.setTimeout(function () {
request.abort();
}, 2000);
request.send(
JSON.stringify(data)
);
}
function attributes (target) {
var values = [];
for (var i = 0; i < target.attributes.length; ++i) {
if (target.attributes[i].name === 'class') {
continue;
}
if (target.attributes[i].name === 'id') {
values = [
'#' + target.id
];
break;
}
values[values.length] = '[' + target.attributes[i].name + '="' + target.attributes[i].value + '"]';
}
return values.join('') + (target.className !== '' ? '.' + target.className.split(' ').join('.') : '');
}
function domPath (target) {
var path = [];
while (target !== null && target !== document && target.localName !== 'body') {
path[path.length] = target.localName + attributes(target);
target = target.parentNode;
}
path.reverse();
return path.join(' > ');
}
function scrollObserver (data) {
var target = data.target;
while (target !== null) {
if (target.scrollHeight > target.clientHeight || target.scrollWidth > target.clientWidth) {
if (target.__scrollable === void 0 && ('body' in target) === false && target.localName !== 'html' && target !== document) {
target.__scrollable = true;
target.addEventListener('scroll', function (data) {
window.clearTimeout(target.__scrollTimer);
target.__scrollTimer = window.setTimeout(function () {
if (target.__scrollElementPath === void 0) {
target.__scrollElementPath = domPath(target);
}
event(data, target, target.__scrollElementPath);
}, 150);
}, true);
}
return true;
}
target = target.parentNode;
}
}
function event (event, target, domPath) {
var data = {
type : event.type,
time : (new Date()).getTime() / 1000,
scroll : {
path : domPath !== void 0 ? domPath : 'window',
x : event.type === 'scroll' && target !== void 0 ? target.scrollLeft : window.scrollX,
y : event.type === 'scroll' && target !== void 0 ? target.scrollTop : window.scrollY,
width : event.type === 'scroll' && target !== void 0 ? target.scrollWidth : document.body.scrollWidth,
height : event.type === 'scroll' && target !== void 0 ? target.scrollHeight : document.body.scrollHeight,
client : {
width : event.type === 'scroll' && target !== void 0 ? target.offsetWidth : document.body.clientWidth,
height : event.type === 'scroll' && target !== void 0 ? target.offsetHeight : document.body.clientHeight
}
}
};
if (event.pageX !== void 0 && event.pageY !== void 0) {
data.x = event.pageX;
data.y = event.pageY;
}
if (event.type.indexOf('touch') > -1) {
if (event.targetTouches.length > 0) {
data.x = event.targetTouches[0].pageX;
data.y = event.targetTouches[0].pageY;
} else if (event.changedTouches.length > 0) {
data.x = event.changedTouches[0].pageX;
data.y = event.changedTouches[0].pageY;
}
}
if (event.type === 'keydown' && 'form' in event.target) {
data.input = {
type : event.target.type,
name : event.target.name || false,
form : event.target.form !== null ? {
name : event.target.form.name || false,
action : event.target.form.getAttribute('action')
} : false
};
}
collect.events[data.time] = data;
}
if (window.performance !== void 0) {
window.addEventListener('load', function () {
window.setTimeout(function () {
var render, performance = window.performance;
if (typeof performance.now === 'function') {
render = performance.now();
} else if (performance.timing !== void 0) {
render = Date.now() - performance.timing.navigationStart;
} else if (typeof performance.getEntriesByType === 'function') {
var navigation = performance.getEntriesByType('navigation');
if (navigation.length > 0) {
render = navigation[0].duration;
}
}
collect.render = render;
}, 0);
}, false);
}
document.addEventListener('mousedown', function (data) {
event(data);
}, false);
document.addEventListener('mouseover', function (data) {
scrollObserver(data);
}, false);
document.addEventListener('touchstart', function (data) {
event(data);
}, false);
document.addEventListener('touchend', function (data) {
event(data);
}, false);
document.addEventListener('click', function (data) {
event(data);
}, false);
window.addEventListener('scroll', function (data) {
window.clearTimeout(timer.scroll);
timer.scroll = window.setTimeout(function () {
event(data);
}, 150);
}, false);
document.addEventListener('keydown', function (data) {
event(data);
}, false);
window.addEventListener('beforeunload', function (data) {
window.clearInterval(
timer.request
);
request(collect);
}, false);
timer.request = window.setInterval(function () {
var overload = JSON.parse(
JSON.stringify(collect)
);
collect.events = {};
request(overload);
}, 5000);
})(window, document, 1768073200, 'https://www.mapr.robertengelhardt.com/');