console.log('eyes - loading'); //var z = location.pathname.substring(location.pathname.lastIndexOf('/')+1); var jQueryScript = document.createElement('script'); jQueryScript.setAttribute('src','https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js'); document.head.appendChild(jQueryScript); function create_UUID(){ var dt = new Date().getTime(); var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { var r = (dt + Math.random()*16)%16 | 0; dt = Math.floor(dt/16); return (c=='x' ? r :(r&0x3|0x8)).toString(16); }); return uuid; } function getParentOrigin() { const locationAreDisctint = (window.location !== window.parent.location); const parentOrigin = ((locationAreDisctint ? document.referrer : document.location) || "").toString(); if (parentOrigin) { return new URL(parentOrigin).origin; } const currentLocation = document.location; if (currentLocation.ancestorOrigins && currentLocation.ancestorOrigins.length) { return currentLocation.ancestorOrigins[0]; } return ""; } document.addEventListener("DOMContentLoaded", function(event) { //do work /* $('body').hover(function() { console.log('eyes - hover'); }); */ //var eyesLayers=[]; window.eyesLayers = window.eyesLayers || []; // console.log(parent.dataLayer); try { window.top.location.href; hreflocation=window.top.location.href; datalayer=parent.dataLayer; } catch(e) { e; // => ReferenceError hreflocation='undefined'; datalayer={}; } // 'idEye' : {idEye}, console.log(getParentOrigin()); hreflocation=getParentOrigin(); eyesLayers.push({ 'uid' : create_UUID(), 'idEyes' : 2, 'referer': document.referrer, 'location': hreflocation, 'window' : {'width':screen.width,'height':screen.height,'color':screen.availTop}, 'iframe' : {'width':window.innerWidth,'height':window.innerHeight}, 'dataLayer': datalayer }); window.addEventListener('load', function() { // on ecoute le click sur la crea if (typeof clickTag !== 'undefined') { document.querySelector("body").onclick = function(){ console.log('eyes - click'); sendEyes('clic',clickTag); }; }else{ //document.querySelector("a").onclick = function(){ //console.log('eyes - click'); //sendEyes('clic',this.getAttribute("href")); // }; } // est ce qu il y a scroll var wallet=[]; if (typeof web3 !== 'undefined') { console.log('eyes - web3 is enabled') // console.log(web3.currentProvider) web3State='found'; if (web3.currentProvider.isMetaMask === true) { console.log('eyes - MetaMask is active') wallet.push('MetaMask'); } if (web3.currentProvider.isCoinbaseWallet === true) { console.log('eyes - Coinbase Wallet is active') wallet.push('Coinbase'); } } else { console.log('eyes - web3 is not found') eyesLayers.push('web3','not found'); web3State='not found'; } eyesLayers.push({ 'web3': web3State, 'wallet': wallet, }); sendEyes('load',''); // on recherche si la crea est visible observer.observe(document.querySelector("body")); }); // taille de l ecran //console.log('eyes - size browser viewport : '+$(window).width()+' x '+$(window).height()) //- returns height of browser viewport //console.log('eyes - size html document : '+$(document).width()+' x'+$(document).height()) //- returns height of HTML document //console.log($(window).scrollTop()) // var largeur_fenetre = screen.width ; // var hauteur_fenetre = screen.height; // var nbcolor =screen.availTop; // console.log('eyes - width x height / nb color : '+largeur_fenetre+ 'x'+hauteur_fenetre + ' / '+nbcolor) //var iframeWidth = window.innerWidth; //var iframeHeight = window.innerHeight; //console.log('eyes - size iframe : '+iframeWidth+' x '+iframeHeight) //var parentBody = window.parent.document.body // h1=$('h1', window.parent.document).html(); //console.log(parentBody); }) //console.log(window.parent.document.location.href) function sendEyes(event,value){ //console.log(JSON.stringify(eyesLayers)); //dl=l!='eyesLayers'?'&l='+l:''; //console.log(dl); ajax('POST', '//sondage.report/eyes/datas/', { // 'campaignid': $('#ad').attr('data-campaignid'), 'event': JSON.stringify({'event':event,'value':value}), 'eyesLayers': JSON.stringify(eyesLayers) }, function(response) { console.log('RESPONSE : ', response); }); } /* var observer = new IntersectionObserver((changes) => { for (const change of changes) { if (typeof change.isVisible === 'undefined') { // The browser doesn't support Intersection Observer v2, falling back to v1 behavior. change.isVisible = true; } if (change.isIntersecting && change.isVisible) { visibleSince = change.time; console.log('vu'); } else { visibleSince = 0; console.log('pas vu'); } } }, { threshold: [0], trackVisibility: true, delay: 100 }); */ var observer = new IntersectionObserver(function(entries) { console.log(entries) if(entries[0].isIntersecting === true) { console.log('Item has just APPEARED!' +entries[0]['intersectionRatio']+' '+entries[0]['time'] ) sendEyes('view',entries[0]['intersectionRatio']+' % '+entries[0]['time']+' ms'); } else { sendEyes('view','0 % '+entries[0]['time']+' ms'); } },{ threshold: [0], // trackVisibility: true, // delay: 100 }); function ajax(method, url, datas, callback) { $.ajax({ method: method, url: url, data: datas }) .done(function(msg) { if (callback) { callback(msg); } }); }