window.__lpEnvSite = "21991129";
window.__watchDogURL = "https://va-healthcheck-service.public.openaiplatform.telstra.com/codi_consumer_health";
window.__businessWatchDogURL = "https://va-healthcheck-service.public.openaiplatform.telstra.com/codi_business_health";
window.__loadLivePersonSrc = function(){
window.lpTag=window.lpTag||{};if(typeof window.lpTag._tagCount==='undefined'){window.lpTag={site:window.__lpEnvSite||'81478844',section:lpTag.section||'',autoStart:lpTag.autoStart===false?false:true,ovr:lpTag.ovr||{},_v:'1.6.0',_tagCount:1,protocol:'https:',events:{bind:function(app,ev,fn){lpTag.defer(function(){lpTag.events.bind(app,ev,fn);},0);},trigger:function(app,ev,json){lpTag.defer(function(){lpTag.events.trigger(app,ev,json);},1);}},defer:function(fn,fnType){if(fnType==0){this._defB=this._defB||[];this._defB.push(fn);}else if(fnType==1){this._defT=this._defT||[];this._defT.push(fn);}else{this._defL=this._defL||[];this._defL.push(fn);}},load:function(src,chr,id){var t=this;setTimeout(function(){t._load(src,chr,id);},0);},_load:function(src,chr,id){var url=src;if(!src){url=this.protocol+'//'+((this.ovr&&this.ovr.domain)?this.ovr.domain:'lptag.liveperson.net')+'/tag/tag.js?site='+this.site;}var s=document.createElement('script');s.setAttribute('charset',chr?chr:'UTF-8');if(id){s.setAttribute('id',id);}s.setAttribute('src',url);document.getElementsByTagName('head').item(0).appendChild(s);},init:function(){this._timing=this._timing||{};this._timing.start=(new Date()).getTime();var that=this;if(window.attachEvent){window.attachEvent('onload',function(){that._domReady('domReady');});}else{window.addEventListener('DOMContentLoaded',function(){that._domReady('contReady');},false);window.addEventListener('load',function(){that._domReady('domReady');},false);}if(typeof(window._lptStop)=='undefined'){this.load();}},start:function(){this.autoStart=true;},_domReady:function(n){if(!this.isDom){this.isDom=true;this.events.trigger('LPT','DOM_READY',{t:n});}this._timing[n]=(new Date()).getTime();},vars:lpTag.vars||[],dbs:lpTag.dbs||[],ctn:lpTag.ctn||[],sdes:lpTag.sdes||[],ev:lpTag.ev||[]};lpTag.init();}else{window.lpTag._tagCount+=1;}
};
window.__disableVA = false;
window.__disableBusinessVA = false;
window.dtcPages = "https://www.my.telstra.com.au/myaccount/home,https://www.telstra.com.au/contact-us/account-billing/understand-bill,https://www.telstra.com.au/mobile-phones/prepaid-mobiles,https://www.telstra.com.au/tv-movies-music/foxtel-from-telstra,https://www.telstra.com.au/contact-us/plans-products/mobiles-tablets";
var lpSettings = lpSettings || {
"heading": "Need to talk to us?",
"description": "Please tell us what you want to chat about",
"persistentChat": true,
"options": {"route0": {"label": "Mobile & Tablet Plans","isActive": "true","section": "telstra,service,aem,consumer","childs": {"route0": {"label": "Bill & Plan Enquiries","isActive": "true","section": "service-mobile,virtualassistant","lead": "MOB-bill-plan-addon","help": "Help & Support
I need to understand my bill
Report a payment or reconnect my service
Request a payment extension
Arrange or update direct debit
Check my upgrade and recontracting fees
"}, "route1": {"label": "Buy Online","isActive": "true","section": "sales-mobile","lead": "MOB-buy-online","help": "Help & Support
Order a new mobile
Get a SIM only plan
Check my upgrade date and fees
Track my order
Get help with a back order"}, "route2": {"label": "Existing Order","isActive": "true","section": "service-general,virtualassistant","lead": "MOB-existing-order","help": "Help & Support
Track my order
Cancel or change my order
Confirm my plan details
Check my contract termination fees
Get help with a back order"}, "route3": {"label": "Fault","isActive": "true","section": "fault-mobile,virtualassistant","lead": "MOB-fault","help": "Help & Support
View our interactive mobile help guides
Unlock my iPhone
Check for outages"}, "route4": {"label": "SIM Replacement","isActive": "true","section": "mobile-sim-deflect","lead": "MOB-sim-rep"}, "route5": {"label": "Disconnection","isActive": "true","section": "saves","lead": "MOB-disconnection"}, "route6": {"label": "Other","isActive": "true","section": "service-general,mob-other,virtualassistant","lead": "MOB-other","help": "Help & Support
Check my contract termination fees
Track my order
I need to understand my bill
Account services
Try our online support articles"}}}, "route1": {"label": "Pre-Paid","isActive": "true","section": "telstra,service,aem,consumer","childs": {"route0": {"label": "Activate & Recharge","isActive": "true","section": "prepaid,virtualassistant","lead": "PPM-activate-recharge","help": "Help & Support
How to activate my Pre-Paid service
How to recharge my Pre-Paid service
Payment options
Check my activation status
Check out our Pre-Paid support articles"}, "route1": {"label": "Existing Order","isActive": "true","section": "prepaid,virtualassistant","lead": "PPM-existing-order","help": "Help & Support
How to activate my Pre-Paid service
How to change my plan
Check my activation status
Check out our Pre-Paid support articles
Track my order"}, "route2": {"label": "Offers & Plans","isActive": "true","section": "prepaid,virtualassistant","lead": "PPM-my-offer-plan","help": "Help & Support
View or change my plan
Explore available plans
Pre-Paid Plus packs
Pre-Paid expiry period
International roaming"}, "route3": {"label": "Fault","isActive": "true","section": "fault-prepaid,virtualassistant","lead": "PPM-fault","help": "Help & Support
Check for outages
Unlock my Telstra mobile
Pre-Paid troubleshooting tips
Pre-Paid support articles"}, "route4": {"label": "SIM Replacement","isActive": "true","section": "prepaid-sim-deflect","lead": "PPM-sim-rep","help": "Help & Support
Unlock my Telstra mobile
Track my order
Cancel or change my order
Pre-Paid support articles"}, "route5": {"label": "Disconnection","isActive": "true","section": "saves","lead": "PPM-disconnection"}}}, "route2": {"label": "NBN & Bundles","isActive": "true","section": "telstra,service,aem,consumer","childs": {"route0": {"label": "Buy Online","isActive": "true","section": "sales-nbn","lead": "NBN-buy-online","help": "Help & Support
Order a new service
See latest offers
Check my upgrade date and fees
Track my order"}, "route1": {"label": "Bill & Plan Enquiries","isActive": "true","section": "service-nbn,virtualassistant","lead": "NBN-bill-plan-addon","help": "Help & Support
Request a payment extension
Report a payment or reconnect my service
I want to pay my bill
I need to understand my bill
Arrange or update direct debit"}, "route2": {"label": "Existing Order","isActive": "true","section": "nbn-orders,virtualassistant","lead": "NBN-existing-order","help": "Help & Support
Track my order
Reschedule my appointment"}, "route3": {"label": "Moving Home","isActive": "true","section": "nbn-moves,virtualassistant","lead": "NBN-moving-home","help": "Help & Support
Move my service to another address
Track my order"}, "route4": {"label": "Fault","isActive": "true","section": "fault-nbn","lead": "NBN-fault","help": "Help & Support
Connecting my new service
Check for outages
Troubleshooting and tech support
How to use my service
Connection speed"}, "route5": {"label": "Disconnection","isActive": "true","section": "saves","lead": "NBN-disconnection"}}}, "route3": {"label": "Broadband, Bundles & Home Phone","isActive": "true","section": "telstra,service,aem,consumer","childs": {"route0": {"label": "Buy Online","isActive": "true","section": "sales-home,virtualassistant","lead": "BBHP-buy-online","help": "Help & Support
Order a new service
See latest offers
Check my upgrade date and fees
Track my order"}, "route1": {"label": "Bill & Plan Enquiries","isActive": "true","section": "service-home,virtualassistant","lead": "BBHP-bill-plan-addon","help": "Help & Support
Request a payment extension
Report a payment or reconnect my service
I need to understand my bill
Arrange or update direct debit
I want to query a charge on my bill"}, "route2": {"label": "Existing Order","isActive": "true","section": "service-bundles-home,virtualassistant","lead": "BBHP-existing-order","help": "Help & Support
Track my order
Reschedule my appointment"}, "route3": {"label": "Moving Home","isActive": "true","section": "copper-moves,virtualassistant","lead": "BBHP-moving-home","help": "Help & Support
Move my service to another address
Track my order"}, "route4": {"label": "Fault","isActive": "true","section": "fault-adsl,virtualassistant","lead": "BBHP-fault","help": "Help & Support
Connecting my new service
Check for outages
Troubleshooting and tech support
Mobile broadband tech support
Connection speed"}, "route5": {"label": "Disconnection","isActive": "true","section": "saves","lead": "BBHP-disconnection"}}}, "route4": {"label": "Entertainment & Apps","isActive": "true","section": "telstra,service,aem,consumer","childs": {"route0": {"label": "24x7 App","isActive": "true","section": "service-apps,virtualassistant","lead": "EAA-247-app","help": "Help & Support
Register for a Telstra ID
Retrieve my Telstra ID username
Retrieve my Telstra ID password"}, "route1": {"label": "Telstra Plus","isActive": "true","section": "telstra-plus,virtualassistant","lead": "EAA-telstraplus","help": "Help & Support
Join Telstra Plus
Find out more about Telstra Plus
View Telstra Plus FAQ
Register for a Telstra ID
Retrieve my Telstra ID username
Retrieve my Telstra ID password"}, "route2": {"label": "Email","isActive": "true","section": "fault-email,virtualassistant","lead": "EAA-email","help": "Help & Support
Troubleshoot email for PC
Troubleshoot email for mobile device
Forgot my username or password"}, "route3": {"label": "Foxtel","isActive": "true","section": "foxtel,virtualassistant","lead": "EAA-foxtel","help": "Help & Support
Foxtel FAQs
Foxtel from Telstra – Set up and configure
Foxtel Go"}, "route4": {"label": "My Account","isActive": "true","section": "service-apps,virtualassistant","lead": "EAA-my-acc","help": "Help & Support
Register for My Account
Retrieve my username
Retrieve or reset my password
Join Telstra Plus
Find out more about Telstra Plus"}, "route5": {"label": "Telstra Air","isActive": "true","section": "service-apps,virtualassistant","lead": "EAA-telstra-air","help": "Help & Support
Telstra Air – all you need to know"}, "route6": {"label": "Platinum","isActive": "true","section": "platinum","lead": "EAA-platinum","help": "Help & Support
Telstra Platinum"}}}, "route5": {"label": "Business Accounts & Products","isActive": "true","section": "telstra,service,aem,consumer,business,businessva","lead": "BAAP-none","childs": {}}},
"enableDTC": false,
"dtcSection": "tcom,non-auth,telstra,service,aem,consumer,dtc,virtualassistant",
"dtcLabel": "Need help? Let's chat."
};
/*
LivePerson class
*/
var console = console || {
log: function (log1, log2) {
}
};
var TelstraLivePerson = function (_config) {
this.data = _config;
this.persistentChatContainer = false;
this.backMask = false;
this.container = false;
this.containerBox = false;
this.closeBT = false;
this.childElements = {};
this.siteId = false;
this.section = false;
this.sourceSection = false;
this.authToken = false;
this.isDirect = false;
this.lead = false;
this.urlMap = window.__lpUrlMap || false;
this.callBack = false;
this.callBackInterval = 1; // in second
this.callBackTread = false;
this.chatWindowOpen = false;
var initParams = {};
var _vaSection = "virtualassistant";
var _vaSection2 = "va-livechat";
var _businessVaSection = "businessva";
var _instance = this;
var _defaultPersistentChatLabel = "Need help? Let's chat.";
var _initCalled = false;
// calculate some of the dtc params here so that they are not re-calculated unnecessarily
// do not consider query params or anchor tags when checking for current page url
var _dtcPages = window.dtcPages.split(",");
var thisPage = window.location.href.split(/[?#]/)[0];
var isDTCPage = _dtcPages.indexOf(thisPage) != -1;
this._watchDogURL = 'virtual-assistant-status';
if (window.__watchDogURL) {
this._watchDogURL = window.__watchDogURL;
}
this._businessWatchDogURL = 'virtual-assistant-status';
if (window.__businessWatchDogURL) {
this._businessWatchDogURL = window.__businessWatchDogURL;
}
this._watchDog = {
"virtual-assistant-status": {
"orchestrator": false,
"watson-virtual-agent": false,
"liveperson-agent-api": false,
"watson-tone-analyzer": false
}
};
this._businessWatchDog = {
"virtual-assistant-status": {
"orchestrator": false,
"watson-virtual-agent": false,
"liveperson-agent-api": false,
"watson-tone-analyzer": false
}
};
this.isDTCApplicableOnPage = function () {
// not applicable if DTC flag is off or if Consumer VA is not active
if (!this.data.enableDTC || !this.isVAActive()) {
return false;
}
return isDTCPage;
};
this.isVAActive = function () {
if (_instance._watchDog
&& (
(_instance._watchDog["virtual-assistant-status"]
&& _instance._watchDog["virtual-assistant-status"]["orchestrator"]
&& _instance._watchDog["virtual-assistant-status"]["watson-virtual-agent"]
&& _instance._watchDog["virtual-assistant-status"]["liveperson-agent-api"])
|| _instance._watchDog["active"] == true)
) {
return true;
} else {
return false;
}
};
this.isBusinessVAActive = function () {
if (_instance._businessWatchDog
&& (
(_instance._businessWatchDog["virtual-assistant-status"]
&& _instance._businessWatchDog["virtual-assistant-status"]["orchestrator"]
&& _instance._businessWatchDog["virtual-assistant-status"]["watson-virtual-agent"]
&& _instance._businessWatchDog["virtual-assistant-status"]["liveperson-agent-api"])
|| _instance._businessWatchDog["active"] == true)
) {
return true;
} else {
return false;
}
};
// async bind
var _style = "";
_style += '.telstra_live_person_back.hide, .telstra_live_person_containerBox.hide, .persistentChatContainer.hide{display:none;}';
_style += '.telstra_live_person_back{width:100%; height:1000%; position: absolute; top: 0; left: 0; background-color: #666666; opacity: 0.8;}';
_style += '.telstra_live_person_containerBox{width: 100%;position: fixed; top: 100px;font-size:14px;}';
_style += '.telstra_live_person_container{width: 80%; max-width:474px; max-height:100%; min-height: 220px; margin: 0px auto; background-color: #ffffff;color: #666666; padding: 10px;}';
_style += '.telstra_live_person_container_header{font-size: 24px; padding: 10px; border-bottom: 1px solid #dddddd;}';
_style += '.telstra_live_person_container_description{padding: 10px;}';
_style += '.telstra_live_person_container_routeLevel1{width: 90%; padding: 5px 10px; margin-bottom: 5px;}';
_style += '.telstra_live_person_container_routeLevel1>select{width: 100%; padding: 5px 0px;}';
_style += '.telstra_live_person_container_routeLevel2{width: 90%; padding: 5px 10px; margin-bottom: 5px;}';
_style += '.telstra_live_person_container_routeLevel2>select{width: 100%; padding: 5px 0px;}';
_style += '.telstra_live_person_container_chatNow_desc{width: 90%; padding: 5px 10px;}';
_style += '.telstra_live_person_container_chatNow_bt{float: right;left: -20px;}';
_style += '.persistentChatContainer{width:auto;position:fixed;bottom:0px;right:56px;}';
_style += '.persistentChatBtnContainer{max-width:1365px;margin-right:auto;margin-left:auto}';
_style += '.persistentChatBtn{background-color:#1a5199;padding:6px 10px 6px 12px;float:right;z-index:1040;text-decoration:none;cursor:pointer}';
_style += '.persistentChatBtn:hover{text-decoration:none !important}';
_style += '.persistentChatBtn:focus{color:#fff !important}';
_style += '.persistentChatLabel{padding-top:2px;font-weight:bold;font-size:16px;margin-left:36px;margin-right:5px;color:#fff}';
_style += '.persistentChatIcon{float:left;width:28px;padding:2px}';
_style += '@media only screen and (max-width:767px){.persistentChatBtnContainer{width:auto;} .persistentChatBtn{border-radius:50%;padding:18px;margin-bottom:40px;margin-right:30px} .persistentChatLabel{display:none} .persistentChatIcon{width:29px}}';
//_style+= '.LPMcontainer.LPMoverlay{display:none!important;}';
var _styleElement = document.createElement("STYLE");
_styleElement.innerHTML = _style;
document.getElementsByTagName('head')[0].appendChild(_styleElement);
var _asyncLoad = setTimeout(function () {
if (document.getElementsByTagName('body').length != 0) {
_instance.backMask = document.createElement('DIV');
_instance.backMask.setAttribute("class", "telstra_live_person_back hide");
_instance.container = document.createElement('DIV');
_instance.container.setAttribute("class", "telstra_live_person_container modal-content");
_instance.containerBox = document.createElement('DIV');
_instance.containerBox.setAttribute("class", "telstra_live_person_containerBox hide");
_instance.containerBox.appendChild(_instance.container);
_instance.closeBT = document.createElement('BUTTON');
_instance.closeBT.setAttribute("class", "close");
_instance.closeBT.onclick = function () {
_instance.hide();
};
_instance.container.appendChild(_instance.closeBT);
document.getElementsByTagName('body')[0].appendChild(_instance.backMask);
document.getElementsByTagName('body')[0].appendChild(_instance.containerBox);
_instance.render();
clearTimeout(_asyncLoad);
}
}, 500);
this.getPersistentSection = function (_initSetting) {
if (this.isDTCApplicableOnPage() && this.data.dtcSection != '') {
return this.data.dtcSection.split(",");
} else {
return this.getInitPersistentSection(_initSetting);
}
};
this.getInitPersistentSection = function (_initSetting) {
return this.data.persistentSection || (_initSetting && _initSetting.persistentSection);
};
this.getPersistentChatLabel = function (_initSetting) {
if (this.isDTCApplicableOnPage()) {
return this.data.dtcLabel;
} else {
return this.getInitPersistentChatLabel(_initSetting);
}
};
this.getInitPersistentChatLabel = function (_initSetting) {
return (_initSetting.persistentChatLabel && _initSetting.persistentChatLabel != "") ? _initSetting.persistentChatLabel : _defaultPersistentChatLabel;
};
this.getInitPersistentChatToggle = function (_initSetting) {
return this.data.persistentChat && _initSetting && _initSetting.persistentChat;
};
this.init = function (_initSetting) {
// store initSettings so we can use them later
initParams = _initSetting;
this.persistentChatToggle = this.getInitPersistentChatToggle(_initSetting);
var persistentChatLabel = this.getInitPersistentChatLabel(_initSetting);
this.data.persistentSection = this.getInitPersistentSection(_initSetting);
this.setupPersistentChat(this.persistentChatToggle, persistentChatLabel);
this.section = _initSetting.section || [];
if (this.urlMap) {
var _urlVal = document.URL.split("?")[0].split("#")[0];
if (this.urlMap[_urlVal]) {
this.section = this.urlMap[_urlVal];
}
}
this.sourceSection = _initSetting.sourceSection || [];
this.callBack = _initSetting.callBack || false;
this.callBackInterval = _initSetting.callBackInterval || this.callBackInterval;
/*Initializing TP TAG*/
window.lpTag = window.lpTag || {};
window.lpTag.section = this.section;
if (window.__loadLivePersonSrc) {
window.__loadLivePersonSrc();
// incase if lp overwrite sections
window.lpTag.section = this.section;
}
this.section = JSON.parse(JSON.stringify(this.sourceSection));
window.lpTag.sdes = lpTag.sdes || [];
this.isDirect = _initSetting.isDirect;
var _styleLocal = "";
if (!_initSetting.onlyTcomCSS) {
_styleLocal += '.telstra_live_person_container>.close {float: right;display: block;height: 26px;width: 26px;border: 0;padding: 0;cursor: pointer;background-color: #00aaf3;}';
_styleLocal += '.close:after {display: inline-block;content: "x";font-size: 18px !important;color: #fff !important;font-weight: normal !important;line-height: 26px;}';
if (_initSetting.forceButtonCss) {
_styleLocal += '.button,.btn {padding: 14px 20px 14px 20px;border: none;text-decoration: none;display: inline-block;white-space: nowrap;position: relative;outline: none;line-height: normal;max-width: 100%;background-color: #1964c8;color: #fff;}';
}
} else {
//Tcom Specific css
}
var _styleLocalElement = document.createElement("STYLE");
_styleLocalElement.innerHTML = _styleLocal;
document.getElementsByTagName('head')[0].appendChild(_styleLocalElement);
_initCalled = true;
// Add event Listener
window.lpTag.events.bind("lpUnifiedWindow", "state", function (_data) {
// when resume;
if (_data && (_data.state === "waiting" || _data.state === "resume")) {
if (_instance.callBackTread) {
clearInterval(_instance.callBackTread);
_instance.callBackTread = false;
} else if (_instance.callBack) {
_instance.callBackTread = setInterval(function () {
_instance.callBack();
}, _instance.callBackInterval * 1000);
}
} else if (_data && _data.state === "ended") {
// when ended;
if (_instance.callBackTread) {
clearInterval(_instance.callBackTread);
_instance.callBackTread = false;
}
}
if (_data && (_data.state === "waiting" || _data.state === "preChat" || _data.state === "chatting" || _data.state === "offline")) {
_instance.chatWindowOpen = true;
_instance.persistentChatContainer.classList.add('hide');
}
});
window.lpTag.events.bind("lpUnifiedWindow", "windowClosed", function (_data) {
_instance.chatWindowOpen = false;
_instance.persistentChatContainer.classList.remove('hide');
});
};
var _runLiveChat = function () {
var sdesConsumerConfig = {
"type": "ctmrinfo", //MANDATORY
"info": {
"cstatus": "non-auth"
}
};
if (_instance.authToken) {
sdesConsumerConfig.info.cstatus = "auth-tdi";
sdesConsumerConfig.info.customerId = _instance.authToken;
}
window.lpTag.sdes.push(sdesConsumerConfig);
if (_instance.lead) {
lpTag.sdes.push({
"type": "lead", //MANDATORY
"lead": {
"topic": _instance.lead + "" //Customers Level1+Level2 routing choice selection as string - REFER TO TAB3
// COLUMN E
}
});
}
// Section Manipulation for Consumer VA
if (window.__disableVA || !_instance.isVAActive()) {
// remove VA section
_instance.removeSection(_vaSection);
_instance.removeSection(_vaSection2);
}
// Section Manipulation for Business VA
if (window.__disableBusinessVA || !_instance.isBusinessVAActive()) {
// remove VA section
_instance.removeSection(_businessVaSection);
}
window.lpTag.newPage(document.URL, {
section: _instance.section //REFER TO TAB3 COLUMN I
});
_instance.section = JSON.parse(JSON.stringify(_instance.sourceSection));
var engagementId; // NOTE: The value of the var has to be an integer.
var ignoreOffer = false;
window.lpTag.events.bind("LP_OFFERS", "OFFER_IMPRESSION", function (data) { //This is triggered when the engagement has been displayed on the page.
if (data.engagementType === 6) {
// The ignoreOffer flag is added for the workaround, if it's true we don't execute the auto click code
if (ignoreOffer == undefined || !ignoreOffer) {
engagementId = data.engagementId;
var checkForChat = setInterval(checkRendererStubReady, 500);
function checkRendererStubReady() {
if (window.lpTag && window.lpTag.taglets && window.lpTag.taglets.rendererStub) {
var info = window.lpTag.taglets.rendererStub.getEngagementInfo(engagementId);
if (info.state != "undefined" && (info.state === 1 || info.state === 2)) {
window.lpTag.taglets.rendererStub.click(engagementId);
clearInterval(checkForChat);
}
}
}
} else {
// Turn the flag off for the next engagment impression
ignoreOffer = false;
}
}
});
// Bind to another event which triggers when the chat window state changes
window.lpTag.events.bind({
appName: 'API',
eventName: 'state',
func: function (data) {
// If received window init state, which means chat window is going to open
// We set the flag to true to ignore next impress which will be delivered immediately after window close.
// Adding 'ended' and 'applicationEnded' state for fallback
if (data === 'init' || data === 'ended' || data === 'applicationEnded') {
ignoreOffer = true;
if (data !== 'init') {
hidePersistentChatButton();
_instance.chatWindowOpen = true;
} else {
showPersistentChatButton();
_instance.chatWindowOpen = false;
}
} else if (data === 'postChat') {
_instance.chatWindowOpen = true;
// ignore postChat event for persistentChat Container show/hide to avoid flickering
} else {
hidePersistentChatButton();
_instance.chatWindowOpen = true;
}
}
});
};
this.show = function (_showConfig) {
var _computedShowConfig = _showConfig || {};
if (_computedShowConfig.section && _computedShowConfig.section.length && _computedShowConfig.section.length > 0) {
for (var _i = 0; _i < _computedShowConfig.section.length; _i++) {
this.updateSection(_computedShowConfig.section[_i]);
}
}
if (_computedShowConfig.authToken) {
this.authToken = _computedShowConfig.authToken;
this.updateSection("auth-tdi");
this.removeSection("non-auth");
} else {
this.updateSection("non-auth");
this.removeSection("auth-tdi");
}
if (_computedShowConfig.lead) {
this.lead = _computedShowConfig.lead;
}
// DTC override
if (this.isDTCApplicableOnPage() && this.data.dtcSection != '') {
// irrespective of the type of link clicked (2way routing or dtq), force dtq with dtcSection
this.section = this.data.dtcSection.split(",");
_computedShowConfig.isDirect = true;
}
if (this.isDirect || _computedShowConfig.isDirect) {
console.log("direct route");
_runLiveChat();
} else {
//add exclude
this.updateLPSection("exclude");
_instance.backMask.classList.remove('hide');
_instance.containerBox.classList.remove('hide');
_instance.persistentChatContainer.classList.add('hide');
}
};
this.hide = function () {
//Remove exclude
this.removeLPSection("exclude");
_instance.backMask.classList.add('hide');
_instance.containerBox.classList.add('hide');
_instance.childElements['routeLevel1Select'].value = "0";
_instance.onSelectRouter1(_instance.childElements['routeLevel1Select'].value);
_instance.persistentChatContainer.classList.remove('hide');
};
this.render = function () {
this.childElements['header'] = document.createElement("DIV");
this.childElements['header'].setAttribute("class", "telstra_live_person_container_header");
this.childElements['header'].innerHTML = this.data.heading;
this.container.appendChild(this.childElements['header']);
this.childElements['description'] = document.createElement("DIV");
this.childElements['description'].setAttribute("class", "telstra_live_person_container_description");
this.childElements['description'].innerHTML = this.data.description;
this.container.appendChild(this.childElements['description']);
this.childElements['routeLevel1'] = document.createElement("DIV");
this.childElements['routeLevel1Select'] = document.createElement("SELECT");
var _defaultOption = document.createElement("OPTION");
_defaultOption.value = "0";
_defaultOption.innerHTML = "Choose a category";
this.childElements['routeLevel1Select'].appendChild(_defaultOption);
for (var _option in this.data.options) {
var _localOption = document.createElement("OPTION");
_localOption.value = _option;
_localOption.innerHTML = this.data.options[_option].label;
this.childElements['routeLevel1Select'].appendChild(_localOption);
}
this.childElements['routeLevel1Select'].onchange = function (e) {
_instance.onSelectRouter1(e.target.value);
};
this.childElements['routeLevel1'].setAttribute("class", "telstra_live_person_container_routeLevel1");
this.childElements['routeLevel1'].appendChild(this.childElements['routeLevel1Select']);
this.container.appendChild(this.childElements['routeLevel1']);
//this.container.innerHTML = "Popup";
this.childElements['routeLevel2'] = document.createElement("DIV");
this.childElements['routeLevel2'].setAttribute("class", "telstra_live_person_container_routeLevel2");
this.container.appendChild(this.childElements['routeLevel2']);
// Chat now component
this.childElements['chatNow'] = document.createElement("DIV");
this.childElements['chatNow'].setAttribute("class", "telstra_live_person_container_chatNow");
this.container.appendChild(this.childElements['chatNow']);
};
this.onSelectRouter1 = function (_id) {
console.log("Route1Selected:" + _id);
//clear child
while (this.childElements['routeLevel2'].firstChild) {
this.childElements['routeLevel2'].removeChild(this.childElements['routeLevel2'].firstChild);
}
if (_id + "" != "0") {
if (this.data.options[_id].childs && JSON.stringify(this.data.options[_id].childs) != JSON.stringify({})) {
var _dataOptions = this.data.options[_id].childs;
this.childElements['routeLevel2Select'] = document.createElement("SELECT");
this.childElements['routeLevel2'].appendChild(this.childElements['routeLevel2Select']);
var _defaultOption = document.createElement("OPTION");
_defaultOption.value = "0";
_defaultOption.innerHTML = "Choose a category";
this.childElements['routeLevel2Select'].appendChild(_defaultOption);
for (var _option in _dataOptions) {
var _localOption = document.createElement("OPTION");
_localOption.value = _option;
_localOption.innerHTML = _dataOptions[_option].label;
this.childElements['routeLevel2Select'].appendChild(_localOption);
}
this.childElements['routeLevel2Select'].onchange = function (e) {
_instance.onSelectRouter2(e.target.value);
};
this.showChatNow(false, false);
} else {
this.childElements['routeLevel2Select'] = false;
var _parentObject = false;
for (var _option in this.data.options) {
if (_option === _id) {
_parentObject = this.data.options[_option];
_parentObject.id = _id;
}
}
this.showChatNow(_parentObject, false);
console.log("No child route found for " + _id);
}
} else {
this.showChatNow(false, false);
}
};
this.onSelectRouter2 = function (_id) {
var _ParentRouteId = this.childElements['routeLevel1Select'].value;
var _ChildRouteId = this.childElements['routeLevel2Select'];
if (_ChildRouteId) {
_ChildRouteId = _ChildRouteId.value;
}
var _parentObject = false;
var _childObject = false;
for (var _option in this.data.options) {
if (_option === _ParentRouteId) {
_parentObject = this.data.options[_option];
_parentObject.id = _ParentRouteId;
for (var _childOption in this.data.options[_option].childs) {
if (_childOption === _ChildRouteId) {
_childObject = this.data.options[_option].childs[_childOption];
_childObject.id = _ChildRouteId;
}
}
}
}
if (_id + "" == "0") {
this.showChatNow(false, false);
} else {
this.showChatNow(_parentObject, _childObject);
}
};
this.showChatNow = function (_parentObject, _childObject) {
var _showableObj = _childObject || _parentObject;
var _helpShowable = function (_arrString) {
var __returnObj = true;
if (_arrString && _arrString.length > 0) {
for (var _arrStringI = 0; _arrStringI < _arrString.length; _arrStringI++) {
var _sectionArr = _arrString[_arrStringI].split(',');
for (var _sectionArrI = 0; _sectionArrI < _sectionArr.length; _sectionArrI++) {
if (_sectionArr[_sectionArrI] == _vaSection) {
//__returnObj = false;
}
}
}
}
return __returnObj;
};
//clear child
while (this.childElements['chatNow'].firstChild) {
this.childElements['chatNow'].removeChild(this.childElements['chatNow'].firstChild);
}
if (!_showableObj) {
return;
}
if (_showableObj.lead) {
this.lead = _showableObj.lead;
} else {
this.lead = false;
}
var _infoArray = [];
_infoArray[0] = _parentObject.section;
if (_childObject) {
_infoArray[1] = _childObject.section;
}
this.childElements['chatNowDesc'] = document.createElement("DIV");
this.childElements['chatNowDesc'].setAttribute("class", "telstra_live_person_container_chatNow_desc");
this.childElements['chatNow'].appendChild(this.childElements['chatNowDesc']);
if (_showableObj.help && _showableObj.help != "") {
// remove if section for child or parent has _vaSection
var _sectionStringArr = [];
if (_parentObject && _parentObject.section) {
_sectionStringArr[_sectionStringArr.length] = _parentObject.section;
}
if (_childObject && _childObject.section) {
_sectionStringArr[_sectionStringArr.length] = _childObject.section;
}
if (_helpShowable(_sectionStringArr) || window.__disableVA || (!window.__disableVA && !_instance.isVAActive())) {
this.childElements['chatNowDesc'].innerHTML = _showableObj.help;
}
}
this.childElements['chatNowBt'] = document.createElement("A");
this.childElements['chatNowBt'].setAttribute("class", "telstra_live_person_container_chatNow_bt btn primary");
this.childElements['chatNowBt'].innerHTML = "Chat now";
this.childElements['chatNowBt'].setAttribute("href", "javascript:void(0);");
// Adding Chat initialisation
this.childElements['chatNowBt'].onclick = function () {
_instance.initChat(_infoArray);
};
this.childElements['chatNow'].appendChild(this.childElements['chatNowBt']);
var _clearDiv = document.createElement("DIV");
_clearDiv.style.clear = "both";
this.childElements['chatNow'].appendChild(_clearDiv);
};
this.updateSection = function (_id) {
var _isUnique = true;
for (var _i = 0; _i < this.section.length; _i++) {
if (_id === this.section[_i]) _isUnique = false;
}
if (_isUnique)
this.section[this.section.length] = _id;
};
this.removeSection = function (_id) {
var _updateSections = [];
var _hasSection = false;
for (var _i = 0; _i < this.section.length; _i++) {
if (_id !== this.section[_i]) {
_updateSections[_updateSections.length] = this.section[_i];
} else {
_hasSection = true;
}
}
if (_hasSection)
this.section = _updateSections;
};
this.updateLPSection = function (_id) {
var _isUnique = true;
for (var _i = 0; _i < window.lpTag.section.length; _i++) {
if (_id === window.lpTag.section[_i]) _isUnique = false;
}
if (_isUnique)
window.lpTag.section[window.lpTag.section.length] = _id;
};
this.removeLPSection = function (_id) {
var _updateSections = [];
var _hasSection = false;
for (var _i = 0; _i < window.lpTag.section.length; _i++) {
if (_id !== window.lpTag.section[_i]) {
_updateSections[_updateSections.length] = window.lpTag.section[_i];
} else {
_hasSection = true;
}
}
if (_hasSection)
window.lpTag.section = _updateSections;
};
this.initChat = function (args) {
console.log("Initiate Live Chat with Args", args);
for (var _i = 0; _i < args.length; _i++) {
if (args[_i].indexOf(",") === -1) {
this.updateSection(args[_i]);
} else {
var _localArgs = args[_i].split(",");
for (var _j = 0; _j < _localArgs.length; _j++) {
this.updateSection(_localArgs[_j]);
}
}
}
_runLiveChat();
this.hide();
};
this.setupPersistentChat = function (persistentChatToggle, persistentChatLabel) {
_instance.persistentChatContainer = document.createElement('DIV');
_instance.persistentChatContainer.setAttribute("class", "persistentChatContainer");
// delay showing chat everywhere button until consumer va health check query completes
hidePersistentChatButton();
document.getElementsByTagName('body')[0].appendChild(_instance.persistentChatContainer);
if (persistentChatToggle) {
_instance.persistentChatBtnContainer = document.createElement('DIV');
_instance.persistentChatBtnContainer.setAttribute("class", "persistentChatBtnContainer");
_instance.persistentChatBtn = document.createElement('DIV');
_instance.persistentChatBtn.setAttribute("class", "persistentChatBtn");
_instance.persistentChatIcon = document.createElement('IMG');
_instance.persistentChatIcon.setAttribute("class", "persistentChatIcon");
_instance.persistentChatIcon.src = "https://www.telstra.com.au/etc/designs/liveperson/icon-speech.png";
_instance.persistentChatBtn.appendChild(_instance.persistentChatIcon);
_instance.persistentChatLabel = document.createElement('DIV');
_instance.persistentChatLabel.setAttribute("class", "persistentChatLabel");
_instance.persistentChatLabel.innerHTML = persistentChatLabel;
_instance.persistentChatBtn.appendChild(_instance.persistentChatLabel);
_instance.persistentChatBtn.onclick = function () {
// Note: RetrieveChatAuthToken will call liveperson.show function.
/* if (window.RetrieveChatAuthToken) {
if (!_instance.data.persistentSection) {
window.RetrieveChatAuthToken([], false);
} else {
window.RetrieveChatAuthToken(_instance.data.persistentSection, true);
}
}
else {*/
if (!_instance.data.persistentSection || _instance.data.persistentSection.length === 0) {
_instance.show();
} else {
_instance.show({isDirect: true, section: _instance.data.persistentSection});
}
//}
};
//_instance.persistentChatBtn.href = "#";
_instance.persistentChatBtn.setAttribute("title", persistentChatLabel);
_instance.persistentChatBtn.setAttribute("id", "persistentChatBtnId"); //used for omniture tracking
_instance.persistentChatBtnContainer.appendChild(_instance.persistentChatBtn);
_instance.persistentChatContainer.appendChild(_instance.persistentChatBtnContainer);
}
};
var hidePersistentChatButton = function () {
if (_instance.persistentChatToggle) {
_instance.persistentChatContainer.classList.add('hide');
}
};
var showPersistentChatButton = function () {
if (_instance.persistentChatToggle) {
_instance.persistentChatContainer.classList.remove('hide');
}
};
// Set Persistent Parameters
this.setPersistentParameters = function (persistentSection, persistentChat) {
this.data.persistentSection = persistentSection || [];
if (!persistentChat) {
persistentChat = false;
}
if (this.persistentChatContainer !== false && persistentChat === false) {
hidePersistentChatButton();
}
if (persistentChat === true) {
if (!_initCalled || (this.persistentChatContainer !== false && (this.persistentChatContainer.childElementCount === 0))) {
// if init method was not called or if it was called but persistentChatContainer and its children were not created due to toggle being false, create the container again
this.setupPersistentChat(persistentChat, this.getPersistentChatLabel(initParams));
} else {
this.persistentChatToggle = persistentChat;
if (!_instance.chatWindowOpen) {
showPersistentChatButton();
}
}
}
this.persistentChatToggle = persistentChat;
};
// Load VA Orchestrator Config
var _loadWatchDog = function () {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
if (this.readyState == 4) {
if (this.status == 200) {
//this.responseText;
_instance._watchDog = JSON.parse(this.responseText);
}
// delay updating chat everywhere button so that init call can finish creating dom elements
setTimeout(updateDtcChatEverywhere, 3000);
}
};
xhttp.open("GET", _instance._watchDogURL, true);
xhttp.send();
};
var updateDtcChatEverywhere = function(){
// show chat everywhere button based on DTC, bot availability and global persistent chat toggle
if(_instance.persistentChatLabel) {
_instance.persistentChatLabel.innerHTML = _instance.getPersistentChatLabel(initParams);
}
_instance.setPersistentParameters(_instance.getPersistentSection(initParams), _instance.getInitPersistentChatToggle(initParams));
};
// Load Business VA Orchestrator Status
var _loadBusinessWatchDog = function () {
var bxhttp = new XMLHttpRequest();
bxhttp.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
//this.responseText;
_instance._businessWatchDog = JSON.parse(this.responseText);
}
};
bxhttp.open("GET", _instance._businessWatchDogURL, true);
bxhttp.send();
};
if (!window.__disableVA) {
_loadWatchDog();
}
if (!window.__disableBusinessVA) {
_loadBusinessWatchDog();
}
};
var lpSettings = lpSettings || {};
var livePerson = new TelstraLivePerson(lpSettings);