We use cookies to enable best chat experience. Follow these directions to re-enable cookies specific to your browser type or re-open this website in a cookie-enabled browser.
We use cookies to enable best chat experience. Follow these directions to re-enable cookies specific to your browser type or re-open this website in a cookie-enabled browser.
";
console.log("Local storage not supported");
}
if (event.data.action == 'clearallsessionkeys') {
sessionStorage.clear();
}
if (event.data.action == 'clearalllocalstoragekeys') {
localStorage.clear();
}
if (event.data.action == 'cookierejectreload') {
IMIChatInit.removeStorageKeysWhenCookieRejected();
IMIChatInit.init();
}
}
} catch (e) { }
},
resize: function () {
try {
var destination = document.getElementById('iframechatwindow').contentWindow;
destination.postMessage({
action: 'resize',
width: window.outerWidth //window.innerWidth//screen.width // document.body.clientWidth
}, "*");
IMIGeneral.checkmobile();
} catch (e) { }
},
removeStorageKeysWhenCookieRejected: function () {
sessionStorage.removeItem(_wxengage_attr_key + "_imichat-reload-check");
sessionStorage.removeItem("webex_engage_data-bind");
sessionStorage.removeItem("webex_engage_data-org");
localStorage.removeItem(fingerprint + "_" + _skey + "_badgecount");
localStorage.removeItem(fingerprint + "_" + _skey + "_cardcount");
localStorage.removeItem("style_" + document.getElementById("divicw").getAttribute("data-bind") + "_" + window.location.hostname);
localStorage.removeItem("webex_engage_customer_first_seen");
localStorage.removeItem("webex_engage_customer_last_seen");
localStorage.removeItem("webex_engage_customer_last_seen_interval_id");
localStorage.removeItem("webex_engage_executed_proactive_ids");
localStorage.removeItem("fingerprint");
localStorage.removeItem("webex_engage_repeat_customer");
sessionStorage.removeItem("webex_engage_imichat_hasinitconvexist");
localStorage.removeItem("webex_engage_cookieconsent_accepted");
},
clearBrowserStorage : function() {
try {
IMIChatInit.removeStorageKeysWhenCookieRejected();
var destination = document.getElementById('iframechatwindow').contentWindow;
destination.postMessage({
action: 'clearbrowserstorage',
width: window.outerWidth //window.innerWidth//screen.width // document.body.clientWidth
}, "*");
IMIChatInit.verifyCookieConsent();
console.log("browser storage cleared");
} catch (e) { }
},
LaunchProactiveMsgManager: function (domainName, callback) {
try {
var widget_styles = localStorage.getItem("style_" + document.getElementById("divicw").getAttribute("data-bind") + "_" + window.location.hostname);
if (widget_styles == null && !JSON.parse(widget_styles).enable_proactive) {
callback();
return;
}
var body = document.getElementsByTagName('body')[0];
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = IMIChatInit.domainName() + '/js/proactive-msg-manager.js';
body.appendChild(script);
script.addEventListener('load', function (event) {
console.log('proactive manager loaded;');
var destination = document.getElementById('iframechatwindow').contentWindow;
destination.postMessage({
action: 'proactive-manager-loaded',
attrkey: document.getElementById("divicw").getAttribute("data-bind"),
host: window.location.hostname
}, "*");
callback();
});
} catch (e) {
console.log("LaunchProactiveMsgManager:" + e.msg);
}
},
processAbandonedChats: function (type) {
if (!imichatwidget.hasInitiatedChat()) {
return;
}
var browser_fingerprint = localStorage.getItem("fingerprint");
var url = IMIGeneral.profileUrl() + "livechats/" + _wxengage_attr_key + "/customers/" + browser_fingerprint + "/abandoned?host=" + window.document.URL;
url = url + "&type=" + type;
var body = JSON.stringify({
"is_reloaded": false,
"is_closechat": true
});
var headers = {
'type': 'application/json',
'fpid': hdr_bfp,
'Tid': hdr_tid,
'X-Token': hdr_xtoken
};
var blob = new Blob([body], headers);
navigator.sendBeacon(url);
},
handleAbandonedChats: function () {
// Attach the event keypress to exclude the F5 refresh
//jQuery(window).on('keydown', function (e) {
window.addEventListener('keydown', function (e) {
if (e.keyCode == 116) {
_IMIchat_IsValidNavigation = true;
}
});
window.addEventListener("beforeunload", function (e) {
sessionStorage.setItem(_wxengage_attr_key + "_imichat-reload-check", document.referrer);
console.log(document.referrer);
//sessionStorage.setItem("imi_tabid", Math.random().toString(16).slice(2));
if (_IMIchat_IsValidNavigation !== undefined && !_IMIchat_IsValidNavigation) {
IMIChatInit.processAbandonedChats("unload");
}
});
if (window.performance.navigation.type == 1) {
IMIChatInit.processAbandonedChats("load");
}
},
loadJQuery: function (domainName, callback) {
if (typeof (jQuery) !== 'undefined') {
callback();
return;
}
var body = document.getElementsByTagName('body')[0];
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = domainName + '/js/jquery.min.js';
body.appendChild(script);
script.addEventListener('load', function (event) {
callback();
});
return;
},
on: function (func_name, callback) {
if (typeof callback != 'function') {
console.error('function was expected.');
return;
}
switch (func_name) {
case 'imichat-widget:ready':
_IMIchat_callback_dic['imichat-widget:ready'] = callback;
break;
}
},
checklocalStorage: function () {
var test = 'test';
try {
localStorage.setItem(test, test);
localStorage.removeItem(test);
return true;
} catch (e) {
return false;
}
},
call_previous_chats: function () {
try {
var destination = document.getElementById('iframechatwindow').contentWindow;
msg = {
"action": "showiframe",
"host": window.location.hostname,
"chatmobile": ((navigator.userAgent.indexOf("Mobile")) != -1) ? "1" : "0"
};
destination.postMessage(msg, domainUrl);
} catch (e) {
}
},
check_clear_session_chats: function () {
if (document.referrer == sessionStorage.getItem(_wxengage_attr_key + "_imichat-reload-check")) {
return false;
}
else if (sessionStorage.getItem(_wxengage_attr_key + "_imichat-reload-check") == undefined) {
return true;
}
else {
console.log("Hey, Thanks for visiting again");
return false;
}
},
verifyCookieConsent: function () {
var isCookieConsent = typeof cookieConsentWidgetOptions === 'undefined' ? false : true;
if (isCookieConsent != undefined && isCookieConsent != null && isCookieConsent && localStorage.getItem("webex_engage_cookieconsent_accepted") != "1") {
try {
var body = document.getElementsByTagName('body')[0];
var script = document.currentScript || (function () {
var scripts = document.getElementsByTagName('script');
return scripts[scripts.length - 1];
})();
var generalscript = document.createElement('script');
generalscript.src = IMIChatInit.domainName() + "/js/imichatgeneral.js";
generalscript.type = 'text/javascript';
body.appendChild(generalscript);
generalscript.addEventListener('load', function (event) {
document.getElementById("divicw").innerHTML = "" +
"" +
"" +
"" +
"
We use cookies to enable best chat experience. Follow these directions to re-enable cookies specific to your browser type or re-open this website in a cookie-enabled browser.
";
console.log("Local storage not supported");
}
}
}
};
}();
IMIChatInit.verifyCookieConsent();
var imichatwidget = {
// get hasInitiatedConversation() {
// if (sessionStorage.getItem("webex_engage_imichat_hasinitconvexist") == null)
// return false;
// if (sessionStorage.getItem("webex_engage_imichat_hasinitconvexist") == "1") {
// return true;
// } else {
// return false;
// }
// },
hasInitiatedChat: function () {
if (sessionStorage.getItem("webex_engage_imichat_hasinitconvexist") == null)
return false;
if (sessionStorage.getItem("webex_engage_imichat_hasinitconvexist") == "1") {
return true;
} else {
return false;
}
},
show: function () {
//$("#divicw").show();return;
document.getElementById("divicw").style.display = 'block';
},
hide: function () {
// $("#divicw").hide();return;
document.getElementById("divicw").style.display = 'none';
},
/* test:function()
{
if(sessionStorage.getItem("webex_engage_imichat_hasinitconvexist")==null)
return false;
if(sessionStorage.getItem("webex_engage_imichat_hasinitconvexist")=="1")
{
return true;
}
else
{
return false;
}
},*/
maximizeWindow: function () {
IMIChatInit.chatswitchicon(1);
IMIChatInit.resize();
IMIChatInit.call_previous_chats();
return;
},
minimizeWindow: function () {
return IMIChatInit.chatswitchicon(0);
},
init: function (jsondata, callback) {
if (typeof callback != 'function') {
console.error('function was expected.');
return;
}
var destination = document.getElementById('iframechatwindow').contentWindow;
destination.postMessage({
action: 'imichat_custom_chat_fields',
data: jsondata,
type: 'add'
}, '*');
_IMIchat_callback_dic['imichat-widget:custom_chat_fields_init'] = callback;
},
update: function (jsondata, callback) {
if (typeof callback != 'function') {
console.error('function was expected.');
return;
}
var destination = document.getElementById('iframechatwindow').contentWindow;
destination.postMessage({
action: 'imichat_custom_chat_fields',
data: jsondata,
type: 'update'
}, '*');
_IMIchat_callback_dic['imichat-widget:custom_chat_fields_update'] = callback;
},
on: function (func_name, callback) {
if (typeof callback != 'function') {
console.error('function was expected.');
return;
}
switch (func_name) {
case 'imichat-widget:ready':
_IMIchat_callback_dic['imichat-widget:ready'] = callback;
break;
}
},
clearBrowserStorage: function () {
IMIChatInit.clearBrowserStorage();
}
};
/*
function imichatWidgetLoaded(){imi
imichatwidget.maximizeWindow();
}*/