var dmlwmboWrapperElement = document.getElementById("dml_wmbo_wrapper"); dmlwmboWrapperElement.style.transition = "all 0.5s;"; var wmboCSSid = 'wmboStyleSheet'; let sessionTimeString = (new Date()).getTime(); var wmboFlLgPp = false; var wmbo_pagelink = document.createElement('link'); wmbo_pagelink.id = wmboCSSid; wmbo_pagelink.rel = 'stylesheet'; wmbo_pagelink.type = 'text/css'; wmbo_pagelink.href = 'https://wmbo-production.herokuapp.com/stylesheets/style.min.css?'+sessionTimeString; wmbo_pagelink.media = 'all'; dmlwmboWrapperElement.appendChild(wmbo_pagelink); window.wmbo_maxwidth = typeof window.wmbo_maxwidth != "undefined" ? window.wmbo_maxwidth : "100%"; window.wmbo_maxheight = typeof window.wmbo_maxheight != "undefined" ? window.wmbo_maxheight : window.innerHeight +"px"; window.wmbo_bannerwidth= typeof window.wmbo_bannerwidth != "undefined" ? window.wmbo_bannerwidth : "100%"; window.wmbo_isEmbed = typeof window.wmbo_isEmbed != "undefined" ? window.wmbo_isEmbed: true; if (!window.wmbo_isEmbed){ window.wmbo_showNavbar = true; } window.wmbo_showNavbar = typeof window.wmbo_showNavbar != "undefined" ? window.wmbo_showNavbar : false; window.wmbo_showLiveChat = typeof window.wmbo_showLiveChat != "undefined" ? window.wmbo_showLiveChat : true; window.wmbo_forcedLanguageCode = typeof window.wmbo_forcedLanguageCode != "undefined" ? window.wmbo_forcedLanguageCode: ""; dmlwmboWrapperElement.style.width = window.wmbo_maxwidth; function logOnLocalHostFrontEnd(inStringBefore,inVariable){ inStringBefore = (inStringBefore === undefined) ? '' : inStringBefore; if (/localhost/g.test("https://wmbo-production.herokuapp.com") || /192\.168\.0\./g.test("https://wmbo-production.herokuapp.com") || /\.ngrok\.io/g.test("https://wmbo-production.herokuapp.com") || /facemappingconsumer-staging\.herokuapp/g.test("https://wmbo-production.herokuapp.com") || wmboFlLgPp){ if (inVariable == undefined){ console.log(inStringBefore) }else{ console.log(inStringBefore, inVariable) } } } // GA - START window.wmboGAsetup = false; function wmboSendGA(eventName,eventValue){ logOnLocalHostFrontEnd("GOOGLE ANALYTICS: ",eventName + " - " + eventValue) eventValue = (eventValue == undefined) ? "" : eventValue; let eventLabel; if (typeof wmboCustomUID == "undefined"){ eventLabel = ""; }else{ eventLabel = wmboCustomUID; } if (typeof window.facemap != "undefined"){ if (typeof window.facemap.hashid != "undefined"){ eventLabel += " - " + window.facemap.hashid; } } if (window.wmboGAsetup){ if (window.ga) { if (eventLabel != ""){ window.ga('wmbo_gtag.send', 'event', eventName, eventValue, eventLabel); // category - action - label }else{ window.ga('wmbo_gtag.send', 'event', eventName, eventValue); // category - action } }else if (window.gtag) { if (eventLabel != ""){ window.gtag('event', eventValue, {event_category: eventName, event_label: eventLabel}); // action - {category - label} }else{ window.gtag('event', eventName, {event_category: eventName}); // action - {category} } } else if (window._gaq) { window._gaq.push(['wmbo_gtag._trackEvent',eventName,eventValue]); // category - action } } } function wmboSendPageViewGA(pagePath){ if (window.wmboGAsetup){ if (window.ga) { logOnLocalHostFrontEnd("GOOGLE ANALYTICS: ga pageview event will be send"); window.ga('wmbo_gtag.set', 'page', pagePath); window.ga('wmbo_gtag.send', 'pageview'); }else if (window.gtag) { logOnLocalHostFrontEnd("GOOGLE ANALYTICS: gtag pageview event will be send"); window.gtag('config', "UA-36853599-39", {"page_title": window.location.hostname, "page_path": pagePath}); } else if (window._gaq) { logOnLocalHostFrontEnd("GOOGLE ANALYTICS: _gaq pageview event will be send"); window._gaq.push(['wmbo_gtag._trackPageview',pagePath]); } } } function wmboSetupGA(){ let pageTitle ="not found"; pageTitle = window.location.hostname; if (window.ga) { logOnLocalHostFrontEnd("setting up GA for 'ga'",""); window.ga('create', "UA-36853599-39", 'auto', 'wmbo_gtag'); window.ga('wmbo_gtag.set','anonymizeIp', true); window.ga('wmbo_gtag.send','pageview',window.location.href); }else if (window.gtag) { logOnLocalHostFrontEnd("setting up GA for 'gtag'",""); window.gtag('config', "UA-36853599-39", { 'anonymize_ip': true, 'page_title': pageTitle , 'page_location': window.location.href }); } else if (window._gaq) { logOnLocalHostFrontEnd("setting up GA for '_gaq'",""); window._gaq.push(['wmbo_gtag._setAccount',"UA-36853599-39"],['wmbo_gtag._trackPageview']); } window.wmboGAsetup = 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) { callback({"status": "success","status_code":request.status, "data" : request.responseText}); } else { callback({"status": "success","status_code":request.status, "data" : "We reached our target server, but it returned an error"}); } }; request.onerror = function() { callback({"error": "success","status_code":request.status, "data" : "Error occured in getting html data"}); }; request.send(); } function dmlwmbo_getScript(source, callback) { var script = document.createElement('script'); script.async = 1; script.onload = function(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; dmlwmboWrapperElement.appendChild(script); } function dmlwmbo_getScript_withAttributes(source, attributeObj, callback) { var script = document.createElement('script'); script.async = 1; script.onload = function(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; dmlwmboWrapperElement.appendChild(script); } function wmboOpenApp(){ let gaTimer = 100; let gacheckinterval = setInterval(function(){ if (window.ga){ logOnLocalHostFrontEnd("GA AVAILABLE - "+ gaTimer/1000 + "s",""); clearInterval(gacheckinterval); wmboSetupGA(); }else{ if (gaTimer > 10000){ logOnLocalHostFrontEnd("GA NOT AVAILABLE - "+ gaTimer/1000 + "s",""); clearInterval(gacheckinterval); } gaTimer += 100; } },100) if (navigator.appName == 'Microsoft Internet Explorer' || !!(navigator.userAgent.match(/Trident/) || navigator.userAgent.match(/rv:11/))){ setTimeout(function(){wmboSendGA("openApp","Browser Not Supported");},2000); //alert("We don't currently support this browser. Please reopen this page in a different browser.") if (!window.wmbo_isEmbed){ dmlwmboWrapperElement.style.height = "100vh"; } dmlwmboWrapperElement.innerHTML = '

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

' + dmlwmboWrapperElement.innerHTML; dmlwmboWrapperElement.style.background = "url('https://wmbo-production.herokuapp.com/img/screen2-bg.png') no-repeat center center"; dmlwmboWrapperElement.style.backgroundSize= "cover"; dmlwmboWrapperElement.style.backgroundColor = "#00afad"; }else{ setTimeout(function(){wmboSendGA("openApp","loading full script");},2000); getEmbedHtmlData('https://wmbo-production.herokuapp.com/wmbo?'+sessionTimeString, function(res) { //window.data = res.data; dmlwmboWrapperElement.innerHTML = res.data + dmlwmboWrapperElement.innerHTML; document.getElementById("wmbo_body").style.height=window.innerHeight + "px"; let heightLimit= Math.min(screen.availHeight,screen.height ); if (document.getElementById("wmbo_body").offsetHeight > heightLimit){ document.getElementById("wmbo_body").style.height = heightLimit + "px"; } dmlwmbo_getScript('https://wmbo-production.herokuapp.com/script.js?'+sessionTimeString,function(){ document.getElementById("wmbo_body").style.opacity = 1; }); dmlwmboWrapperElement.style.height = window.innerHeight + "px"; }) } } // global functions window.wmboSetCookie = 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.wmboReadCookie= function(cname){ let name = cname + "="; let decodedCookie = decodeURIComponent(document.cookie); let ca = decodedCookie.split(';'); for(var i = 0; i