if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(get_Position); } else { potnxx = ''; } class analytics { constructor(id, id_domain, ancestor_origins, location, position, browser, reference, iframe, firsttime, lasttime, metadata, status) { this.id = id; this.id_domain = id_domain; this.ancestor_origins = ancestor_origins; this.location = location; this.position = position; this.browser = browser; this.reference = reference; this.iframe = iframe; this.firsttime = firsttime; this.lasttime = lasttime; this.metadata = metadata; this.status = status; } } analytics.id = ''; analytics.id_domain = null; analytics.ancestor_origins = window.location.ancestorOrigins[0]; analytics.location = window.location; analytics.position = ''; analytics.browser = get_browser(); analytics.reference = get_reference(); analytics.iframe = get_isiframe(); analytics.firsttime = get_currentdate(); analytics.lasttime = get_currentdate(); analytics.metadata = ''; analytics.status = ''; let url_ajaxxx = "//api.analyticsweb.co" let xhttprest = new XMLHttpRequest(); setInterval(update, 15000); document.addEventListener("DOMContentLoaded", function (event) { xhttprest.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200) { objxx = JSON.parse(this.responseText); analytics.id = objxx.id; } }; ajax(url_ajaxxx, analytics.id, analytics.id_domain, analytics.ancestor_origins, analytics.location, analytics.position, analytics.browser, analytics.reference, analytics.iframe, analytics.firsttime, analytics.lasttime, analytics.metadata, analytics.status); }); function ajax(url, id, id_domain, ancestor_origins, location, position, browser, reference, iframe, firsttime, lasttime, metadata, status) { xhttprest.open("POST", url, true); xhttprest.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xhttprest.send("id=" + id + "&id_domain=" + id_domain + "&ancestor_origins=" + ancestor_origins + "&location=" + location + "&position=" + position + "&browser=" + browser + "&reference=" + reference + "&iframe=" + iframe + "&firsttime=" + firsttime + "&lasttime=" + lasttime + "&metadata=" + metadata + "&status=" + status); } function get_Position(position) { potnxx = JSON.stringify({latitude: position.coords.latitude, longitude: position.coords.longitude}); } function update() { let currentdatefm = get_currentdate(); ajax(url_ajaxxx, analytics.id, analytics.id_domain, analytics.ancestor_origins, analytics.location, analytics.position, analytics.browser, analytics.reference, analytics.iframe, analytics.firsttime, currentdatefm, analytics.metadata, analytics.status); } function get_currentdate() { let currentdate = new Date(); let currentdatefmf = currentdate.getFullYear() + '-' + (currentdate.getMonth() + 1) + '-' + currentdate.getDate() + ' ' + currentdate.getHours() + ':' + currentdate.getMinutes() + ':' + currentdate.getSeconds(); return currentdatefmf; } function get_browser() { let browser; let isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0; let isFirefox = typeof InstallTrigger !== 'undefined'; let isSafari = navigator.vendor && navigator.vendor.indexOf('Apple') > -1 && navigator.userAgent && navigator.userAgent.indexOf('CriOS') == -1 && navigator.userAgent.indexOf('FxiOS') == -1; let isIE = /*@cc_on!@*/false || !!document.documentMode; let isEdge = document.documentMode || /Edge/.test(navigator.userAgent) || /Edg/.test(navigator.userAgent); let isChrome = !!window.chrome && (!!window.chrome.webstore || !!window.chrome.runtime); (isOpera) ? browser = 'Opera' : (isFirefox) ? browser = 'Firefox' : (isSafari) ? browser = 'Safari' : (isIE) ? browser = 'IE' : (isEdge) ? browser = 'Edge' : (isChrome) ? browser = 'Chrome' : ''; return browser; } function get_isiframe() { //if (window.location !== window.parent.location || window.top !== window.self) { // let url = window.location.ancestorOrigins[0]; // let domainname = url.match(/:\/\/(.[^/]+)/)[1]; // return JSON.stringify({domain: domainname, url: url}); //} return window.location !== window.parent.location || window.top !== window.self; } function get_reference() { if (document.referrer) { let url = document.referrer; let domainname = url.match(/:\/\/(.[^/]+)/)[1]; let reference = JSON.stringify({domain: domainname, url: url}); return reference; } }