// Define the client side app that drives the comms to the server var lillyLiveAgent = { debug : false, // element to use when chat is available domElementWhenChatIsAvailable : null, // element to use when chat is unavailable domElementWhenChatIsUnavailable : null, // array to determine which chat buttons are active chatButtonsActive : [], respondToButtonEvent : function (buttonId, e) { lillyLiveAgent.consoleLog('buttonId == '+buttonId); lillyLiveAgent.consoleLog('e == '+e); lillyLiveAgent.consoleLog('chatButtonsActive.indexOf(buttonId) == '+lillyLiveAgent.chatButtonsActive.indexOf(buttonId)); if (e == liveagent.BUTTON_EVENT.BUTTON_AVAILABLE) { if (lillyLiveAgent.chatButtonsActive.indexOf(buttonId) == -1) { lillyLiveAgent.chatButtonsActive[lillyLiveAgent.chatButtonsActive.length] = buttonId; } } if (e == liveagent.BUTTON_EVENT.BUTTON_UNAVAILABLE) { if (lillyLiveAgent.chatButtonsActive.indexOf(buttonId) != -1) { lillyLiveAgent.chatButtonsActive.splice(lillyLiveAgent.chatButtonsActive.indexOf(buttonId), 1); } } lillyLiveAgent.consoleLog('chatButtonsActive == '+lillyLiveAgent.chatButtonsActive.toString()); if (lillyLiveAgent.chatButtonsActive.length == 0) { $('#'+lillyLiveAgent.domElementWhenChatIsAvailable).hide() $('#'+lillyLiveAgent.domElementWhenChatIsUnavailable).show() } else { $('#'+lillyLiveAgent.domElementWhenChatIsAvailable).show() $('#'+lillyLiveAgent.domElementWhenChatIsUnavailable).hide() } }, respondToButtonEvent_573F0000000blJJ : function (e) { lillyLiveAgent.consoleLog('573F0000000blJJ e == '+e); lillyLiveAgent.respondToButtonEvent('573F0000000blJJ', e); }, respondToButtonEvent_573F0000000CbIL : function (e) { lillyLiveAgent.consoleLog('573F0000000CbIL e == '+e); lillyLiveAgent.respondToButtonEvent('573F0000000CbIL', e); }, respondToButtonEvent_5735d000000WBlq : function (e) { lillyLiveAgent.consoleLog('5735d000000WBlq e == '+e); lillyLiveAgent.respondToButtonEvent('5735d000000WBlq', e); }, respondToButtonEvent_573F0000000Ccqe : function (e) { lillyLiveAgent.consoleLog('573F0000000Ccqe e == '+e); lillyLiveAgent.respondToButtonEvent('573F0000000Ccqe', e); }, respondToButtonEvent_5735d000000NaX9 : function (e) { lillyLiveAgent.consoleLog('5735d000000NaX9 e == '+e); lillyLiveAgent.respondToButtonEvent('5735d000000NaX9', e); }, respondToButtonEvent_5735d000000NaWz : function (e) { lillyLiveAgent.consoleLog('5735d000000NaWz e == '+e); lillyLiveAgent.respondToButtonEvent('5735d000000NaWz', e); }, setupCompatibilityFunctions : function() { if ( ! Array.prototype.indexOf ) { // IE8, IE7 don't support indexOf Array.prototype.indexOf = function(obj, start) { var startingIndex = 0; for (var i = (start || 0), j = this.length; i < j; i++) { if (this[i] === obj) { return i; } } return -1; } } }, // initialize routines initialize : function() { lillyLiveAgent.consoleLog('initialize started'); // Create a div element for each button needing to track lillyLiveAgent.setupTrackingElements(); if (lillyLiveAgent.domElementWhenChatIsAvailable == null) { lillyLiveAgent.consoleLog('domElementWhenChatIsAvailable is not set'); } if (lillyLiveAgent.domElementWhenChatIsUnavailable == null) { lillyLiveAgent.consoleLog('domElementWhenChatIsUnavailable is not set'); } if (lillyLiveAgent.domElementWhenChatIsAvailable == null || lillyLiveAgent.domElementWhenChatIsUnavailable == null) { lillyLiveAgent.consoleLog('lillyLiveAgent initialize aborted'); return; } // Initialise liveagent lillyLiveAgent.consoleLog('https://d.la7cs.salesforceliveagent.com/chat---572F0000000CcmR---00DF0000000Bmu9', liveagent.disableOptionalCookies()); //liveagent.init('https://d.la7cs.salesforceliveagent.com/chat', '572F0000000CcmR', '00DF0000000Bmu9', liveagent.disableOptionalCookies()); liveagent.init('https://d.la2-c1-phx.salesforceliveagent.com/chat', '572F0000000CcmR', '00DF0000000Bmu9', liveagent.disableOptionalCookies()); if (lillyLiveAgent.debug) { liveagent.enableLogging(); } if ( ! window._laq ) { window._laq = []; } window._laq.push ( function() { liveagent.showWhenOnline('573F0000000blJJ', document.getElementById('liveagent_button_online_573F0000000blJJ')); liveagent.addButtonEventHandler('573F0000000blJJ', lillyLiveAgent.respondToButtonEvent_573F0000000blJJ); liveagent.showWhenOnline('573F0000000CbIL', document.getElementById('liveagent_button_online_573F0000000CbIL')); liveagent.addButtonEventHandler('573F0000000CbIL', lillyLiveAgent.respondToButtonEvent_573F0000000CbIL); liveagent.showWhenOnline('5735d000000WBlq', document.getElementById('liveagent_button_online_5735d000000WBlq')); liveagent.addButtonEventHandler('5735d000000WBlq', lillyLiveAgent.respondToButtonEvent_5735d000000WBlq); liveagent.showWhenOnline('573F0000000Ccqe', document.getElementById('liveagent_button_online_573F0000000Ccqe')); liveagent.addButtonEventHandler('573F0000000Ccqe', lillyLiveAgent.respondToButtonEvent_573F0000000Ccqe); liveagent.showWhenOnline('5735d000000NaX9', document.getElementById('liveagent_button_online_5735d000000NaX9')); liveagent.addButtonEventHandler('5735d000000NaX9', lillyLiveAgent.respondToButtonEvent_5735d000000NaX9); liveagent.showWhenOnline('5735d000000NaWz', document.getElementById('liveagent_button_online_5735d000000NaWz')); liveagent.addButtonEventHandler('5735d000000NaWz', lillyLiveAgent.respondToButtonEvent_5735d000000NaWz); liveagent.showWhenOnline('573F0000000Cd0C', document.getElementById('liveagent_button_online_573F0000000Cd0C')); } ); $( '#'+lillyLiveAgent.domElementWhenChatIsAvailable ).click(function() { liveagent.startChat('573F0000000Cd0C'); }); $( '#'+lillyLiveAgent.domElementWhenChatIsUnavailable ).click(function() { if('UT' == 'US' || 'UT' == 'UT' ){ window.open("https://customerconnect.my.salesforce-sites.com/liveagent/Prechat_form_LillyMedicalcom");} }); lillyLiveAgent.consoleLog('initialize complete'); }, setupChatWindowSizing : function() { var ie10 = $.browser.msie && $.browser.versionNumber == '10'; var ie9 = $.browser.msie && $.browser.versionNumber == '9'; //lillyLiveAgent.consoleLog('setupChatWindowSizing:::>UT'); if ($.browser.msie) { liveagent.setChatWindowHeight(681); liveagent.setChatWindowWidth(630); } else if ($.browser.safari) { liveagent.setChatWindowHeight(645); liveagent.setChatWindowWidth(630); } else { liveagent.setChatWindowHeight(642); liveagent.setChatWindowWidth(632); } //CR#CHG1306214(GCO System: To implement live agent functionality for Germany) Modified By: Kashima Khanna TCS on 12-Oct-2018 }, setupTrackingElements : function() { var div = document.createElement('div'); div.setAttribute('id', 'liveagent_button_online_573F0000000blJJ'); div.className = 'placeholder-live-agent-chat-btn'; div.style.display = 'none'; // test case, append the div to the body document.body.appendChild(div); var div = document.createElement('div'); div.setAttribute('id', 'liveagent_button_online_573F0000000CbIL'); div.className = 'placeholder-live-agent-chat-btn'; div.style.display = 'none'; // test case, append the div to the body document.body.appendChild(div); var div = document.createElement('div'); div.setAttribute('id', 'liveagent_button_online_5735d000000WBlq'); div.className = 'placeholder-live-agent-chat-btn'; div.style.display = 'none'; // test case, append the div to the body document.body.appendChild(div); var div = document.createElement('div'); div.setAttribute('id', 'liveagent_button_online_573F0000000Ccqe'); div.className = 'placeholder-live-agent-chat-btn'; div.style.display = 'none'; // test case, append the div to the body document.body.appendChild(div); var div = document.createElement('div'); div.setAttribute('id', 'liveagent_button_online_5735d000000NaX9'); div.className = 'placeholder-live-agent-chat-btn'; div.style.display = 'none'; // test case, append the div to the body document.body.appendChild(div); var div = document.createElement('div'); div.setAttribute('id', 'liveagent_button_online_5735d000000NaWz'); div.className = 'placeholder-live-agent-chat-btn'; div.style.display = 'none'; // test case, append the div to the body document.body.appendChild(div); var div = document.createElement('div'); div.setAttribute('id', 'liveagent_button_online_573F0000000Cd0C'); div.className = 'placeholder-live-agent-chat-btn'; div.style.display = 'none'; // test case, append the div to the body document.body.appendChild(div); }, // load event to setup environment load : function() { lillyLiveAgent.setupCompatibilityFunctions(); // load the Javascript libraries required lillyLiveAgent.loadJavascriptLibraries(); lillyLiveAgent.verifyJSLibsAndInitialize(); }, verifySecondaryJSLibsAttempts : 0, verifySecondaryJSLibsAndSetupChatWindowSizing : function() { lillyLiveAgent.consoleLog('verifySecondaryJSLibsAndSetupChatWindowSizing started'); if (lillyLiveAgent.verifySecondaryJSLibsAttempts == 5) { lillyLiveAgent.consoleLog('verifySecondaryJSLibsAndSetupChatWindowSizing fifth attempt to verify loading a library. Aborting script.'); return; } lillyLiveAgent.verifySecondaryJSLibsAttempts += 1; if (typeof $.browser === 'undefined') { lillyLiveAgent.consoleLog('$.browser library not found'); var timeoutID = window.setTimeout(lillyLiveAgent.verifySecondaryJSLibsAndSetupChatWindowSizing, 300); } else { lillyLiveAgent.consoleLog('$.browser library found'); lillyLiveAgent.setupChatWindowSizing(); } }, verifyJSLibsAttempts : 0, verifyJSLibsAndInitialize : function() { lillyLiveAgent.consoleLog('verifyJSLibsAndInitialize started'); if (lillyLiveAgent.verifyJSLibsAttempts == 5) { lillyLiveAgent.consoleLog('verifyJSLibsAndInitialize fifth attempt to verify loading a library. Aborting script.'); return; } lillyLiveAgent.verifyJSLibsAttempts += 1; if (typeof jQuery === 'undefined') { lillyLiveAgent.consoleLog('jQuery library not found'); var timeoutID = window.setTimeout(lillyLiveAgent.verifyJSLibsAndInitialize, 300); } else if (typeof liveagent === 'undefined') { lillyLiveAgent.consoleLog('liveagent library not found'); var timeoutID = window.setTimeout(lillyLiveAgent.verifyJSLibsAndInitialize, 300); } else { lillyLiveAgent.loadSecondTierJavascriptLibraries(); lillyLiveAgent.consoleLog('all libraries found'); lillyLiveAgent.initialize(); lillyLiveAgent.verifySecondaryJSLibsAndSetupChatWindowSizing(); } }, loadJavascriptLibraries : function() { lillyLiveAgent.verifyJSLibsAttempts = 0; lillyLiveAgent.consoleLog('loading the JQuery library'); var script = document.createElement('script'); script.src = 'https://customerconnect.my.salesforce-sites.com/liveagent/resource/1705759386000/liveAgentCommon/script/jquery-3.7.1.min.js'; if ( !document.head || !document.head.appendChild ) { //document.appendChild(script); document.getElementsByTagName('head')[0].appendChild(script); } else { document.head.appendChild(script); } lillyLiveAgent.consoleLog('loading the Live Agent Deployment library'); var script = document.createElement('script'); //script.src = 'https://customerconnect.my.salesforce-sites.com/liveagent/resource/1705759386000/liveAgentCommon/script/liveagent-deployment-29.0.js'; script.src = 'https://customerconnect.my.salesforce-sites.com/liveagent/resource/1705759386000/liveAgentCommon/script/liveagent-deployment-52.0.js'; if ( !document.head || !document.head.appendChild ) { //document.appendChild(script); document.getElementsByTagName('head')[0].appendChild(script); } else { document.head.appendChild(script); } lillyLiveAgent.consoleLog('loading completed'); }, loadSecondTierJavascriptLibraries : function() { lillyLiveAgent.verifySecondaryJSLibsAttempts = 0; lillyLiveAgent.consoleLog('loading the JQuery Browser library'); var script = document.createElement('script'); script.src = 'https://customerconnect.my.salesforce-sites.com/liveagent/resource/1705759386000/liveAgentCommon/script/jquery.browser-0.0.5.min.js'; if ( !document.head || !document.head.appendChild ) { //document.appendChild(script); document.getElementsByTagName('head')[0].appendChild(script); } else { document.head.appendChild(script); } }, consoleLog : function(message) { if (lillyLiveAgent.debug) { if (typeof console !== 'undefined' && typeof console.log !== 'undefined') { console.log(message); } } } }