var dmleyeEchoWrapperElement = document.getElementById("dml_eyeEcho_wrapper"); dmleyeEchoWrapperElement.style.transition = "all 0.5s;"; var eyeEcho_banner_cta_active = true; var eyeEchoCSSid = 'eyeEchoStyleSheet'; let sessionTimeString = (new Date()).getTime(); var eyeEcho_pagehead = document.getElementsByTagName('head')[0]; var eyeEcho_pagelink = document.createElement('link'); eyeEcho_pagelink.id = eyeEchoCSSid; eyeEcho_pagelink.rel = 'stylesheet'; eyeEcho_pagelink.type = 'text/css'; eyeEcho_pagelink.href = 'https://eyeecho.herokuapp.com/stylesheets/style.min.css?'+sessionTimeString; eyeEcho_pagelink.media = 'all'; eyeEcho_pagehead.appendChild(eyeEcho_pagelink); window.eyeEcho_forcedLanguageCode = typeof window.eyeEcho_forcedLanguageCode != "undefined" ? window.eyeEcho_forcedLanguageCode : ""; window.eyeEcho_hasBanner = typeof window.eyeEcho_hasBanner != "undefined" ? window.eyeEcho_hasBanner : true; window.eyeEcho_isEmbed = typeof window.eyeEcho_isEmbed != "undefined" ? window.eyeEcho_isEmbed : true; window.eyeEcho_maxwidth = typeof window.eyeEcho_maxwidth != "undefined" ? window.eyeEcho_maxwidth : "100%"; window.eyeEcho_maxheight = typeof window.eyeEcho_maxheight != "undefined" ? window.eyeEcho_maxheight : window.innerHeight +"px"; window.eyeEcho_bannerwidth= typeof window.eyeEcho_bannerwidth != "undefined" ? window.eyeEcho_bannerwidth : "100%"; window.eyeEcho_banner_cta_title= typeof window.eyeEcho_banner_cta_title != "undefined" ? window.eyeEcho_banner_cta_title : "eyeEcho touch"; window.eyeEcho_banner_cta_text= typeof window.eyeEcho_banner_cta_text != "undefined" ? window.eyeEcho_banner_cta_text : "reawaken your skin with the power of touch"; window.eyeEcho_banner_cta_button= typeof window.eyeEcho_banner_cta_button != "undefined" ? window.eyeEcho_banner_cta_button : "show me how"; dmleyeEchoWrapperElement.style.width = window.eyeEcho_maxwidth; function logOnLocalHostFrontEnd(inStringBefore,inVariable){ inStringBefore = (inStringBefore === undefined) ? '' : inStringBefore; if (/localhost/g.test("https://eyeecho.herokuapp.com") || /192\.168\.0\./g.test("https://eyeecho.herokuapp.com") || /\.ngrok\.io/g.test("https://eyeecho.herokuapp.com") || /facemappingconsumer-staging\.herokuapp/g.test("https://eyeecho.herokuapp.com")){ if (inVariable == undefined){ console.log(inStringBefore) }else{ console.log(inStringBefore, inVariable) } } } // GA - START window.eyeEchoGAsetup = false; function eyeEchoSendGA(eventName, eventCategory){ eventCategory = (eventCategory == undefined) ? "general" : eventCategory; if (window.eyeEchoGAsetup){ if (window.gtag) { logOnLocalHostFrontEnd("gtag event: ", eventName + " - " + eventCategory); window.gtag('event', eventName, {event_category: eventCategory}); }else if (window.ga) { window.ga('eyeEcho_gtag.send', 'event', eventCategory, eventName); logOnLocalHostFrontEnd("ga event: ", eventName + " - " + eventCategory); } else if (window._gaq) { logOnLocalHostFrontEnd("_gaq event: ", eventName + " - " + eventCategory); window._gaq.push(['eyeEcho_gtag._trackEvent',eventCategory,eventName]); } } } function eyeEchoSetupGA(){ let pageTitle ="not found"; pageTitle = window.location.hostname; if (window.gtag) { window.gtag('config', 'UA-36853599-31', { 'anonymize_ip': true, 'page_title': pageTitle , 'page_location': window.location.href, 'page_path': window.location.href }); }else if (window.ga) { window.ga('create', 'UA-36853599-31', 'auto', 'eyeEcho_gtag'); // change with new value! window.ga('eyeEcho_gtag.set','anonymizeIp', true); window.ga('eyeEcho_gtag.send','pageview',window.location.href); } else if (window._gaq) { window._gaq.push(['eyeEcho_gtag._setAccount','UA-36853599-31'],['eyeEcho_gtag._trackPageview']); } window.eyeEchoGAsetup = true; } //eyeEchoSetupGA(); // GA - END function getEmbedHtmlData(url, callback){ let request = new XMLHttpRequest(); request.open('GET', url, true); request.onload = function() { if (request.status >= 200 && request.status < 400) { // Success! callback({"status": "success","status_code":request.status, "data" : request.responseText}); } else { // We reached our target server, but it returned an error callback({"status": "success","status_code":request.status, "data" : "We reached our target server, but it returned an error"}); } }; request.onerror = function() { // There was a connection error of some sort callback({"error": "success","status_code":request.status, "data" : "Error occured in getting html data"}); }; request.send(); } function dmleyeEcho_getScript(source, callback) { //console.log('inside get script call'); var script = document.createElement('script'); //var prior = document.getElementsByTagName('script')[0]; script.async = 1; script.onload = function(evt) { //console.log(source ," ready state: ",evt); callback({"status":"success","message":"done"}); }; script.onerror = function(err){ console.log(err) callback({"status":"error", "message":"error in getting script " + source}); } script.setAttribute('type','text/javascript'); script.src = source; dmleyeEchoWrapperElement.appendChild(script); } function dmleyeEcho_getScript_withAttributes(source, attributeObj, callback) { //console.log('inside get script call'); var script = document.createElement('script'); //var prior = document.getElementsByTagName('script')[0]; script.async = 1; script.onload = function(evt) { //console.log(source ," ready state: ",evt); callback({"status":"success","message":"done"}); }; script.onerror = function(err){ console.log(err) callback({"status":"error", "message":"error in getting script " + source}); } script.setAttribute('type','text/javascript'); try{ Object.keys(attributeObj).forEach( function(attrKey){ script.setAttribute(attrKey,attributeObj[attrKey]); }); }catch(err){ console.log(err); } script.src = source; dmleyeEchoWrapperElement.appendChild(script); } function eyeEchoOpenApp(){ eyeEchoSetupGA() //dmleyeEchoWrapperElement.style.height = document.documentElement.clientHeight + "px"; setTimeout(function(){eyeEchoSendGA("open app","flow");},1000); getEmbedHtmlData('https://eyeecho.herokuapp.com/eyeEcho?'+sessionTimeString, function(res) { window.data = res.data; if (window.eyeEcho_isEmbed){ if (window.eyeEcho_hasBanner){ let eyeEchoBannerElement = document.getElementById("eyeEcho_cta_banner"); eyeEchoBannerElement.style.opacity = 0; } setTimeout(function(){ dmleyeEchoWrapperElement.innerHTML = res.data + dmleyeEchoWrapperElement.innerHTML; if (window.eyeEcho_hasBanner){ document.getElementById("eyeEcho_cta_banner").style.display = "none"; } //dmleyeEchoWrapperElement.style.height = "auto"; //dmleyeEchoWrapperElement.style.maxHeight = window.eyeEcho_maxheight; //document.getElementById("eyeEcho_body").style.height= "auto"; //document.getElementById("eyeEcho_body").style.transform = "scale("+dmleyeEchoWrapperElement.offsetWidth/document.documentElement.clientWidth+")"; dmleyeEcho_getScript('https://eyeecho.herokuapp.com/script.js?'+sessionTimeString,function(){ document.getElementById("eyeEcho_body").style.opacity = 1; }); },500) }else{ dmleyeEchoWrapperElement.innerHTML = res.data + dmleyeEchoWrapperElement.innerHTML; dmleyeEchoWrapperElement.style.height=document.documentElement.clientHeight + "px"; dmleyeEcho_getScript('https://eyeecho.herokuapp.com/script.js?'+sessionTimeString,function(){ document.getElementById("eyeEcho_body").style.opacity = 1; }); } }) } function eyeEchoMakeBanner(){ let bannerWidth; if (window.eyeEcho_bannerwidth.indexOf("%")>-1){ bannerWidth = dmleyeEchoWrapperElement.offsetWidth * Number(window.eyeEcho_bannerwidth.replace("%",""))/100; }else{ bannerWidth = Number(window.eyeEcho_bannerwidth.replace("px","").replace("%","")); } if (bannerWidth>500){ dmleyeEchoWrapperElement.innerHTML += '
'+ '

'+eyeEcho_banner_cta_title+'

'+window.eyeEcho_banner_cta_text+'

'+window.eyeEcho_banner_cta_button+'

' document.getElementById("eyeEcho_cta_banner").style.backgroundImage ="url('https://eyeecho.herokuapp.com/img/eyeEcho-touch-pdp.jpg')"; }else{ dmleyeEchoWrapperElement.innerHTML += '
'+ '

'+eyeEcho_banner_cta_title+'

'+window.eyeEcho_banner_cta_text+'

'+window.eyeEcho_banner_cta_button+'

' document.getElementById("eyeEcho_cta_banner").style.backgroundImage ="url('https://eyeecho.herokuapp.com/img/eyeEcho-touch-mobile-image.jpg')"; document.getElementById("eyeEcho_cta_banner").style.height = (dmleyeEchoWrapperElement.offsetWidth*1197/700) + "px"; } } function changeToApp(){ if (eyeEcho_banner_cta_active){ eyeEchoOpenApp() eyeEcho_banner_cta_active = false; } } // global functions window.eyeEchoSetCookie = function(cname,cvalue, exdays){ var d = new Date(); d.setTime(d.getTime() + (exdays*24*60*60*1000)); var expires = "expires="+ d.toUTCString(); document.cookie = cname + "=" + cvalue + ";" + expires + ";"; } window.eyeEchoReadCookie= function(cname){ let name = cname + "="; let decodedCookie = decodeURIComponent(document.cookie); let ca = decodedCookie.split(';'); for(var i = 0; i -1){ window.eyeEcho_hasBanner = false; } if (!window.eyeEcho_isEmbed || !window.eyeEcho_hasBanner ){ eyeEchoOpenApp() }else{ eyeEchoMakeBanner(); }