var dmlphytoWrapperElement = document.getElementById("dml_phyto_wrapper"); dmlphytoWrapperElement.style.transition = "all 0.5s;"; var phyto_banner_cta_active = true; var phytoCSSid = 'phytoStyleSheet'; let sessionTimeString = (new Date()).getTime(); var phyto_pagehead = document.getElementsByTagName('head')[0]; var phyto_pagelink = document.createElement('link'); phyto_pagelink.id = phytoCSSid; phyto_pagelink.rel = 'stylesheet'; phyto_pagelink.type = 'text/css'; phyto_pagelink.href = 'https://phytotouch-production.herokuapp.com/stylesheets/style.min.css?'+sessionTimeString; phyto_pagelink.media = 'all'; phyto_pagehead.appendChild(phyto_pagelink); window.phyto_forcedLanguageCode = typeof window.phyto_forcedLanguageCode != "undefined" ? window.phyto_forcedLanguageCode : ""; window.phyto_hasBanner = typeof window.phyto_hasBanner != "undefined" ? window.phyto_hasBanner : true; window.phyto_isEmbed = typeof window.phyto_isEmbed != "undefined" ? window.phyto_isEmbed : true; window.phyto_maxwidth = typeof window.phyto_maxwidth != "undefined" ? window.phyto_maxwidth : "100%"; window.phyto_maxheight = typeof window.phyto_maxheight != "undefined" ? window.phyto_maxheight : window.innerHeight +"px"; window.phyto_bannerwidth= typeof window.phyto_bannerwidth != "undefined" ? window.phyto_bannerwidth : "100%"; window.phyto_banner_cta_title= typeof window.phyto_banner_cta_title != "undefined" ? window.phyto_banner_cta_title : "phyto touch"; window.phyto_banner_cta_text= typeof window.phyto_banner_cta_text != "undefined" ? window.phyto_banner_cta_text : "reawaken your skin with the power of touch"; window.phyto_banner_cta_button= typeof window.phyto_banner_cta_button != "undefined" ? window.phyto_banner_cta_button : "show me how"; dmlphytoWrapperElement.style.width = window.phyto_maxwidth; function logOnLocalHostFrontEnd(inStringBefore,inVariable){ inStringBefore = (inStringBefore === undefined) ? '' : inStringBefore; if (/localhost/g.test("https://phytotouch-production.herokuapp.com") || /192\.168\.0\./g.test("https://phytotouch-production.herokuapp.com") || /\.ngrok\.io/g.test("https://phytotouch-production.herokuapp.com") || /facemappingconsumer-staging\.herokuapp/g.test("https://phytotouch-production.herokuapp.com")){ if (inVariable == undefined){ console.log(inStringBefore) }else{ console.log(inStringBefore, inVariable) } } } // GA - START window.phytoGAsetup = false; function phytoSendGA(eventName,eventValue){ eventValue = (eventValue == undefined) ? "" : eventValue; if (window.phytoGAsetup){ if (window.ga) { window.ga('phyto_gtag.send', 'event', eventName, eventValue); }else if (window.gtag) { window.gtag('event', eventName, {value: eventValue}); } else if (window._gaq) { window._gaq.push(['phyto_gtag._trackEvent',eventName,eventValue]); } } } function phytoSetupGA(){ let pageTitle ="not found"; pageTitle = window.location.hostname; if (window.ga) { window.ga('create', 'UA-36853599-27', 'auto', 'phyto_gtag'); // change with new value! window.ga('phyto_gtag.set','anonymizeIp', true); window.ga('phyto_gtag.send','pageview',window.location.href); }else if (window.gtag) { window.gtag('config', 'UA-36853599-27', { 'anonymize_ip': true, 'page_title': pageTitle , 'page_location': window.location.href }); } else if (window._gaq) { window._gaq.push(['phyto_gtag._setAccount','UA-36853599-27'],['phyto_gtag._trackPageview']); } window.phytoGAsetup = true; } // 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 dmlphyto_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; dmlphytoWrapperElement.appendChild(script); } function dmlphyto_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; dmlphytoWrapperElement.appendChild(script); } function phytoOpenApp(){ let gaTimer = 100; let gacheckinterval = setInterval(function(){ if (window.ga){ logOnLocalHostFrontEnd("GA AVAILABLE - "+ gaTimer/1000 + "s",""); clearInterval(gacheckinterval); phytoSetupGA(); }else{ if (gaTimer > 10000){ logOnLocalHostFrontEnd("GA NOT AVAILABLE - "+ gaTimer/1000 + "s",""); clearInterval(gacheckinterval); } gaTimer += 100; } },100) if (dmlphytoWrapperElement.offsetWidth > 768 && false){ dmlphytoWrapperElement.innerHTML += '

hey! we are almost ready to launch phyto touch for desktop.

Still interested?

To preview this widget now, visit www.phytotouch.com from your mobile device

' document.getElementById("phyto_no_desktop_screen").style.height = Math.min(dmlphytoWrapperElement.offsetWidth * 0.55,window.innerHeight) + "px"; }else{ if (navigator.appName == 'Microsoft Internet Explorer' || !!(navigator.userAgent.match(/Trident/) || navigator.userAgent.match(/rv:11/))){ setTimeout(function(){phytoSendGA("openApp","Browser Not Supported");},2000); if (!window.phyto_isEmbed){ dmlphytoWrapperElement.style.height = "100vh"; } dmlphytoWrapperElement.innerHTML = '

We don\'t currently support this browser. Please reopen this page in a different browser, such as Chrome.

'; //dmlphytoWrapperElement.style.background = "url('https://phytotouch-production.herokuapp.com/img/screen2-bg.png') no-repeat center center"; dmlphytoWrapperElement.style.background = "lightblue"; dmlphytoWrapperElement.style.backgroundSize= "cover"; }else{ setTimeout(function(){phytoSendGA("openApp","loading full script");},2000); getEmbedHtmlData('https://phytotouch-production.herokuapp.com/phyto?'+sessionTimeString, function(res) { window.data = res.data; if (window.phyto_isEmbed && window.phyto_hasBanner){ let phytoBannerElement = document.getElementById("phyto_cta_banner"); phytoBannerElement.style.opacity = 0; setTimeout(function(){ dmlphytoWrapperElement.innerHTML = res.data + dmlphytoWrapperElement.innerHTML; document.getElementById("phyto_body").style.height=window.phyto_maxheight; document.getElementById("phyto_cta_banner").style.display = "none"; dmlphytoWrapperElement.style.maxHeight = window.phyto_maxheight; dmlphytoWrapperElement.style.width = window.phyto_maxwidth; dmlphytoWrapperElement.style.height = window.phyto_maxheight; dmlphytoWrapperElement.style.maxHeight = window.phyto_maxheight; dmlphyto_getScript('https://phytotouch-production.herokuapp.com/script.js?'+sessionTimeString,function(){ document.getElementById("phyto_body").style.opacity = 1; //dmlphyto_getScript_withAttributes("https://consent.cookiebot.com/uc.js",{"data-cbid":"9a0e10ab-b363-4aea-857e-5dedb771dc33", "id":"Cookiebot"},function(resCookieBot){}) }); },500) }else{ dmlphytoWrapperElement.innerHTML = res.data + dmlphytoWrapperElement.innerHTML; document.getElementById("phyto_body").style.height=window.innerHeight + "px"; dmlphyto_getScript('https://phytotouch-production.herokuapp.com/script.js?'+sessionTimeString,function(){ document.getElementById("phyto_body").style.opacity = 1; }); dmlphyto_getScript('https://phytotouch-production.herokuapp.com/vendor/exif.js?'+sessionTimeString,function(){ logOnLocalHostFrontEnd("exif loaded"); }); } }) } } } function phytoMakeBanner(){ let bannerWidth; if (window.phyto_bannerwidth.indexOf("%")>-1){ bannerWidth = dmlphytoWrapperElement.offsetWidth * Number(window.phyto_bannerwidth.replace("%",""))/100; }else{ bannerWidth = Number(window.phyto_bannerwidth.replace("px","").replace("%","")); } if (bannerWidth>500){ dmlphytoWrapperElement.innerHTML += '
'+ '

'+phyto_banner_cta_title+'

'+window.phyto_banner_cta_text+'

'+window.phyto_banner_cta_button+'

' document.getElementById("phyto_cta_banner").style.backgroundImage ="url('https://phytotouch-production.herokuapp.com/img/phyto-touch-pdp.jpg')"; }else{ dmlphytoWrapperElement.innerHTML += '
'+ '

'+phyto_banner_cta_title+'

'+window.phyto_banner_cta_text+'

'+window.phyto_banner_cta_button+'

' document.getElementById("phyto_cta_banner").style.backgroundImage ="url('https://phytotouch-production.herokuapp.com/img/phyto-touch-mobile-image.jpg')"; document.getElementById("phyto_cta_banner").style.height = (dmlphytoWrapperElement.offsetWidth*1197/700) + "px"; } } function changeToApp(){ if (phyto_banner_cta_active){ phytoOpenApp() phyto_banner_cta_active = false; } } // global functions window.phytoSetCookie = 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.phytoReadCookie= function(cname){ let name = cname + "="; let decodedCookie = decodeURIComponent(document.cookie); let ca = decodedCookie.split(';'); for(var i = 0; i -1){ window.phyto_hasBanner = false; } if (!window.phyto_isEmbed || !window.phyto_hasBanner ){ phytoOpenApp() }else{ phytoMakeBanner(); }