_satellite["_runScript3"](function(event, target, Promise) {
// Script to open drift chat for either link or button.
(function() {
/* Add this class to any elements you want to use to open Drift.
*
* Examples:
* - Questions? We're here to help!
* -
*
* You can have any additional classes on those elements that you
* would like.
*/
var DRIFT_CHAT_SELECTOR = '.drift-open-chat'
/* http://youmightnotneedjquery.com/#ready */
function ready(fn) {
if (document.readyState != 'loading') {
fn();
} else if (document.addEventListener) {
document.addEventListener('DOMContentLoaded', fn);
} else {
document.attachEvent('onreadystatechange', function() {
if (document.readyState != 'loading')
fn();
});
}
}
/* http://youmightnotneedjquery.com/#each */
function forEachElement(selector, fn) {
var elements = document.querySelectorAll(selector);
for (var i = 0; i < elements.length; i++)
fn(elements[i], i);
}
function openChat(driftApi, event) {
event.preventDefault();
var configuredInteractionId = parseInt(event.target.dataset.interactionid ? event.target.dataset.interactionid : event.srcElement.closest('.drift-open-chat').getAttribute('data-interactionId'));
if (localStorage && localStorage.getItem('avlrDriftDebug')) {
_satellite.logger.log('interaction id: ', configuredInteractionId);
}
if(configuredInteractionId && Number.isInteger(configuredInteractionId)){
driftApi.startInteraction({ interactionId: configuredInteractionId });
}else{
driftApi.openChat();
}
return false;
}
function collectAdobeId() {
try {
var adobeid= _satellite.getVisitorId().getMarketingCloudVisitorID();
drift.on('ready', function() {
drift.api.setUserAttributes({
adobeId: adobeid,
eloquaFormName: 'AvaForm-Chat',
});
});
} catch (err) {
if (localStorage && localStorage.getItem('avlrDriftDebug')) {
_satellite.logger.log('Error getting adobeId for drift usage', JSON.stringify(err));
}
}
} collectAdobeId();
ready(function() {
drift.on('ready', function(api) {
var handleClick = openChat.bind(this, api)
forEachElement(DRIFT_CHAT_SELECTOR, function(el) {
el.addEventListener('click', handleClick);
});
});
});
})();
});