If you're interested in going to a match: Click on the date line above and a window will open to the ticket purchase page. TV information will be added when it becomes available (probably in January).
/* eslint-disable no-console */
class VideoEngager {
constructor () {
let popupinstance = null;
let iframeHolder = null;
let iframeInstance;
let oVideoEngager;
let interactionId;
let TENANT_ID;
let startWithVideo;
let autoAccept;
let platform;
let extraAgentMessage;
let veUrl;
let enablePrecall;
let i18n;
let useWebChatForm;
let webChatFormData;
let title;
let submitButton;
let customAttributes;
const i18nDefault = {
en: {
ChatFormSubmitVideo: 'Start Video',
WebChatTitleVideo: 'Video Chat',
ChatFormSubmitAudio: 'Start Audio',
WebChatTitleAudio: 'Audio Chat'
}
};
let form;
let enablePrecallForced;
const KEEP_ALIVE_TIME = 10 * 60 * 1000; // keep alive time 10min
let keepAliveTimer;
const init = function () {
const config = window._genesys.widgets.videoengager;
TENANT_ID = config.tenantId;
startWithVideo = (config.audioOnly) ? !config.audioOnly : true;
autoAccept = (config.autoAccept) ? config.autoAccept : true;
platform = config.platform;
extraAgentMessage = config.extraAgentMessage;
veUrl = config.veUrl;
i18n = config.i18n;
form = config.form;
enablePrecallForced = config.hasOwnProperty('enablePrecall');
enablePrecall = config.enablePrecall;
useWebChatForm = config.useWebChatForm;
webChatFormData = (config.webChatFormData) ? config.webChatFormData : {};
if (config.callHolder) {
iframeHolder = document.getElementById(config.callHolder);
if (!iframeHolder) {
console.log('iframe holder is passing, but not found: ', config.callHolder);
}
}
customAttributes = config.customAttributes ? config.customAttributes : null;
};
const startVideoEngager = function () {
if (!interactionId) {
interactionId = getGuid();
}
if (useWebChatForm) {
initiateForm();
} else {
startWithHiddenChat();
}
};
const startCalendar = function () {
oVideoEngager.command('Calendar.generate')
.done(function (e) {
console.log(e);
})
.fail(function (e) {
console.error('Calendar failed : ', e);
});
};
const copyToClipboard = function (e) {
const copyText = document.getElementById('meetingUrl');
copyText.select();
copyText.setSelectionRange(0, 99999);
navigator.clipboard.writeText(copyText.value);
};
const createGoogleCalendarEvent = function (fullText) {
Date.prototype.addHours = function (h) {
this.setTime(this.getTime() + (h * 60 * 60 * 1000));
return this;
};
const isoToIcal = function (str) {
str = str.replace(/-/g, '');
str = str.replace(/:/g, '');
str = str.replace('.', '');
str = str.replace('00000Z', '00Z');
return str;
};
const getContentOfLineDefinition = function (definition) {
return fullText.substring(fullText.indexOf(definition)).substring(definition.length, fullText.substring(fullText.indexOf(definition)).indexOf('\r'));
};
const toIsoWithOffset = function (date) {
return new Date(date.getTime() - (date.getTimezoneOffset() * 60000)).toISOString();
};
const icalStr = getContentOfLineDefinition('DTSTART:');
const strYear = icalStr.substr(0, 4);
const strMonth = parseInt(icalStr.substr(4, 2), 10) - 1;
const strDay = icalStr.substr(6, 2);
const strHour = icalStr.substr(9, 2);
const strMin = icalStr.substr(11, 2);
const strSec = icalStr.substr(13, 2);
const oDate = new Date(strYear, strMonth, strDay, strHour, strMin, strSec);
const dates = isoToIcal(toIsoWithOffset(oDate)) + '/' + isoToIcal(toIsoWithOffset(oDate.addHours(1)));
const googleEvent = {
baseUrl: 'https://calendar.google.com/calendar/r/eventedit?',
text: getContentOfLineDefinition('SUMMARY:'),
dates: dates,
details: getContentOfLineDefinition('DESCRIPTION:') + '\n' + getContentOfLineDefinition('URL:'),
location: getContentOfLineDefinition('LOCATION:')
};
return `${googleEvent.baseUrl}text=${googleEvent.text}&dates=${googleEvent.dates}&details=${googleEvent.details}&location=${googleEvent.location}`;
};
this.initExtension = function ($, CXBus, Common) {
console.log('on init extension VideoEngager');
init();
oVideoEngager = CXBus.registerPlugin('VideoEngager');
oVideoEngager.publish('ready');
oVideoEngager.registerCommand('startVideo', function (e) {
// videochat channel is selected
console.log('startVideoTriggered');
startWithVideo = true;
startVideoEngager();
});
oVideoEngager.registerCommand('startAudio', function (e) {
startWithVideo = false;
startVideoEngager();
});
oVideoEngager.registerCommand('startVideoEngager', function (e) {
startVideoEngager();
});
oVideoEngager.before("WebChat.open", function(oData) {
console.log('before webchat open');
oData.userData = oData.userData ? oData.userData : {};
if (!oData.userData.veVisitorId) {
oData.userData.veVisitorId = null;
}
return oData;
});
oVideoEngager.registerCommand('startWebChat', function (e) {
oVideoEngager.command('WebChat.open', {
userData: {veVisitorId:null}
});
});
oVideoEngager.registerCommand('endCall', function (e) {
oVideoEngager.command('WebChatService.endChat');
closeIframeOrPopup();
});
oVideoEngager.registerCommand('startCalendar', function (e) {
startCalendar();
});
oVideoEngager.subscribe('Callback.opened', function (e) {
document.querySelector('#cx_form_callback_tennantId').value = window._genesys.widgets.videoengager.tenantId;
// authenticate
let date = new Date();
document.querySelector('#cx_form_callback_phone_number').value = '';
oVideoEngager.subscribe('CallbackService.scheduleError', function (e) {
if (e.data.responseJSON && e.data.responseJSON.body) {
document.querySelector('#cx_callback_information').innerText = e.data.responseJSON.body.message;
}
});
oVideoEngager.subscribe('CallbackService.scheduled', function (e) {
document.querySelector('#cx-callback-result').innerText = 'Video Call Scheduled';
if (document.querySelector('#cx-callback-result-number').innerText === '') {
document.querySelector('#cx-callback-result-desc').remove();
}
if (document.querySelector('#cx-callback-result-desc')) {
document.querySelector('#cx-callback-result-desc').innerText = 'Your Phone Number';
}
$('.cx-buttons-default.cx-callback-done').remove();
$('div.cx-footer.cx-callback-scheduled').remove();
$('#visitorid').remove();
$('#icsDataDownload').remove();
$('#downloadLinkHolder').remove();
$('#shareURL').remove();
$('#visitorInfo').remove();
$('.cx-confirmation-wrapper').css('height', 'auto');
$('.cx-callback').css('width', '400px');
if (e && e.data && e.data.videoengager && e.data.videoengager) {
const scheduleDate = new Date(e.data.videoengager.date);
let htmlText = '