var dml_dmlqz = dml_dmlqz || {}; if (/localhost/g.test("https://dml-quiz-production.herokuapp.com") || /192\.168\.0\./g.test("https://dml-quiz-production.herokuapp.com")){ dml_dmlqz.logAllFlag = true; }else{ dml_dmlqz.logAllFlag = false; } dml_dmlqz.isEmbed = dml_dmlqz.isEmbed || true; dml_dmlqz.forced_language = dml_dmlqz.forced_language || ""; dml_dmlqz.addToBagFlag = false; dml_dmlqz.hasBanner = dml_dmlqz.hasBanner || false; dml_dmlqz.bannerTexts = dml_dmlqz.bannerTexts || { "tagline" : "banner subtitle", "cta" : "banner call to action" }; dml_dmlqz.widget_wrapper=document.getElementById("dml_dmlqz_wrapper"); dml_dmlqz.debug = function(inStringBefore,inVariable){ if ( dml_dmlqz.logAllFlag){ inStringBefore = (inStringBefore === undefined) ? '' : inStringBefore; if (inVariable == undefined){ console.log(inStringBefore) }else{ console.log(inStringBefore, inVariable) } } } // GA - START dml_dmlqz.GAsetup = false; dml_dmlqz.sendGA = function(eventName,eventParameters){ if (eventParameters === undefined){ eventParameters = {}; } if (!window.gtag) return; if (!dml_dmlqz.GAsetup) return; var parametersAsString; try{ parametersAsString = JSON.stringify(eventParameters); dml_dmlqz.debug("GOOGLE ANALYTICS: " + eventName + " - " + parametersAsString); }catch(err){ console.warn("Error in GA event parameters - ",err); eventParameters={}; } window.gtag('event', eventName, eventParameters); } dml_dmlqz.setupGA = function(){ if (window.gtag) { dml_dmlqz.debug("setting up GA with 'gtag'"); window.gtag('config', ""); dml_dmlqz.GAsetup = true; } } // GA - END dml_dmlqz.getEmbedHtmlData = function(url, callback){ var 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(); } dml_dmlqz.getScript = function(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; dml_dmlqz.widget_wrapper.appendChild(script); } dml_dmlqz.getScript_withAttributes = function(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; dml_dmlqz.widget_wrapper.appendChild(script); } dml_dmlqz.openApp = function(){ var gaTimer = 100; var checkForWindowGA = true; var gacheckinterval = setInterval(function(){ if (window.gtag){ dml_dmlqz.debug("GA AVAILABLE - "+ gaTimer/1000 + "s",""); clearInterval(gacheckinterval); dml_dmlqz.setupGA(); }else{ if (checkForWindowGA){ if (window.ga){ checkForWindowGA = false; console.log("found ga but not gtag - adding gtag library"); dml_dmlqz.getScript("https://www.googletagmanager.com/gtag/js?id=",function(res){ window.dataLayer = window.dataLayer || []; window.gtag = function(){dataLayer.push(arguments);} gtag('js', new Date()); }); } } if (gaTimer > 20000){ dml_dmlqz.debug("GA NOT AVAILABLE - "+ gaTimer/1000 + "s"); clearInterval(gacheckinterval); } gaTimer += 100; } },100) if (document.getElementById("dmlqz_banner_container")){ document.getElementById("dmlqz_banner_container").style.display="none" } if (navigator.appName == 'Microsoft Internet Explorer' || !!(navigator.userAgent.match(/Trident/) || navigator.userAgent.match(/rv:11/))){ setTimeout(function(){dml_dmlqz.sendGA("flow",{action: "showing browser not supported screen", page_title: "landing_page", page_location: window.location.hostname, page_path: window.location.pathname});},2000); //alert("We don't currently support this browser. Please reopen this page in a different browser.") if (!dml_dmlqz.isEmbed){ dml_dmlqz.widget_wrapper.style.height = window.innerHeight + "px"; } dml_dmlqz.widget_wrapper.innerHTML = '

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

' + dml_dmlqz.widget_wrapper.innerHTML; if (dml_dmlqz.widget_wrapper.offsetWidth >= 768){ dml_dmlqz.widget_wrapper.style.background = "url('https://dml-quiz-production.herokuapp.com/img/pwrbrt_onboarding_bg_desktop.jpg') no-repeat center center"; }else{ dml_dmlqz.widget_wrapper.style.background = "url('https://dml-quiz-production.herokuapp.com/img/pwrbrt_onboarding_mobile_bg.jpg') no-repeat center center"; } dml_dmlqz.widget_wrapper.style.backgroundSize= "cover"; }else{ var sessionTimeString = (new Date()).getTime(); dml_dmlqz.styleSheet = {} dml_dmlqz.styleSheet.cssId = 'dmlqzStyleSheet'; dml_dmlqz.styleSheet.pagelink = document.createElement('link'); dml_dmlqz.styleSheet.pagelink.id = dml_dmlqz.styleSheet.cssId; dml_dmlqz.styleSheet.pagelink.rel = 'stylesheet'; dml_dmlqz.styleSheet.pagelink.type = 'text/css'; dml_dmlqz.styleSheet.pagelink.href = 'https://dml-quiz-production.herokuapp.com/css/styles.min.css?'+sessionTimeString; dml_dmlqz.styleSheet.pagelink.media = 'all'; dml_dmlqz.widget_wrapper.appendChild(dml_dmlqz.styleSheet.pagelink); if (typeof dml_dmlqz.customCssUrl != 'undefined'){ dml_dmlqz.customStyleSheet = {} dml_dmlqz.customStyleSheet.cssId = 'dmlqzCustomStyleSheet'; dml_dmlqz.customStyleSheet.pagelink = document.createElement('link'); dml_dmlqz.customStyleSheet.pagelink.id = dml_dmlqz.customStyleSheet.cssId; dml_dmlqz.customStyleSheet.pagelink.rel = 'stylesheet'; dml_dmlqz.customStyleSheet.pagelink.type = 'text/css'; dml_dmlqz.customStyleSheet.pagelink.href = `${dml_dmlqz.customCssUrl}?${sessionTimeString}`; dml_dmlqz.customStyleSheet.pagelink.media = 'all'; dml_dmlqz.widget_wrapper.appendChild(dml_dmlqz.customStyleSheet.pagelink); } setTimeout(function(){dml_dmlqz.sendGA("flow",{action: "loading full script", page_title: "srs_landing_page", page_location: window.location.hostname, page_path: window.location.pathname});},2000); dml_dmlqz.getEmbedHtmlData('https://dml-quiz-production.herokuapp.com/widget?'+sessionTimeString, function(res) { dml_dmlqz.widget_wrapper.innerHTML = res.data + dml_dmlqz.widget_wrapper.innerHTML; dml_dmlqz.getScript('https://dml-quiz-production.herokuapp.com/script.js?'+sessionTimeString,function(){}); }) } } dml_dmlqz.openApp()