(function () {
window.DESKPRO_WIDGET_OPTIONS = {"language":1,"widget":{"type":"bubble","position":"right","agent_polling_timeout":null,"enabled":true,"primary_color":"#1657ea"},"button":{"size":"large","colors":{"background":"#1657ea","text":"#ffffff","border":"#4e9576"},"translations":null},"chat":{"default_values":{"fields":{"1":"","2":"","3":"","4":""}},"waiting_timeout":10,"request_user_info":true},"ticket":{"select_department":"default","default_department":1,"select_subject":"custom","default_subject":""},"helpdeskUrl":"https:\/\/chat.cmtelecom.com\/"};
window.DESKPRO_WIDGET_OPTIONS.chat.default_values.fields["4"]=window.location.href;
var realDeskProBtn,
fakeDeskProBtn,
deskproloaded = false,
cookieimg,
/* DESKPRO_WIDGET_LOADER::BEGIN*/
loadDeskproWidget = function () {
var element = document.createElement("script");
element.setAttribute("defer", "defer");
element.src = "https://chat.cmtelecom.com/dyn-assets/pub/build/widget_loader.min.js";
document.body.appendChild(element);
},
DeskproListener = function (evt) {
if (!!evt && !!evt.source && !!evt.source.$ && !!evt.source['DP_HELPDESK_URL'] && !!evt.data && !!evt.data.type && evt.data.type == 'widgetStatus') {
if (!deskproloaded) {
deskproloaded = true;
setTimeout(function () {
realDeskProBtn.querySelector('button').click();
}, 10
);
} else {
if (!!evt.data.options) {
if (evt.data.options.isOpened) {
fakeDeskProBtn.style.visibility = 'hidden';
if (evt.data.options.chatAvailable) {
cookieimg=new Image();
cookieimg.src= location.protocol + "//platformheader.cmtelecom.com/cmDpC/open?"+new Date().valueOf();
}
} else {
//cmDpC
cookieimg=new Image();
cookieimg.src= location.protocol + "//platformheader.cmtelecom.com/cmDpC?"+new Date().valueOf();
fakeDeskProBtn.style.visibility = 'visible';
fakeDeskProBtn.querySelector('button').classList.remove('clicked');
}
}
}
fakeDeskProBtn.querySelector('button').classList.remove('deskpro-loading');
}
},
openChat = function (evt) {
fakeDeskProBtn.querySelector('button').classList.add('clicked');
if (!(!!realDeskProBtn)) {
window.addEventListener('message', DeskproListener, false);
fakeDeskProBtn.querySelector('button').classList.add('deskpro-loading');
realDeskProBtn = document.createElement('div');
realDeskProBtn.setAttribute('style', 'overflow:hidden;width:0px;height:0px;position:fixed;bottom:20px; right:100vw;pointer-events:none');
realDeskProBtn.innerHTML = '';
document.body.appendChild(realDeskProBtn);
loadDeskproWidget();
} else {
realDeskProBtn.querySelector('button').click();
}
},
showDeskproButton = function () {
fakeDeskProBtn = document.createElement('div');
fakeDeskProBtn.setAttribute('class', 'deskpro-init');
fakeDeskProBtn.innerHTML = '';
document.body.appendChild(fakeDeskProBtn)
fakeDeskProBtn.querySelector('button').addEventListener('click', openChat);
/*
*/
};
showDeskproButton();
window.postMessage("deskproWidgetIsLoaded");
})()