Advertisement
dozer10t

/* Timestamp: Wed Sep 20 22:13:44 PDT 2017*//* Checking the

Sep 24th, 2017
681
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 29.08 KB | None | 0 0
  1. /* Timestamp: Wed Sep 20 22:13:44 PDT 2017*//* Checking the supported browsers */
  2. if (!window["v3Lander"] && navigator.userAgent.indexOf("Opera") == -1
  3.     && navigator.userAgent.indexOf("MSIE 6") == -1 /* We do not support IE7- */
  4.     && (navigator.userAgent.indexOf("MSIE 7") == -1
  5.         || navigator.userAgent.indexOf("Trident") != -1
  6.         || navigator.userAgent.toLowerCase().indexOf("media center") != -1
  7.     )
  8. ) {
  9.  
  10.     if (typeof window.v3LanderConfig != "object") {
  11.         // if custom parameters is not defined or invalid, then set empty map
  12.         window.v3LanderConfig = {};
  13.     }
  14. window.v3Lander = {
  15.  
  16.     codeVersion:'1505970822884',
  17.     v3Frame:false,
  18.     domState: "defer-failed",
  19.     domReady: false,
  20.     secureProtocol: function(url){
  21.         return url.replace(/^HTTPS?:/i, "https:");
  22.     },
  23.     hostToPath:{},
  24.     hostedFileURL: window.v3LanderConfig.hostedFileURL || "/global/snippets/inq/inqChat.html",
  25.     isAtHostedFileURL: false,
  26.     log:function(s) {
  27.         if (typeof console != "undefined" && console.log) {
  28.             console.log(s);
  29.         }
  30.     },
  31.    
  32.     FMProxy:    {
  33.         fcns:{},
  34.         addFcn: function(name, fcnStr){
  35.             var obj = null;
  36.             try{
  37.                 obj = eval("({'"+name+"':"+fcnStr+"})");
  38.             }
  39.             catch(err){
  40.                 throw "function eval failed. err="+err.toString();
  41.             }
  42.             this.fcns[name]=obj[name];
  43.         },
  44.         getFcn: function(name){
  45.             return this.fcns[name];
  46.         },
  47.         /*Removes a function from the collection of functions */
  48.         removeFcn: function(name){
  49.             if(!!this.fcns[name]){
  50.                 delete this.fcns[name];
  51.                 return true;
  52.             }
  53.             return false;
  54.         }
  55.     },
  56.    
  57.     // multiHost=true
  58.  
  59.     _getHostedFileURL:function(domain){
  60.         if (!domain) {
  61.             /* if domain has not been supplied, use our domain */
  62.             domain = window.location.host;
  63.         }
  64.         domain = domain.toUpperCase();
  65.         /* If we have no host-to-path map, then return the default URL */
  66.         if (v3Lander.hostToPath && v3Lander.hostToPath[domain]) {
  67.             return v3Lander.hostToPath[domain];
  68.         } else {
  69.             return v3Lander.hostedFileURL;
  70.         }
  71.     },
  72.  
  73.     _setHostedFileURL: function(domain) {
  74.         if (!domain) {
  75.             /* if domain has not been supplied, use current window domain */
  76.             domain = window.location.host;
  77.         }
  78.         domain = domain.toUpperCase();
  79.         /* If we have no host-to-path map, then hosted file URL is not updated */
  80.         if (v3Lander.hostToPath && v3Lander.hostToPath[domain]) {
  81.             v3Lander.hostedFileURL = v3Lander.hostToPath[domain];
  82.         }
  83.     },
  84.  
  85.     getHostedFileURL:function(domain){
  86.  
  87.         var url = this._getHostedFileURL(domain);
  88.         if (url.indexOf("//") != 0) {
  89.  
  90.             url = "//" + domain + url;
  91.         }
  92.  
  93.         url = window.location.protocol + url;
  94.  
  95.         return url;
  96.     },
  97.     establishHostedFileURL:function(){
  98.         if (window.v3LanderConfig.hostToPath) {
  99.             for (var i = 0, paths = window.v3LanderConfig.hostToPath; i < paths.length; i++) {
  100.                 if (paths[i].domain && paths[i].hostedFileDirectory) {
  101.                     v3Lander.hostToPath[paths[i].domain.toUpperCase()] = paths[i].hostedFileDirectory + v3Lander.hostedFileURL;
  102.                 }
  103.             }
  104.         }
  105.         this._setHostedFileURL();
  106.     },
  107.    
  108.     assignDomain:function(){
  109.         if (this.isAtHostedFileURL){
  110.             var domainName = document.domain;
  111.             var temp = domainName.split('.');
  112.             for (var i=0; i < temp.length; i++){
  113.                 try{
  114.                     var tempwindow = null;
  115.                     if (window.location.search == "")
  116.                         tempwindow = window.opener;
  117.                     else if (window.location.search.indexOf('?IFRAME') == 0 || window.location.search == "?IEXF")
  118.                         tempwindow = window.parent;
  119.                     else if (window.location.search == "?BLNK")
  120.                         tempwindow = window.parent ;
  121.                     else if (window.location.search == "?XHR")
  122.                         tempwindow = window.parent.parent;
  123.                     else if (window.location.search == "?PRXY")
  124.                         tempwindow = window.parent.parent;
  125.                     else return ;
  126.  
  127.                    
  128.                     if (document.domain == tempwindow.document.domain){
  129.                         break;
  130.                     } else {
  131.                         temp.shift();
  132.                         if (temp.length > 1) {
  133.                             document.domain = temp.join('.');
  134.                         }
  135.                     }
  136.                 }
  137.                 catch(ee){
  138.                     temp.shift();
  139.                     if (temp.length > 1) {
  140.                         document.domain = temp.join('.');
  141.                     }
  142.                 }
  143.             }
  144.         }
  145.     },
  146.  
  147.     embeddedHostedFile: null,
  148.     embeddedDiv: null,
  149.     c2cQueryData: null,
  150.     registerDivRetry: 0,
  151.  
  152.     resizeAnscestorIframe: function(){
  153.         var items = name.split("||");      
  154.         var iframeName = items[1];         
  155.         var width = items[2];              
  156.         var height = items[3];             
  157.        
  158.         var iframeElements = parent.parent.document.getElementsByName(iframeName);
  159.         if (iframeElements.length > 0) {   
  160.             try {
  161.                 var iframe = iframeElements[0];
  162.                
  163.                 iframe.style.cssText += ";"+"width: "+width+ "px;"+
  164.                                             "height: "+height+"px;"+
  165.                                             "display: block;"+
  166.                                             "overflow: hidden;" +
  167.                                             "overflow-x: hidden;"+
  168.                                             "overflow-y: hidden;"+
  169.                                             "border-style: hidden;"+
  170.                                             "border-style: none;"+
  171.                                             "border-width: 0px;" ;
  172.             } catch(e){
  173.             }
  174.         }
  175.     },
  176.  
  177.     registerDiv: function(retryCount){
  178.         if (!!retryCount)
  179.             v3Lander.registerDivRetry = retryCount;
  180.         try {
  181.             if (top["Inq"]==null) throw (new Error("Inq not ready"));
  182.             if (top.Inq["fireCustomEvent"]==null) throw (new Error("fireCustomEvent not ready"));
  183.             top.Inq.fireCustomEvent("IframeC2C",{div: v3Lander.embeddedDiv, queryData:v3Lander.c2cQueryData});
  184.         } catch(e){
  185.             if (--(v3Lander.registerDivRetry) > 0)
  186.                 window.setTimeout(v3Lander.registerDiv, 500);
  187.         }
  188.     },
  189.  
  190.     resizeIframe: function(width, height){
  191.         /**
  192.          *  @see http://jira.touchcommerce.com/browse/RTDEV-11045
  193.          * */
  194.         var winName = !!window.name?window.name.replace(/\n|<.*?>/g,"").replace(/\"/g,'\\\''):window.name;
  195.         var name = "RESIZE||"+winName+"||" + width + "||" + height ;
  196.         var div = document.createElement("div");
  197.         div.innerHTML = '<ifr'+'ame id="inqChatStage" name="'+name+'" src="'+this.embeddedHostedFile+'?RSC2C"'
  198.                     + ' style="z-index:9999999;overflow:hidden;position:absolute;height:1px;width:1px;left:0px;top:0px;border-style: none;border-width: 0px;display: none;"'
  199.                     + ' scrolling="NO"'
  200.                     + ' frameborder=0'
  201.                     + '></ifr'+'ame>' ;
  202.         var ifrm = div.firstChild ;
  203.         document.body.appendChild(ifrm);
  204.     },
  205.  
  206.     setSource:function(attributes, domain){
  207.         v3Lander.embeddedHostedFile = v3Lander.getHostedFileURL(domain);
  208.        
  209.         v3Lander.embeddedDiv.innerHTML = "";
  210.        
  211.         var image = new Image();
  212.        
  213.         image.onload = function(e){
  214.            
  215.             v3Lander.resizeIframe(this.width, this.height);
  216.             return false;
  217.             };
  218.        
  219.         for (var attr in attributes){
  220.             image.setAttribute(attr, attributes[attr]);
  221.         }
  222.        
  223.         if (!!image.onclick){
  224.             try {
  225.                
  226.                 if (!!image.style["cursor"]) image.style.cursor = "pointer";   
  227.                 else image.style.cssText += ";cursor: pointer;cursor: hand;";  
  228.             } catch (e) {
  229.             }
  230.             var fun = "" + image.onclick ;                 
  231.             if (fun.indexOf("function")!=0) {              
  232.                 var funInner = image.onclick;              
  233.                 image.onclick = new Function(funInner);    
  234.             }
  235.         }
  236.         v3Lander.embeddedDiv.appendChild(image);           
  237.     },
  238.  
  239.     fixV3IFrames:function(div){
  240.         var inqFrames = div.getElementsByTagName("IFRAME");
  241.         div.style.cssText = "overflow:hidden;position:absolute;height:1px;width:1px;left:0px;top:0px;"
  242.                     +"border-style: none;border-width: 0px;" ;
  243.         for (var ix = 0, l = inqFrames.length; ix < l; ix++) {
  244.             inqFrame = inqFrames[ix] ;
  245.             inqFrame.allowTransparency="true" ;
  246.             inqFrame.border="0";
  247.             inqFrame.frameBorder="no" ;
  248.             inqFrame.frameSpacing=0;
  249.             inqFrame.marginWidth=0;
  250.             inqFrame.style.cssText =
  251.                 "z-index:9999999;overflow:hidden;position:absolute;left:0px;top:0px;width:1px;height:1px;border-style: none;border-width: 0px;BACKGROUND-COLOR: Transparent;" ;
  252.         }
  253.     },
  254.    
  255.     initV3Frame:function(){
  256.         if (window.frameElement)
  257.             window.clientwin = window.parent;
  258.         else if (window.opener)
  259.             window.clientwin = window.opener;
  260.         if (window.clientwin)
  261.             window.clientwin.inqFrame=window ;
  262.         window.inqFrame = window ;
  263.         window.name = opener ? "_inqPersistentChat" : "inqV3";
  264.         this.insertLandingTag();
  265.     },
  266.    
  267.     reload: function(){
  268.         this.domReady = false;
  269.         setTimeout(function(){
  270.             v3Lander._reload();
  271.         }, 50);
  272.     },
  273.     _reload: function(){
  274.        var chatStage = document.getElementById("inqChatStage");
  275.        var corner = document.getElementById("inqDivResizeCorner");
  276.        var title = document.getElementById("inqTitleBar");
  277.        if (chatStage) {
  278.            document.body.removeChild(chatStage);
  279.        }
  280.        if (corner) {
  281.            document.body.removeChild(corner);
  282.        }
  283.        if (title) {
  284.            document.body.removeChild(title);
  285.        }
  286.        window.inqFrame = null;
  287.        window.Inq = undefined;
  288.         this.start();
  289.     },
  290.     createV3Frame: function(win){
  291.        if (!win) win = window;
  292.        var doc = win.document;
  293.         var div = doc.createElement("div") ;
  294.         var port = (doc.location.port=="")?"":(":"+doc.location.port);
  295.         var iframesrc = v3Lander.hostedFileURL.indexOf("/") == 0 ?
  296.                 doc.location.protocol + '//' + doc.location.hostname + port + v3Lander.hostedFileURL
  297.                     + '?IFRAME' + (window.v3LanderConfig.iframeSrcParams || "")
  298.                 : v3Lander.hostedFileURL ;
  299.  
  300.         if (typeof(CEAPI_POST_CHAT_SURVEY_DATA) != "undefined" && CEAPI_POST_CHAT_SURVEY_DATA != null) {
  301.             // We are loading from tagserver servlet /showPostChatSurvey responded page now. We need to use the
  302.             // same /showPostChatSurvey url to load the inqLaunch<site>.js into the IFrame to
  303.             // avoid cross-domain issue. We also pass in the hostedFileURL param to let /showPostChatSurvey
  304.             // servlet know it is not called from ceapi client. Also passing in the siteID and vanityDomain.
  305.             iframesrc = doc.location + '?IFRAME&hostedFileURL=true&siteID=' + 154 +
  306.                 '&vanityDomain=' + v3Lander.secureProtocol(window.v3LanderConfig.vanityDomain || 'https://sprint.inq.com');
  307.         }
  308.  
  309.        
  310.         if (top != parent) {
  311.             var rand = (Math.round(Math.random()*1000000000000)).toString(36);
  312.             iframesrc += (iframesrc.indexOf('?') == -1)?'?':'&';
  313.             iframesrc += "rand=" + rand;
  314.         }
  315.  
  316.         div.id = "inqChatStage";
  317.         div.style.cssText = "z-index:9999999;overflow:hidden;position:absolute;height:1px;width:1px;left:0px;top:0px;"
  318.                         +"border-style: none;border-width: 0px;" ;
  319.         div.innerHTML = '<iframe id="inqChatStage" title="Chat Window"'
  320.                       + ' name="154"'
  321.                       + ' src="' + iframesrc + '"'
  322.                       + ' style="z-index:9999999;overflow:hidden;position:absolute;height:1px;width:1px;left:0px;top:0px;border-style: none;border-width: 0px;display: none;"'
  323.                       + ' scrolling="NO"'
  324.                       + ' frameborder=0'
  325.                       + '></iframe>'
  326.                       + '<div id="inqTitleBar" style="border-width: 0px; position: absolute; z-index: 9999999; left: 0px; top: 0px; cursor: move; height: 55px; width: 410px; display: none;">'
  327.                       + '<img />'
  328.                       + '</div>'
  329.                       + '<div id="inqResizeBox" style="border-width: 0px; position: absolute; z-index: 9999999; left: 0px; top: 0px; display:none; height: 0px; width: 0px;">'
  330.                       + '<div id="inqDivResizeCorner" style="border-width: 0px; position: absolute; z-index: 9999999; left: 424px; top: 284px; cursor: se-resize; height: 16px; width: 16px; display: none;"></div>'  ;
  331.         var bdy=doc.body;
  332.         if (bdy){
  333.             var iframes = div.getElementsByTagName("IFRAME") ;
  334.             var divs = div.getElementsByTagName("DIV");
  335.             for (var ix = iframes.length - 1; ix > -1; --ix) {
  336.                 bdy.appendChild(iframes[ix]);
  337.             }
  338.             for (var ix = divs.length - 1; ix > -1; --ix) {
  339.                 bdy.appendChild(divs[ix]);
  340.             }
  341.         }
  342.         if (iframesrc==this.hostedFileURL) {
  343.             var stg = document.getElementById("inqChatStage");
  344.             var doc = stg.contentDocument || stg.contentWindow.document;
  345.             if (!doc) {
  346.                 return;
  347.             }
  348.             doc.open("replace");
  349.             doc.write(
  350.                 '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">\n'
  351.                 +'<html><head><title></title>\n'
  352.                 +'<meta http-equiv=Content-Type content="text/html; charset=utf-8">\n'
  353.                 +'</head>\n'
  354.                 +'<body>\n'
  355.                 +'<script type="text\/javascript" language="javascript" charset="utf-8" \n'
  356.                 +'\t\tsrc="' + v3Lander.secureProtocol(window.v3LanderConfig.vanityDomain || 'https://sprint.inq.com')+'/chatskins/launch/inqChatLaunch154.js"><\/script>\n'
  357.                 +'</body>\n'
  358.                 +'</html>');
  359.             doc.close();
  360.         }
  361.         v3Lander.fixV3IFrames(div);
  362.     },
  363.  
  364.     loadScript:function(name, useMediaServer) {
  365.         var bdy = document.getElementsByTagName("BODY");
  366.         if (bdy && bdy[0]) {
  367.            var srctag = document.createElement("SC" + "RIPT");
  368.             if (useMediaServer) {
  369.                 srctag.src = v3Lander.secureProtocol(window.v3LanderConfig.vanityDomain || "http://mediav3.inq.com" || "https://sprint.inq.com") + name;
  370.             } else {
  371.                 srctag.src = v3Lander.secureProtocol(window.v3LanderConfig.vanityDomain || "https://sprint.inq.com") + name;
  372.             }
  373.             srctag.type = "text/javascript";
  374.             srctag.charset = "utf-8";
  375.             srctag.language = "javascript";
  376.             bdy[0].appendChild(srctag);
  377.         }
  378.     },
  379.  
  380.     inqSiteDataFun:null,
  381.     inqRulesEngineFun:null,
  382.     mbusToLoad:[],
  383.     page:null,
  384.     cgIDs:null,
  385.     isBupMode:false,
  386.     isRplMode:false,
  387.     loadedMbuRuleDataFuns:[],
  388.  
  389.     requestPage: function(){
  390.         this.resolvePage();
  391.     },
  392.  
  393.     getPage: function(){
  394.         return this.page;
  395.     },
  396.  
  397.     getContentGroupIDs: function(){
  398.         return this.cgIDs;
  399.     },
  400.    
  401.     resolvePage: function() {
  402.         var requestUrl = "/tagserver/launch/resolvePage?siteID=154&url=" + encodeURIComponent(document.URL) + "&codeVersion=" + encodeURIComponent(v3Lander.codeVersion);
  403.         var overriddenPageId = null;
  404.         if (window.inqSiteID) {
  405.             overriddenPageId = window.inqSiteID;
  406.         } else if (window.parent && window.parent.inqSiteID) {
  407.            overriddenPageId = window.parent.inqSiteID;
  408.         }
  409.  
  410.         if (overriddenPageId) {
  411.             requestUrl += "&overridePageId=" + encodeURIComponent(overriddenPageId);
  412.         }
  413.         this.loadScript(requestUrl);
  414.     },
  415.     reInitChatData: null,
  416.    
  417.     applyPage: function(data) {
  418.         var contains = function(a, obj) {
  419.             for (var i = 0; i < a.length; i++) {
  420.                if (a[i] === obj) {
  421.                    return true;
  422.                }
  423.            }
  424.            return false;
  425.        };
  426.        var prepareMbusList = function (bUnits) {
  427.            var mbusToLoad = [];
  428.            // check duplicate and push
  429.            for (var i = 0; i < bUnits.length; i++) {
  430.                if (!contains(mbusToLoad, bUnits[i])) {
  431.                    mbusToLoad.push(bUnits[i]);
  432.                }
  433.            }
  434.            return mbusToLoad;
  435.        };
  436.  
  437.        if (this.isBupMode && data.bUnits) {
  438.            this.mbusToLoad = prepareMbusList(data.bUnits);
  439.        }
  440.  
  441.        if (this.isRplMode && data.page) {
  442.            this.page = data.page;
  443.        }
  444.  
  445.        if (this.isRplMode && data.cgIDs) {
  446.            this.cgIDs = data.cgIDs;
  447.        }
  448.  
  449.         if (this.reInitChatData) { //check if Inq#reinitChat callback is required (only for RPL sites)
  450.             window.Inq.reinitChatV3Callback(this.reInitChatData.pageID, this.reInitChatData.data);
  451.             this.reInitChatData = null;
  452.         } else {
  453.             this.createV3Frame();
  454.         }
  455.    },
  456.  
  457.    initSiteDefaultData:function(siteData, rulesEngineData, landingData) {
  458.        v3Lander.landingData = landingData;
  459.        v3Lander.inqSiteDataFun = "var initSiteData = " + siteData.toString();
  460.        v3Lander.inqRulesEngineFun = "var initRulesData = " + rulesEngineData.toString();
  461.        if (!v3Lander.isBupMode || parent.v3Lander.mbusToLoad.length == 0) {
  462.            v3Lander.loadTcFramework();
  463.        } else {
  464.            v3Lander.loadMbuData();
  465.        }
  466.    },
  467.  
  468.    loadTcFramework:function() {
  469.         v3Lander.loadScript(v3Lander.generatePath("tcFramework.min.js"), true);
  470.    },
  471.  
  472.     generatePath:function(filename) {
  473.  
  474.         return (window.v3LanderConfig.vanityDomain ? "/chatskins" : "/media") + "/launch/" + filename + "?codeVersion=" + encodeURIComponent(v3Lander.codeVersion);
  475.     },
  476.  
  477.    loadMbuData:function() {
  478.        for (var i = 0; i < parent.v3Lander.mbusToLoad.length; i++) {
  479.             this.loadMbuDataForBU(parent.v3Lander.mbusToLoad[i]);
  480.        }
  481.    },
  482.  
  483.     buDataCallbackFcn: null,
  484.  
  485.     /***
  486.      * Calls to tagserver to load the appropriate rules file for a given business unit.
  487.      * @param buID {Number}
  488.      * @param callback [Function]
  489.      */
  490.     loadMbuDataForBU:function(buID, callback){
  491.         if(!!callback){
  492.             this.buDataCallbackFcn = callback;
  493.         }
  494.         v3Lander.loadScript("/chatskins/launch/site_154_bu_" + buID + ".js?codeVersion=" + encodeURIComponent(v3Lander.codeVersion));
  495.     },
  496.  
  497.    applyMbuRuleData:function(mbuRuleData) {
  498.         if(this.buDataCallbackFcn){
  499.             this.buDataCallbackFcn(mbuRuleData);
  500.             this.buDataCallbackFcn = null;
  501.         }
  502.         else{
  503.             v3Lander.loadedMbuRuleDataFuns[v3Lander.loadedMbuRuleDataFuns.length] = mbuRuleData.toString();
  504.             // check that we already loaded exactly the same amount of mbu rule data and initiate framework loading
  505.             if (v3Lander.loadedMbuRuleDataFuns.length == parent.v3Lander.mbusToLoad.length) {
  506.                 v3Lander.loadTcFramework();
  507.             }
  508.         }
  509.    },
  510.  
  511.     insertLandingTag:function(){
  512.         v3Lander.loadScript(v3Lander.generatePath("site_154_default.js"), true);
  513.     },
  514.    
  515.    insertPostToServerTag:function(){
  516.         v3Lander.loadScript("/tagserver/postToServer.js?codeVersion=" + encodeURIComponent(this.codeVersion));
  517.    },
  518.     parseC2CQueryString: function() {
  519.        
  520.         var queryStringIndex = window.location.href.indexOf("?C2C");
  521.         var queryString = window.location.href.substring(queryStringIndex + 4);
  522.         if(queryString.length > 1) {
  523.            
  524.             var c2cQueryData = "{";
  525.             var queryStringPairs = queryString.substring(1).split("&");
  526.             for(var i=0; i<queryStringPairs.length; i++) {
  527.                 var pair = queryStringPairs[i].split("=");
  528.                 if(pair.length >= 1 || pair.length <= 2)
  529.                     c2cQueryData += (i==0 ? "" : ", ")
  530.                                     + pair[0] + ": "
  531.                                     + (pair.length == 2
  532.                                         ? "\"" + unescape(pair[1]) + "\""
  533.                                         : "\"\"");
  534.             }
  535.             c2cQueryData += "}";
  536.            
  537.             v3Lander.c2cQueryData = c2cQueryData;
  538.         }
  539.     },
  540.     renderC2CDiv: function(){
  541.        
  542.         document.body.style.cssText = "border-style: none; border-width: 0px; margin: 0px; padding: 0px;overflow: hidden;overflow-x: hidden;overflow-y: hidden;";
  543.        
  544.         var c2cdiv = document.createElement("DIV");
  545.         c2cdiv.id = window.name;
  546.  
  547.        
  548.         document.body.appendChild(c2cdiv);
  549.        
  550.         v3Lander.embeddedDiv = c2cdiv;
  551.        
  552.         c2cdiv["setSource"] = v3Lander.setSource;
  553.     },
  554.  
  555.     setDomReadyTimeout: function(t) {
  556.         setTimeout(function(){
  557.             v3Lander.onDomReady();
  558.         }, t || 0);
  559.     },
  560.  
  561.     onDomReady:function(){
  562.        if (v3Lander.domReady) {
  563.             return;
  564.        }
  565.        v3Lander.domReady=true;
  566.         if (window.location.href.indexOf("?C2C")!=-1){
  567.             try{
  568.                 v3Lander.renderC2CDiv();
  569.                 v3Lander.parseC2CQueryString();
  570.                 v3Lander.registerDiv(200)
  571.             } catch(e) {}
  572.             return;
  573.         }
  574.        
  575.         try {
  576.             if (window != window.parent && !v3Lander.isAtHostedFileURL && window.document.domain == window.parent.document.domain) {
  577.                 return;
  578.             }
  579.         } catch(e) {
  580.            
  581.         }
  582.        if(!this.v3Frame) {
  583.             if(this.isBupMode || this.isRplMode) {
  584.                 this.requestPage();
  585.             }
  586.             else {
  587.                 this.createV3Frame();
  588.             }
  589.        } else {
  590.            this.initV3Frame();
  591.        }
  592.     },
  593.     injectIntoParent: function() {
  594.         function whenLoaded() {
  595.             win.v3Lander = window.v3Lander;
  596.             instance.createV3Frame(win);
  597.         }
  598.         var instance = this;
  599.        var win = top.top;
  600.        var doc = win.document;
  601.        if (!doc.readyState) {
  602.  
  603.         } else if (doc.readyState === "complete" || doc.readyState === "loaded") {
  604.             whenLoaded();
  605.         }
  606.        else {
  607.             if (window.addEventListener){
  608.                 window.addEventListener('load', whenLoaded, true);
  609.             } else if (window.attachEvent){
  610.                 window.attachEvent('onload', whenLoaded);
  611.             }
  612.         }
  613.     },
  614.  
  615.     testReady:function(){
  616.        var WAIT_PERIOD = 100;
  617.         var skipDomReadyTest = false;
  618.  
  619.        if (typeof jQuery != "undefined" && jQuery.isReady) {
  620.             v3Lander.setDomReadyTimeout(1);
  621.         } else if (skipDomReadyTest && !v3Lander.v3Frame) {
  622.             v3Lander.setDomReadyTimeout(1);
  623.        } else if (typeof document.readyState == "undefined") {
  624.             if (document.addEventListener){
  625.                 document.addEventListener("load",v3Lander.setDomReadyTimeout, false);
  626.                 document.addEventListener("DOMContentLoaded", v3Lander.setDomReadyTimeout, false);
  627.             }
  628.             v3Lander.setDomReadyTimeout(WAIT_PERIOD);
  629.         } else {
  630.            
  631.            var tridentVersion = navigator.userAgent.match(/Trident\/(\d+)/);
  632.             var newIeVersion = tridentVersion && tridentVersion.length == 2 && parseInt(tridentVersion[1]) >= 6;
  633.             if (document.readyState=="complete" && newIeVersion) {
  634.                 v3Lander.setDomReadyTimeout();
  635.             } else if (!newIeVersion && document.all && !window.opera){      
  636.                 try {
  637.                
  638.                     var isExitChat = false;
  639.                     if (isExitChat) {
  640.                        
  641.                         if (this.isAtHostedFileURL) {
  642.                             document.write('<iframe id="tcBBFrame" src="' + v3Lander.secureProtocol(window.v3LanderConfig.vanityDomain || 'https://sprint.inq.com')+'/tagserver/v3/blank.html" ' +
  643.                                 'frameborder="0" style="height:0px;width:0px;visibility:hidden" ' +
  644.                                 'onload="window.v3Lander._tcBBFrameOnload()"></iframe>');
  645.                         }
  646.                     }
  647.                
  648.                         document.write('<sc'+'ript type="text/javascript" id="v3ContentLoadTag" defer="defer" '+'></sc'+'ript>');
  649.                 } catch (e) {
  650.                     this.log(e);
  651.                 }
  652.                 var v3ContentLoadTag=document.getElementById("v3ContentLoadTag");
  653.                 if (v3ContentLoadTag){
  654.                     v3ContentLoadTag.onreadystatechange=function(){
  655.                         v3Lander.domState=this.readyState;
  656.                         if (this.readyState=="complete"){
  657.                             v3Lander.setDomReadyTimeout(WAIT_PERIOD);
  658.                         }
  659.                     };
  660.                 }
  661.                 else {
  662.                     this.uponError();
  663.                 }
  664.             }
  665.             else if (document.addEventListener || (newIeVersion && document.attachEvent)){
  666.                 if (/loaded|complete/.test(document.readyState)) {
  667.                     v3Lander.setDomReadyTimeout();
  668.                 } else {
  669.                    
  670.                     setTimeout(arguments.callee,100);
  671.                 }
  672.             }
  673.         }
  674.     },
  675.     uponError:function(){
  676.  
  677.         if (document.readyState == "complete") {
  678.             v3Lander.setDomReadyTimeout(1);
  679.         }
  680.         else {
  681.             document.attachEvent("onreadystatechange", function(){
  682.                 if (document.readyState === "complete") {
  683.                     document.detachEvent("onreadystatechange", arguments.callee);
  684.                     v3Lander.setDomReadyTimeout(1);
  685.                 }
  686.             });
  687.         }
  688.     },
  689.    
  690.    
  691.     removeNode:function(id){
  692.         try {
  693.             var tempID = document.getElementById(id);
  694.             var tag = null;
  695.             if (!!tempID)
  696.                 tag = parent.parent.tempID;
  697.             if (tag) {
  698.             tag = tag.parentNode ;
  699.             var p = tag.parentNode ;
  700.             var grandparent = parent.parent;
  701.             if (grandparent["Inq"]==null) return;
  702.             if (grandparent.Inq["removeProxyNode"]==null)
  703.                 grandparent.Inq["removeProxyNode"]= new grandparent.Function( "id",
  704.                 'var node=document.getElementById(id);\n'
  705.               + 'try{\n'
  706.               + 'if(!!node) {\n'
  707.               + 'var p=node.parentNode;\n'
  708.               + 'p.removeChild(node);\n'
  709.               + 'node=p;\n'
  710.               + 'if(!!node) {\n'
  711.               + 'p=node.parentNode;\n'
  712.               + 'p.removeChild(node);\n'
  713.               + '}\n'
  714.               + '}\n'
  715.               + '}catch(e){}\n'
  716.               );
  717.              grandparent.setTimeout('Inq.removeProxyNode("'+id+'")', 100);
  718.             }
  719.         } catch(ee){}
  720.     },
  721.    
  722.     removeNodeXF:function(id){
  723.         try {
  724.             var tag = parent.parent.document.getElementById(id);
  725.             if (tag) {
  726.                 tag = tag.parentNode ;
  727.                 var p = tag.parentNode ;
  728.                 if (p) try { p.removeChild(tag); } catch (e){}
  729.             }
  730.         } catch(e){}
  731.     },
  732.    
  733.     wrapWithTryCatch:function(code){
  734.         return "try {\n"
  735.              + code
  736.              + "\n} catch(e){"
  737.              + "Inq.log('ERROR:' + e.message);"
  738.              +"};";
  739.     },
  740.    
  741.     xframeToIjsf:function(){
  742.         var items = name.split("||");
  743.         var code = decodeURIComponent(items[3]);
  744.        
  745.         var chatStageWindow = window.parent.parent.parent.document.getElementById('inqChatStage').contentWindow;
  746.         chatStageWindow.setTimeout(v3Lander.wrapWithTryCatch(code), 1);
  747.     },
  748.    
  749.      xhfToIjsf:function(){
  750.         var code = decodeURIComponent(name);
  751.         var chatStageWindow = window.parent.parent;
  752.         chatStageWindow.setTimeout(v3Lander.wrapWithTryCatch(code), 1);
  753.     },
  754.    
  755.      postReturnsIE:function(){
  756.         var items = name.split("||");
  757.         var code = decodeURIComponent(items[1]);
  758.         var grandParent = window.parent;
  759.         /* NOTICE: in IE it is problematic to delete an active window
  760.          * Using eval, we were executing a code from this thread that deletes this iframe
  761.          * This caused problems in IE7 and IE6
  762.          * We replaced the eval with a timeout to ensure a different thread
  763.          * @author: fpinn@touchcommerce.com
  764.          */
  765.         /* Wrap the code with try catch */
  766.         grandParent.setTimeout(v3Lander.wrapWithTryCatch(code), 1);
  767.         v3Lander.removeNode(items[0]);
  768.     },
  769.    
  770.     postReturns:function(){
  771.         var items = name.split("||");
  772.         var code = decodeURIComponent(items[1]);
  773.         var grandParent = window.parent.parent;
  774.  
  775.         /* NOTICE: in IE it is problematic to delete an active window
  776.          * Using eval, we were executing a code from this thread that deletes this iframe
  777.          * This caused problems in IE7 and IE6
  778.          * We replaced the eval with a timeout to ensure a different thread
  779.          * @author: fpinn@touchcommerce.com
  780.          */
  781.         /* Wrap the code with try catch */
  782.         grandParent.setTimeout(v3Lander.wrapWithTryCatch(code), 1);
  783.         v3Lander.removeNode(items[0]);
  784.     },
  785.  
  786.     start:function(){
  787.         try {
  788.             this.assignDomain();
  789.             v3Lander.v3Frame= (window.frameElement && window.frameElement.id == "inqChatStage");
  790.         } catch(e){v3Lander.v3Frame=false}
  791.        
  792.         var isExitChat = false;
  793.         if (isExitChat) {
  794.            
  795.             if (this.isAtHostedFileURL) {
  796.                 this.prepBBDetect();
  797.             }
  798.         }
  799.         v3Lander.testReady();
  800.     }
  801. };
  802.  
  803.  
  804.  
  805.     v3Lander.hostToPath["DEVX-WCM.SPRINT.COM"]="/content/inqChat.html";
  806.  
  807.     v3Lander.hostToPath["TC-IMP.INQ.COM"]="/Implementation/sprint/inqChat.html";
  808.  
  809.     v3Lander.hostToPath["SITES.SPRINT.COM"]="/cm/bwtsatlanta/RightTouch/inqChat.html";
  810.  
  811.     v3Lander.hostToPath["PSDORT.TEST.SPRINT.COM"]="/nsschat/global/snippets/inq/inqChat.html";
  812.  
  813.     v3Lander.hostToPath["CST.CORP.SPRINT.COM"]="/nsschat/global/snippets/inq/inqChat.html";
  814.  
  815.     v3Lander.hostToPath["ICONNECT.CORP.SPRINT.COM"]="/docs/TouchCommerce/Care/inqChat.html";
  816.  
  817.     v3Lander.hostToPath["RTB2-M.TEST.SPRINT.COM"]="/mdot/mglobal/snippets/inq/inqChat.html";
  818.  
  819.     v3Lander.hostToPath["M.SPRINT.COM"]="/mobile/snippets/inq/inqChat.html";
  820.  
  821.  
  822.     v3Lander.establishHostedFileURL();
  823.     if (window.location.href.indexOf("surveys/launchNativePostChatSurvey") > -1) {
  824.         // In launchNativePostChatSurvey mode, it is at hosted file URL if url contains hostedFileURL=true.
  825.         // See createV3Frame where it inserts hostedFileURL=true into the url.
  826.         (v3Lander).isAtHostedFileURL = window.location.href.indexOf("hostedFileURL=true") > -1;
  827.     } else {
  828.         (v3Lander).isAtHostedFileURL = window.location.href.indexOf(v3Lander.hostedFileURL) > -1;
  829.     }
  830.     (v3Lander).assignDomain();
  831.    
  832.     if (window.location.href.indexOf("?BLNK")!=-1) {}
  833.     else if (window.location.href.indexOf("?CCFRM") != -1) {
  834.         var host = (window.v3LanderConfig.vanityDomain || "https://sprint.inq.com").replace(/^https?:\/\//, ""); // Strip the protocol. Domain only.
  835.         var url = "http://" + window.document.domain + "/tagserver/ccform/getCreditCardForm?host=" + host;
  836.         window.location.replace(url);
  837.     }
  838.     else if (window.location.href.indexOf("?CCTKN=1") != -1) {
  839.         var s = document.createElement("script");
  840.         // Need to pass the parameters along...
  841.         var params = window.location.href.replace(/^.*\?/,"?");
  842.         var src = (window.v3LanderConfig.vanityDomain || "https://sprint.inq.com") + "/tagserver/cctoken/getToken" + params;
  843.         s.src = src;
  844.         document.head.appendChild(s);
  845.     }
  846.     else if (window.location.href.indexOf("?CCTKN=2") != -1) {
  847.         var s = document.createElement("script");
  848.         // Need to pass the parameters along...
  849.         var params = window.location.href.replace(/^.*\?/,"?");
  850.         var src = (window.v3LanderConfig.vanityDomain || "https://sprint.inq.com") + "/tagserver/cctokentest/getToken" + params;
  851.         s.src = src;
  852.         document.head.appendChild(s);
  853.     }
  854.     else if (window.location.href.indexOf("?XHR")!=-1) {
  855.         v3Lander.xhfToIjsf() ;
  856.         window.close();
  857.     }
  858.     else if (window.location.href.indexOf("?IEXF")!=-1) {
  859.         v3Lander.assignDomain();
  860.         v3Lander.postReturnsIE();
  861.         window.close();
  862.     }
  863.    
  864.     else if (window.location.href.indexOf("?C2C")!=-1) {
  865.         v3Lander.testReady();
  866.     }
  867.     else if (window.location.href.indexOf("?INJECT")!=-1) {
  868.         v3Lander.injectIntoParent();
  869.     }
  870.  
  871.     /* This code is for resizing the iframe in the inner IFRAME (parents parent)
  872.     The name field of the window is "RESIZE||iframename||width||height */
  873.     else if (window.location.href.indexOf("?RSC2C")!=-1) {
  874.         v3Lander.resizeAnscestorIframe();
  875.     }
  876.     else if (window.location.href.indexOf("?POST2SERVER")!=-1) {
  877.         v3Lander.insertPostToServerTag();
  878.     }
  879.     else if (!!window.name && window.name.indexOf("||")!=-1 && v3Lander.isAtHostedFileURL) {
  880.         if (window.location.search == "?XFRM"){
  881.             v3Lander.xframeToIjsf() ;
  882.             window.close();
  883.         }
  884.         else{
  885.             v3Lander.assignDomain();
  886.             v3Lander.postReturns() ;
  887.             window.close();
  888.         }
  889.     }
  890.     else {
  891.         if (!window.v3LanderConfig.customLaunching) {
  892.             v3Lander.start();
  893.         }
  894.     }
  895. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement