www.enterice.com
Open in
urlscan Pro
52.7.88.170
Public Scan
Submitted URL: https://www.enterice.com/chat/JS/buttonHandler.js
Effective URL: https://www.enterice.com/chat/static/JS/buttonHandler.js
Submission: On March 26 via api from US — Scanned from DE
Effective URL: https://www.enterice.com/chat/static/JS/buttonHandler.js
Submission: On March 26 via api from US — Scanned from DE
Form analysis
0 forms found in the DOMText Content
var TrackerId = ''; var chatUrl = ''; var EtechButtonHandler = function () { //private variables var AjaxURL; var IsChatBotAccess = 0; var IsChatwithChatbot = 0; // var chatURL; //Change scope to global var btnID; var subcampaignID; var returnDataByAjax = ''; var BootUpTimer; var LoadDynamicDiv = 0; var OperatorRecallTimer; var OperatorStatus; var buttonControlID; var functionName; var obj; var objName; var isPolling = 0; var OrgID; var jQueryICE; //use this var for comet var LastRecId = -1; var IsOnline; var CometData; var CometURL; var MapPath; var CurrentURL = document.location.href; var CurrentTitle = document.title; var IsEmbedded; var IsChatUiLoad = 0; var fname; var DynamicNameSpace; var API_URL = ''; var Resource_URL = ''; var GlobalSessionID = ''; var templateId = ''; var SkillName = 'SkillName'; var LocationURL = window.location.href; //private methods var newWin = ''; function GetCookie(name) { var re = new RegExp(name + "=([^;]+)"); var value = re.exec(document.cookie); return (value != null) ? unescape(value[1]) : null; } function SetCookie(name, value) { var argv = SetCookie.arguments; var argc = SetCookie.arguments.length; var expires = (argc > 2) ? argv[2] : null; var path = (argc > 3) ? argv[3] : null; var domain = (argc > 4) ? argv[4] : null; //var secure = (argc > 5) ? argv[5] : false; var secure = (window.location.protocol == 'https:') ? true : false; document.cookie = name + '=' + escape(value) + ((expires == null) ? '' : ('; expires=' + expires.toGMTString())) + ((path == null) ? '' : ('; path=' + path)) + ((domain == null) ? '' : ('; domain=' + domain)) + ((secure == true) ? '; secure' : ''); } function getCookieVal(offset) { var endstr = document.cookie.indexOf(';', offset); if (endstr == -1) endstr = document.cookie.length; return unescape(document.cookie.substring(offset, endstr)); } function DeleteCookie(name) { var exp = new Date(); exp.setTime(exp.getTime() - 1); var cval = GetCookie(name); document.cookie = name + '=' + cval + '; expires=' + exp.toGMTString(); } function GetCookieExp(Expval) { var expDays = Expval var exp = new Date(); exp.setTime(exp.getTime() + (expDays * 24 * 60 * 60 * 1000)); return exp; } function pad2(number, length) { var str = '' + number; while (str.length < length) { str = '0' + str; } return str; } function AjaxCall(AjaxURL, Idata) { $.ajax({ dataType: 'json', data: Idata, url: AjaxURL }); } //check IP is requesting resource is blocked or not function IsIpBlocked(skillID) { //do not track traffic analysis if (window.jQuery === undefined) { $(":button").click(function () { window.onbeforeunload = UnPopIt; }); $(":submit").click(function () { window.onbeforeunload = UnPopIt }); $(":radio").click(function () { window.onbeforeunload = UnPopIt }); } else { jQuery(":button").click(function () { window.onbeforeunload = UnPopIt; }); jQuery(":submit").click(function () { window.onbeforeunload = UnPopIt }); jQuery(":radio").click(function () { window.onbeforeunload = UnPopIt }); } obj.subcampaignID = skillID; obj.SetGUID(); } function GoForwardAfterSttingTrackID(retvalue) { fname = InitialFun; DynamicNameSpace = objName; IsCustomerIPBlocked(obj.subcampaignID); } //Open chat window on button click function NewWindow(IsOperatorOnline) { if (newWin.closed != false) { newWin = window.open('', 'MyNewChatWindow', 'width=550,height=600,resizable=yes,fullscreen=no'); if (IsOperatorOnline == "1") { SavePrechatExitSurveyEvents(1, obj.subcampaignID, IsOperatorOnline, '', 0); } else if (IsOperatorOnline == "0") { NewWindowChild(IsOperatorOnline); } else if (IsOperatorOnline == "-1") { NewWindowChild(IsOperatorOnline); } } else { newWin.focus(); } } function OpenEmbeddedPopup(MinimizedButtonText, IsOperatorOnline, MinimizedButtonType) { try { if (GetCookie("IsActiveChat") != "1") { if (IsOperatorOnline == "1") { SavePrechatExitSurveyEvents(1, obj.subcampaignID, IsOperatorOnline, MinimizedButtonText, MinimizedButtonType); } else if (IsOperatorOnline == "0") { EmbeddedWindowChild(IsOperatorOnline, MinimizedButtonText, MinimizedButtonType); } else if (IsOperatorOnline == "-1") { EmbeddedWindowChild(IsOperatorOnline, MinimizedButtonText, MinimizedButtonType); } } else { EmbeddedWindowChild(IsOperatorOnline, MinimizedButtonText, MinimizedButtonType); } } catch (e) { alert(e.message); } } function NewWindowChild(IsOperatorOnline) { try { let ivrVal= LocationURL.split('?')[1]!=undefined ? LocationURL.split('?')[1]:""; let visitorUrl= LocationURL.split('?')[0]!=undefined ? LocationURL.split('?')[0]:""; var newLocationURL = ''; encodeSessionInfo(); if(visitorUrl!=''){ newLocationURL = visitorUrl; } if(ivrVal!=''){ newWin.location = chatURL + "&chatReferenceID=" + GetCookie("chatReferenceID") + "&locationURL=" + newLocationURL + "&" + ivrVal; } else{ newWin.location = chatURL + "&chatReferenceID=" + GetCookie("chatReferenceID") + "&locationURL=" + LocationURL; } } catch (e) { } } function EmbeddedWindowChild(IsOperatorOnline, MinimizedButtonText, MinimizedButtonType) { if (GetCookie("IsActiveChat") != "1") { if (IsChatwithChatbot == 0) { if ($("#chatbotpopupchat").length == 0 && window.document.getElementById('chatbotpopupchat') == null) { if (IsChatBotAccess && IsOperatorOnline == "1") { var Stylelink = window.document.createElement('link'); Stylelink.rel = 'stylesheet'; Stylelink.type = 'text/css'; Stylelink.href = Resource_URL + '/css/ChatBotcss/style.css'; window.document.head.appendChild(Stylelink); var Stylelink1 = window.document.createElement('link'); Stylelink1.rel = 'stylesheet'; Stylelink1.type = 'text/css'; Stylelink1.href = Resource_URL + '/css/ChatBotcss/materialize.css'; window.document.head.appendChild(Stylelink1); var Stylelink2 = window.document.createElement('link'); Stylelink2.rel = 'stylesheet'; Stylelink2.type = 'text/css'; Stylelink2.href = Resource_URL + '/css/ChatBotcss/jquery-ui.css'; window.document.head.appendChild(Stylelink2); var CustomerScript = window.document.createElement('script'); CustomerScript.type = 'text/javascript'; CustomerScript.src = Resource_URL + '/js/ClientButton.js'; window.document.head.appendChild(CustomerScript); if (GetCookie('IsGAActive') == true || GetCookie('IsGAActive') == "true") { setTimeout( function () { SendEvents(SkillName, "_Button", "Button Click"); }, 5000); } $("#Hlink").hide(); var divTag = window.document.createElement("div"); divTag.setAttribute('id', 'chatbotpopupchat'); divTag.setAttribute('class', 'popup-box chat-popup popup-box-on'); var mytesturl = "https://dev.enterice.com/visitor/#/chatbot?Skillid=" + obj.subcampaignID + "&Guid=" + GetCookie('visitorGUID') + "&Orgid=" + obj.OrgID; var IFrame = window.document.createElement("iframe"); IFrame.setAttribute('src', mytesturl); IFrame.setAttribute('id', 'chatpopup'); IFrame.setAttribute('style', 'height: 100% !important; display: inline; border: none;'); divTag.appendChild(IFrame); window.document.body.appendChild(divTag); return false; } } } } SetCookie("ReCalling", "1", null, '/'); $("#Hlink").hide(); var IsIpad = navigator.userAgent.indexOf('iPad') > -1 ? true : false; if (GetCookie("IsActiveChat") == "1" && IsChatUiLoad != 0) { $('#popupchat').addClass('popup-box-on'); } else { $(document).ready(function () { $("#popupchat").remove(); SetCookie("IsChatbot", 0, null, '/'); var Stylelink = window.document.createElement('link'); Stylelink.rel = 'stylesheet'; Stylelink.type = 'text/css'; if (templateId == 2) { Stylelink.href = Resource_URL + '/css/NewCustomerUI/template_1.css'; } else { if (!IsIpad) Stylelink.href = Resource_URL + '/css/NewCustomerUI/EmbeddedStyle.css'; else Stylelink.href = Resource_URL + '/css/NewCustomerUI/EmbeddedStyle_Ipad.css'; } if (!IsResourcExists(2, Stylelink.href)) { window.document.head.appendChild(Stylelink); } var DragableScript = window.document.createElement('script'); DragableScript.type = 'text/javascript'; DragableScript.src = Resource_URL + '/js/dragabal.js'; if (!IsResourcExists(1, DragableScript.src)) { window.document.head.appendChild(DragableScript); } var CustomerScript = window.document.createElement('script'); CustomerScript.type = 'text/javascript'; CustomerScript.src = Resource_URL + '/js/ClientButton.js'; if (!IsResourcExists(1, CustomerScript.src)) { window.document.head.appendChild(CustomerScript); } if (GetCookie('IsGAActive') == true || GetCookie('IsGAActive') == "true") { setTimeout( function () { SendEvents(SkillName, "_Button", "Button Click"); }, 5000); } var divDragable = window.document.createElement("div"); divDragable.setAttribute('id', 'draggable'); divDragable.setAttribute('class', 'ui-widget-content'); var divTag = window.document.createElement("div"); divTag.setAttribute('id', 'popupchat'); divTag.setAttribute('class', 'popup-box chat-popup popup-box-on'); var divOverlay = window.document.createElement("div"); divOverlay.setAttribute('id', 'divOverlay'); divOverlay.setAttribute('class', 'divOverlay'); var ObjURL = chatURL.split('&') ObjURL[5] = "c=" + GetCookie('visitorGUID'); chatURL = ""; for (var u = 0; u < ObjURL.length; u++) { if (ObjURL[u].indexOf('SessionID') < 0) chatURL = chatURL + ObjURL[u] + "&"; else chatURL = chatURL + ObjURL[u]; } var IFrame = window.document.createElement("iframe"); let ivrVal= LocationURL.split('?')[1]!=undefined ? LocationURL.split('?')[1]:""; let visitorUrl= LocationURL.split('?')[0]!=undefined ? LocationURL.split('?')[0]:""; let visitorRefGuid = GetCookie('VisitorRefGuID'); var newLocationURL=''; encodeSessionInfo(); if(visitorUrl!=''){ newLocationURL = visitorUrl; } if (ivrVal != '') { IFrame.setAttribute('src', chatURL + "&IsEmbedded=1&chatReferenceID=" + GetCookie("chatReferenceID") + "&locationURL=" + newLocationURL + "&VisitorRefGuid=" + visitorRefGuid +"&" + ivrVal); } else { IFrame.setAttribute('src', chatURL + "&IsEmbedded=1&chatReferenceID=" + GetCookie("chatReferenceID") + "&locationURL=" + LocationURL + "&VisitorRefGuid=" + visitorRefGuid); } IFrame.setAttribute('id', 'chatpopup'); IFrame.setAttribute('style', 'height: 100% !important; display: inline; border: none;'); divTag.appendChild(divOverlay); divTag.appendChild(IFrame); divDragable.appendChild(divTag); window.document.body.appendChild(divDragable); var divMinimizedbtn = window.document.createElement("div"); divMinimizedbtn.setAttribute('id', 'minimizedButton'); divMinimizedbtn.setAttribute('class', 'popup-head'); divMinimizedbtn.setAttribute('style', 'display:none;'); var divMinimizedPopup = window.document.createElement("div"); divMinimizedPopup.setAttribute('id', 'phead'); divMinimizedPopup.setAttribute('class', 'popup-head-left pull-left'); divMinimizedbtn.appendChild(divMinimizedPopup); window.document.body.appendChild(divMinimizedbtn); if (MinimizedButtonType == 0) { $("#minimizedButton").addClass("bar-button"); if (MinimizedButtonText != null && MinimizedButtonText != '') $("#phead", window.document).append($('<span />').html('<image class="minizedbarimage" src=' + Resource_URL + 'Images/comment_bar.png>' + MinimizedButtonText)); else $("#phead", window.document).append($('<span />').html('<image class="minizedbarimage" src=' + Resource_URL + 'Images/comment_bar.png>ACTIVE CHAT')); } else { $("#minimizedButton").addClass("FencyMinimize"); $("#phead").addClass("FencyMinimizeHead"); $("#phead", window.document).append($('<span><image class="minizedbuttonimage" src=' + Resource_URL + 'Images/comment.png></span>')); } var frame = document.getElementById('chatpopup'); $("#phead", window.document).click(function () { $('#draggable', window.document).show(); $('#popupchat', window.document).removeClass('popup-box-min'); $('#minimizedButton', window.document).hide(); $("#phead span span").remove(); frame.contentWindow.postMessage('Maximize', '*'); SetCookie("IsWindowMinimized", 0); }); if (window.document.getElementById('chatbotpopupchat') != null) { window.document.getElementById('chatbotpopupchat').style.cssText = 'display:none !important'; } if(GetCookie("IsWindowMinimized") == 1){ MinimizePopup(); } }) } } function MinimizePopup() { $('#popupchat').addClass('popup-box-min'); //Iframe Div $('#draggable').hide(); //Iframe $('#minimizedButton').hide(); $("#phead span span").remove(); SetCookie("IsWindowMinimized", 1); } function BootupScript(url, objref, objbyname) { clearTimeout(OperatorRecallTimer); if(window.location.href.indexOf('be.synxis') > -1 && window.location.href.split('IsActiveChat').length > 1 && GetCookie("IsActiveChat") != 1 && GetCookie("IsActiveChat") != '1'){ SetCookie('IsActiveChat', window.location.href.split('IsActiveChat')[1].split('&')[0].replace("=",'')) } OrgID = objref.OrgID; API_URL = url.indexOf('localhost') > -1 ? 'http://' + url.split('/')[0] + '/ICEInternalAPI/Api' : 'https://' + url.split('/')[0] + '/ICEInternalAPI/Api'; Resource_URL = url.indexOf('localhost') > -1 ? 'http://' + url : 'https://' + url; MapPath = url; obj = objref; objName = objbyname; AjaxURL = (('http:' != document.location.protocol) ? 'https://' + url + 'RuleEngineAdmin/AjaxHandler.aspx?format=json&jsoncallback=?' : 'http://' + url + 'RuleEngineAdmin/AjaxHandler.aspx?format=json&jsoncallback=?'); CometURL = (('http:' != document.location.protocol) ? 'https://' + url + 'RuleEngineAdmin/comet/CometAsyncHandler.ashx?format=json&jsoncallback=?' : 'http://' + url + 'RuleEngineAdmin/comet/CometAsyncHandler.ashx?format=json&jsoncallback=?'); if (window.jQuery === undefined || parseInt(window.jQuery.fn.jquery.split('.').join('')) < 172) { EtechButtonHandlerls('http:' != document.location.protocol ? 'https://' + url + 'js/jquery-1.7.2.min.js' : 'http://' + url + 'js/jquery-1.7.2.min.js', function () { fname = CheckOrgChatActive; DynamicNameSpace = objName; GetToken(objref.OrgID); }); } else { fname = CheckOrgChatActive; DynamicNameSpace = objName; GetToken(objref.OrgID); } if (!navigator.cookieEnabled) alert('Please enable browser cookies and refresh the page for ICE chat.'); } function CheckOrgChatActive(IsOrgChatActive) { try { if (IsOrgChatActive) { var AVisitorID = GetCookie('visitorGUID'); if (AVisitorID != null) { if (obj.btnID == 142 && AVisitorID == '2b73130e-3d79-45da-87ab-9d2f12a5f0c5') { AGetCookieExp('visitorGUID'); } else if (obj.btnID == 294 && AVisitorID == 'e5028da5-0f48-427a-bf4e-6bf1064b3248') { AGetCookieExp('visitorGUID'); } } fname = IsIpBlocked; DynamicNameSpace = objName; getSkillID(obj.btnID); } } catch (e) { alert(e.message); } } function SetGUID() { var visitorID = GetCookie('visitorGUID'); if (visitorID == null) { if (returnDataByAjax != '') { visitorID = returnDataByAjax; var exp = GetCookieExp(30); var path = '/'; SetCookie('visitorGUID', returnDataByAjax, exp, path); obj.SetGUID(); } else { fname = SetGUID; GenerateNewGuid("SetGUID"); } } else { var TrackID = GetCookie('TrackID'); if (TrackID == null) { fname = GetTrackID; DynamicNameSpace = objName; GenerateNewTrackID(); } else { GoForwardAfterSttingTrackID('1'); } } } function GetTrackID() { var path = '/'; SetCookie('TrackID', returnDataByAjax, null, path); obj.SetGUID(); } function AGetCookieExp(Expval) { var date = new Date(); document.cookie = Expval + '=;expires=' + date.getTime() + (10 * 1000) + ';'; } function InitialFun() { if (returnDataByAjax[0] !== "true" && returnDataByAjax[0] !== "1" ) { chatURL = returnDataByAjax[1]; var visitorID = GetCookie('visitorGUID'); if (visitorID != null) { if (visitorID == '2b73130e-3d79-45da-87ab-9d2f12a5f0c5' || visitorID == '' || visitorID == 'e5028da5-0f48-427a-bf4e-6bf1064b3248') { chatURL = chatURL + '&chattype=b'; chatURL = chatURL + '&SessionID=' + (obj.hostSiteSessionID == undefined ? '' : obj.hostSiteSessionID); fname = CreateDynamicControl; DynamicNameSpace = objName; GetButtonData(obj.btnID, obj.subcampaignID, obj.OrgID, 'CreateDynamicControl'); } else { chatURL = chatURL + '&chattype=b'; chatURL = chatURL + '&c=' + visitorID; chatURL = chatURL + '&SessionID=' + (obj.hostSiteSessionID == undefined ? '' : obj.hostSiteSessionID); fname = CreateDynamicControl; DynamicNameSpace = objName; GetButtonData(obj.btnID, obj.subcampaignID, obj.OrgID, 'CreateDynamicControl'); } } else { var exp = GetCookieExp(30); var dt = new Date(); var Tdate = dt.getFullYear() + '-' + pad2(dt.getMonth() + 1) + '-' + pad2(dt.getDate()) + ' ' + pad2(dt.getHours()) + ':' + pad2(dt.getMinutes()) + ':' + pad2(dt.getSeconds()); var expiry = exp.getFullYear() + '-' + pad2(exp.getMonth() + 1) + '-' + pad2(exp.getDate()) + ' ' + pad2(exp.getHours()) + ':' + pad2(exp.getMinutes()) + ':' + pad2(exp.getSeconds()); var Domain = document.domain; var SubDomain = document.domain; fname = GenerateNewGUIDAndSetCookie; DynamicNameSpace = objName; GenerateNewGuid("GenerateNewGUIDAndSetCookie"); } } } function GenerateNewGUIDAndSetCookie(Rdata) { var visitorID = Rdata[0]; var exp = GetCookieExp(30); var path = '/'; SetCookie('visitorGUID', returnDataByAjax, exp, path); chatURL = chatURL + '&c=' + visitorID; fname = CreateDynamicControl; DynamicNameSpace = objName; GetButtonData(obj.btnID, obj.subcampaignID, obj.OrgID, 'CreateDynamicControl'); } function CreateButton(Rdata) { // check mobile device or desktop var isMobile = /iPhone|Android/i.test(navigator.userAgent); //end if($("#PopupDivBack").length !== 0 || $("#popupchat").length !== 0) { return false; } else { if (GetCookie("IsChatbot") == 1 && $("#chatbotpopupchat").length == 0) { if (window.document.getElementById('chatbotpopupchat') != null && window.document.getElementById('chatbotpopupchat').innerHTML.length > 0) { } else { $("#Hlink").hide(); OpenEmbeddedPopup(Rdata[7], Rdata[2], Rdata[9]); return false; } } if (Rdata != "1" && Rdata != "0" && Rdata[0] != false) { SetCookie("IsEmbedded", Rdata[6], null, '/'); if (GetCookie('ReCalling') != 1 && (GetCookie("IsActiveChat") != 1 || GetCookie('IsEmbedded') != 1) && GetCookie("IsActiveChatBot") != "1") { IsChatUiLoad = 1; $(document).ready(function () { if ((Rdata[5] == "true" || Rdata[5] == true) && Rdata[2] != "-1") { var divTag = document.getElementById('' + obj.buttonControlID + ''); if (typeof (divTag) != "undefined" || divTag == null) { document.getElementById('' + obj.buttonControlID + '').style.display = "none"; } } else { var IsOperatorOnline = Rdata[2]; var IsButtonHide = Rdata[8]; var ImageSrc = Rdata[0]; if (ImageSrc == "button") { //for css option ImageSrc = Rdata[4]; } if (isMobile && Rdata[10] != '' && Rdata[10] !=null) { ImageSrc = Rdata[10]; } var divTag = document.getElementById('' + obj.buttonControlID + ''); $('#divButtonRendering').remove(); if (typeof (divTag) == "undefined" || divTag == null) { divTag = document.createElement("div"); divTag.setAttribute('id', 'divButtonRendering'); } else { $('#' + '' + obj.buttonControlID + '').empty(); } divTag.style.display = "block"; var HypLink = document.createElement("a"); HypLink.setAttribute('id', 'Hlink'); HypLink.setAttribute('href', 'JavaScript:void(0)'); HypLink.setAttribute('title', '' + Rdata[1] + ''); if (!isMobile && Rdata[4] != "" && Rdata[4] != undefined && Rdata[4] != null) { var divCustomCSS = document.createElement("div"); divCustomCSS.setAttribute('id', 'imgH'); var replaceStr = Rdata[4].replace("###ImageSrc###", ImageSrc); divCustomCSS.innerHTML = replaceStr; HypLink.appendChild(divCustomCSS); } else if (isMobile && ((Rdata[4] != "" && Rdata[4] != undefined && Rdata[4] != null) || (Rdata[11] != "" && Rdata[11] != undefined && Rdata[11] != null))) { var divCustomCSS = document.createElement("div"); divCustomCSS.setAttribute('id', 'imgH'); //for online and local option if (Rdata[0] != "button") { if (Rdata[11] != "" && Rdata[11] != undefined && Rdata[11] != null) { var replaceStr = Rdata[11].replace("###ImageSrc###", ImageSrc); } else { var replaceStr = Rdata[4].replace("###ImageSrc###", ImageSrc); } } else { //for css option var replaceStr = ImageSrc; } divCustomCSS.innerHTML = replaceStr; HypLink.appendChild(divCustomCSS); } else { var Img = document.createElement("img"); Img.setAttribute('id', 'imgH'); Img.setAttribute('src', '' + ImageSrc + ''); Img.setAttribute('alt', '' + Rdata[1] + ''); HypLink.appendChild(Img); } divTag.appendChild(HypLink); if ($('#Hlink').find('img').length) { $('#Hlink').find('img').attr('alt', Rdata[1]); } if (IsOperatorOnline != "1" && IsButtonHide) { document.getElementById('' + obj.buttonControlID + '').style.display = "none"; } if (divTag.id.toString().indexOf('divButtonRendering') != -1) { document.body.appendChild(divTag) } // SetCookie("IsEmbedded", Rdata[6], null, '/'); IsEmbedded = GetCookie("IsEmbedded"); if (navigator.userAgent.match(/msie [6]/i)) { HypLink.onclick = function () { if (window.document.getElementById('chatbotpopupchat') == null && IsChatBotAccess == 1 && (GetCookie("IsPrechatSurvey") == undefined || GetCookie("IsPrechatSurvey") == 2) && IsEmbedded == 1 && IsOperatorOnline == "1") { window.document.getElementById('Hlink').style.display = "none"; SetCookie("IsPrechatSurvey", "0", null, '/'); OpenEmbeddedPopup(Rdata[7], IsOperatorOnline, Rdata[9]); } else if (IsEmbedded == 0) { NewWindow(IsOperatorOnline) } else { OpenEmbeddedPopup(Rdata[7], IsOperatorOnline, Rdata[9]); } } } else { HypLink.onclick = function () { if (window.document.getElementById('chatbotpopupchat') == null && IsChatBotAccess == 1 && (GetCookie("IsPrechatSurvey") == undefined || GetCookie("IsPrechatSurvey") == 2) && IsEmbedded == 1 && IsOperatorOnline == "1") { window.document.getElementById('Hlink').style.display = "none"; SetCookie("IsPrechatSurvey", "0", null, '/'); OpenEmbeddedPopup(Rdata[7], IsOperatorOnline, Rdata[9]); } else if (IsEmbedded == 0) { NewWindow(IsOperatorOnline) } else { OpenEmbeddedPopup(Rdata[7], IsOperatorOnline, Rdata[9]); } } } } }); } else if (IsChatUiLoad == 0 && GetCookie("IsActiveChat") == "1" && GetCookie("IsEmbedded") == "1") { var IsOperatorOnline = Rdata[2]; var ImageSrc = Rdata[0]; if (ImageSrc == "button") { //for css option ImageSrc = Rdata[4]; } if (isMobile && Rdata[10] != '' && Rdata[10] !=null) { ImageSrc = Rdata[10]; } var divTag = document.getElementById('' + obj.buttonControlID + ''); $('#divButtonRendering').remove(); if (typeof (divTag) == "undefined" || divTag == null) { divTag = document.createElement("div"); divTag.setAttribute('id', 'divButtonRendering'); } else { $('#' + '' + obj.buttonControlID + '').empty(); } divTag.style.display = "block"; var HypLink = document.createElement("a"); HypLink.setAttribute('id', 'Hlink'); HypLink.setAttribute('href', 'JavaScript:void(0)'); HypLink.setAttribute('title', '' + Rdata[1] + ''); if (!isMobile && Rdata[4] != "" && Rdata[4] != undefined && Rdata[4]!=null) { var divCustomCSS = document.createElement("div"); divCustomCSS.setAttribute('id', 'imgH'); var replaceStr = Rdata[4].replace("###ImageSrc###", ImageSrc); divCustomCSS.innerHTML = replaceStr; HypLink.appendChild(divCustomCSS); } else if (isMobile && ((Rdata[4] != "" && Rdata[4] != undefined && Rdata[4] != null) || (Rdata[11] != "" && Rdata[11] != undefined && Rdata[11] != null))) { var divCustomCSS = document.createElement("div"); divCustomCSS.setAttribute('id', 'imgH'); //for online and local option if (Rdata[0] != "button") { if (Rdata[11] != "" && Rdata[11] != undefined && Rdata[11] != null) { var replaceStr = Rdata[11].replace("###ImageSrc###", ImageSrc); } else { var replaceStr = Rdata[4].replace("###ImageSrc###", ImageSrc); } } else { //for css option var replaceStr = ImageSrc; } divCustomCSS.innerHTML = replaceStr; HypLink.appendChild(divCustomCSS); } else { var Img = document.createElement("img"); Img.setAttribute('id', 'imgH'); Img.setAttribute('src', '' + ImageSrc + ''); Img.setAttribute('alt', '' + Rdata[1] + ''); HypLink.appendChild(Img); } divTag.appendChild(HypLink) if (divTag.id.toString().indexOf('divButtonRendering') != -1) { document.body.appendChild(divTag) } HypLink.onclick = function () { OpenEmbeddedPopup(Rdata[7], IsOperatorOnline, Rdata[9]); } HypLink.click(); IsChatUiLoad = 1; } else if (IsChatUiLoad == 0 && GetCookie("IsActiveChatBot") == "1" && GetCookie("IsEmbedded") == "1") { var IsOperatorOnline = Rdata[2]; var ImageSrc = Rdata[0]; if (ImageSrc == "button") { //for css option ImageSrc = Rdata[4]; } if (isMobile && Rdata[10] != '' && Rdata[10] !=null) { ImageSrc = Rdata[10]; } var divTag = document.getElementById('' + obj.buttonControlID + ''); $('#divButtonRendering').remove(); if (typeof (divTag) == "undefined" || divTag == null) { divTag = document.createElement("div"); divTag.setAttribute('id', 'divButtonRendering'); } else { $('#' + '' + obj.buttonControlID + '').empty(); } divTag.style.display = "block"; var HypLink = document.createElement("a"); HypLink.setAttribute('id', 'Hlink'); HypLink.setAttribute('href', '#'); HypLink.setAttribute('title', '' + Rdata[1] + ''); if (!isMobile && Rdata[4] != "" && Rdata[4] != undefined && Rdata[4] != null) { var divCustomCSS = document.createElement("div"); divCustomCSS.setAttribute('id', 'imgH'); var replaceStr = Rdata[4].replace("###ImageSrc###", ImageSrc); divCustomCSS.innerHTML = replaceStr; HypLink.appendChild(divCustomCSS); } else if (isMobile && ((Rdata[4] != "" && Rdata[4] != undefined && Rdata[4] != null) || (Rdata[11] != "" && Rdata[11] != undefined && Rdata[11] != null))) { var divCustomCSS = document.createElement("div"); divCustomCSS.setAttribute('id', 'imgH'); //for online and local option if (Rdata[0] != "button") { if (Rdata[11] != "" && Rdata[11] != undefined && Rdata[11] != null) { var replaceStr = Rdata[11].replace("###ImageSrc###", ImageSrc); } else { var replaceStr = Rdata[4].replace("###ImageSrc###", ImageSrc); } } else { //for css option var replaceStr = ImageSrc; } divCustomCSS.innerHTML = replaceStr; HypLink.appendChild(divCustomCSS); } else { var Img = document.createElement("img"); Img.setAttribute('id', 'imgH'); Img.setAttribute('src', '' + ImageSrc + ''); Img.setAttribute('alt', '' + Rdata[1] + ''); HypLink.appendChild(Img); } divTag.appendChild(HypLink) if (divTag.id.toString().indexOf('divButtonRendering') != -1) { document.body.appendChild(divTag) } HypLink.onclick = function () { OpenEmbeddedPopup(Rdata[7], IsOperatorOnline, Rdata[9]); } HypLink.click(); IsChatUiLoad = 1; } else if (IsChatUiLoad == 0 && GetCookie("IsActiveChat") != 1 && GetCookie("IsEmbedded") == "1") { SetCookie("ReCalling", "0", null, '/'); } } if (GetCookie("IsChatbot") == 1) { window.document.getElementById('Hlink').style.display = "none"; } } } //callback function function ForwardCall(data) { if (data == 'LONG') { setTimeout( function () { AjaxCall(CometURL, obj.CometData); }, 1); } if (data == 'NEWDATAISAVAILABLE') { obj.CallForDynamicButtonByComet(); } } //call back function function CheckResponse(data, fname) { if (data != 'undefined' && data != null) { returnDataByAjax = data; fname(data); } else { fname(); } } //callback fuction function CallForDynamicButtonByComet() { fname = CreateButton; DynamicNameSpace = objName; GetButtonData(obj.btnID, obj.subcampaignID, obj.OrgID, 'CreateButton'); } function RecallOperator(data, fname) { try { obj.CheckResponse(data, fname); // if (OperatorRecallTimer) { clearTimeout(OperatorRecallTimer); } /* if (OrgID == 167) { var CookieName = 'visitorGUID'; var visitorID = GetCookie(CookieName); fname = CallForDynamicButton; DynamicNameSpace = objName; } */ // else { clearTimeout(OperatorRecallTimer); if(document.getElementsByTagName('head')[0].outerHTML.indexOf('buttonHandler.js') > -1){ OperatorRecallTimer = setTimeout(function () { var CookieName = 'visitorGUID'; var visitorID = GetCookie(CookieName); fname = CallForDynamicButton; DynamicNameSpace = objName; IsOperatorAvailableCall(obj.subcampaignID); }, 9000000); } // } } catch (e) { } } function IsOperatorAvailable() { var CookieName = 'visitorGUID'; var visitorID = GetCookie(CookieName); fname = CallForDynamicButton; DynamicNameSpace = objName; IsOperatorAvailableCall(obj.subcampaignID); } function CreateDynamicControl(Rdata) { if (LoadDynamicDiv == 0) { LoadDynamicDiv = 1; obj.CreateButton(Rdata); IsOperatorAvailable(); } else { var IsOperatorOnline = Rdata[2]; if (Rdata[5] == "true") { obj.CreateButton(Rdata); } else { obj.CreateButton(Rdata); } } } function CallForDynamicButton() { fname = CreateDynamicControl; DynamicNameSpace = objName; GetButtonData(obj.btnID, obj.subcampaignID, obj.OrgID, 'CreateDynamicControl'); } window.onbeforeunload = function () { if (GetCookie("IsActiveChat") != 1) { SetCookie("ReCalling", "0", null, '/'); } if (typeof (jQuery) !== 'undefined') { var visitorID = GetCookie('visitorGUID'); var url = '' + AjaxURL + ''; var TASessionID = GetCookie('TrackID'); var TARefPage = document.referrer; } } function UnPopIt() { }; function logout() { var visitorID = GetCookie('visitorGUID'); CheckURL(visitorID, obj.OrgID); } function sleep(milliseconds) { var start = new Date().getTime(); for (var i = 0; i < 1e7; i++) { if ((new Date().getTime() - start) > milliseconds) { break; } } } var BrowserDetect = { init: function () { this.browser = this.searchString(this.dataBrowser) || "An unknown browser"; this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "an unknown version"; this.OS = this.searchString(this.dataOS) || "an unknown OS"; }, searchString: function (data) { for (var i = 0; i < data.length; i++) { var dataString = data[i].string; var dataProp = data[i].prop; this.versionSearchString = data[i].versionSearch || data[i].identity; if (dataString) { if (dataString.indexOf(data[i].subString) != -1) return data[i].identity; } else if (dataProp) return data[i].identity; } }, searchVersion: function (dataString) { var index = dataString.indexOf(this.versionSearchString); if (index == -1) return; return parseFloat(dataString.substring(index + this.versionSearchString.length + 1)); }, dataBrowser: [ { string: navigator.userAgent, subString: "Chrome", identity: "Chrome" }, { string: navigator.userAgent, subString: "OmniWeb", versionSearch: "OmniWeb/", identity: "OmniWeb" }, { string: navigator.vendor, subString: "Apple", identity: "Safari", versionSearch: "Version" }, { prop: window.opera, identity: "Opera", versionSearch: "Version" }, { string: navigator.vendor, subString: "iCab", identity: "iCab" }, { string: navigator.vendor, subString: "KDE", identity: "Konqueror" }, { string: navigator.userAgent, subString: "Firefox", identity: "Firefox" }, { string: navigator.vendor, subString: "Camino", identity: "Camino" }, { // for newer Netscapes (6+) string: navigator.userAgent, subString: "Netscape", identity: "Netscape" }, { string: navigator.userAgent, subString: "MSIE", identity: "Explorer", versionSearch: "MSIE" }, { string: navigator.userAgent, subString: "Gecko", identity: "Mozilla", versionSearch: "rv" }, { // for older Netscapes (4-) string: navigator.userAgent, subString: "Mozilla", identity: "Netscape", versionSearch: "Mozilla" } ], dataOS: [ { string: navigator.platform, subString: "Win", identity: "Windows" }, { string: navigator.platform, subString: "Mac", identity: "Mac" }, { string: navigator.userAgent, subString: "iPhone", identity: "iPhone/iPod" }, { string: navigator.platform, subString: "Linux", identity: "Linux" } ] }; BrowserDetect.init(); function getParameterByName(name, url) { if (!url) url = window.location.href; name = name.replace(/[\[\]]/g, "\\$&"); var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), results = regex.exec(url); if (!results) return null; if (!results[2]) return ''; return decodeURIComponent(results[2].replace(/\+/g, " ")); } function GetIsOrgChatActive(OrgID) { var Token = localStorage.getItem("_vt"); try { $.ajax({ url: API_URL + "/Visitor/IsOrganizationActive", method: "POST", type: 'POST', data: { Token: Token, OrganizationID: OrgID }, //dataType : "json", success: function (data) { fname = CheckOrgChatActive; if (data.data != undefined) CheckOrgChatActive(data.data.flag); }, error: function (jqXHR, textStatus, errorThrown) { console.log(jqXHR); console.log(textStatus); console.log(errorThrown); } }); } catch (e) { } } function GetToken(OrgID) { try { $.ajax({ url: API_URL + "/Visitor/GenerateTokenForVisitor?orgId=" + OrgID, method: "POST", type: 'POST', success: function (data) { fname = CheckOrgChatActive; localStorage.setItem("_vt", data); GetIsOrgChatActive(OrgID); }, error: function (jqXHR, textStatus, errorThrown) { console.log(jqXHR); console.log(textStatus); console.log(errorThrown); } }); } catch (e) { } } function getSkillID(ButtonID) { var Token = localStorage.getItem("_vt"); try { $.ajax({ url: API_URL + "/Visitor/GetSkillID", method: "POST", type: 'POST', data: { Token: Token, ButtonID: ButtonID }, success: function (data) { fname = IsIpBlocked; if (data.data != null && data.data.SkillID != "") { IsIpBlocked(data.data.SkillID); SkillName = data.data.SkillName; SetCookie('IsGAActive', data.data.IsGAActive) if (data.data.IsGAActive == true) { TrackerId = data.data.TrackingID; AppendGAEvents(); } } }, error: function (jqXHR, textStatus, errorThrown) { console.log(jqXHR); console.log(textStatus); console.log(errorThrown); } }); } catch (e) { } } function GetButtonData(ButtonID, SubCampaignID, OrganizationID, Source) { if(document.getElementsByTagName('head')[0].outerHTML.indexOf('buttonHandler.js') == -1){ return true; } if (GetCookie("IsActiveChat") != "1" || IsChatUiLoad == 0) { var Rdata = []; var Token = localStorage.getItem("_vt"); try { $.ajax({ url: API_URL + "/Visitor/GetButtonData", method: "POST", type: 'POST', global: false, data: { Token: Token, ButtonID: ButtonID, SubCampaignID: SubCampaignID, OrganizationID: OrganizationID }, success: function (data) { if (data != null && data.data != null) { var isMobile = /iPhone|Android/i.test(navigator.userAgent); Rdata[0] = data.data.ImagePath; Rdata[1] = data.data.ButtonHoverText; Rdata[2] = data.data.IsOperatorOnline; Rdata[3] = data.data.LastRecID; Rdata[4] = data.data.CustomeCSSText; Rdata[5] = data.data.IsQueueLimitExeed; Rdata[6] = data.data.ChatWindowType; if (isMobile) { Rdata[7] = data.data.MinimizedButtonTextMobile; } else { Rdata[7] = data.data.MinimizedButtonText; } Rdata[8] = data.data.IsHideButton; if (isMobile) { Rdata[9] = data.data.MinimizedButtonTypeMobile; } else { Rdata[9] = data.data.MinimizedButtonType; } Rdata[10] = data.data.btnMobileImage; Rdata[11] = data.data.btnMobileFloatingCss; if (Source == 'CreateDynamicControl') { fname = CreateDynamicControl; } else { fname = CreateButton; } CheckResponse(Rdata, fname); } else { var divTag = document.getElementById('' + obj.buttonControlID + ''); if (typeof (divTag) != "undefined" || divTag == null) { document.getElementById('' + obj.buttonControlID + '').style.display = "none"; } } }, error: function (jqXHR, textStatus, errorThrown) { console.log(jqXHR); console.log(textStatus); console.log(errorThrown); } }); } catch (e) { console.log(e.message); } } } function SavePrechatExitSurveyEvents(OperationCode, SkillID, IsOperatorOnline, MinimizedButtonText, MinimizedButtonType) { var Rdata = []; var Token = localStorage.getItem("_vt"); try { $.ajax({ url: API_URL + "/Visitor/SavePrechatExitSurveyEvents", method: "POST", type: 'POST', data: { Token: Token, OperationCode: OperationCode, SkillID: SkillID }, success: function (data) { SetCookie("chatReferenceID", '', null, '/'); SetCookie("chatReferenceID", data.chatReferenceID, null, '/'); if (GetCookie("IsEmbedded") == "1") { var Token = localStorage.getItem("_vt"); try { $.ajax({ url: API_URL + "/Visitor/GenerateNewGuid", method: "POST", type: 'POST', data: { Token: Token }, success: function (data) { if (data.data.Guid != "") { var exp = GetCookieExp(30); var path = '/'; var refguid = GetCookie('VisitorRefGuID'); if (refguid == null) { var visitorRefGuID = GetCookie('visitorGUID'); SetCookie('VisitorRefGuID', visitorRefGuID, exp, path); } SetCookie('visitorGUID', data.data.Guid, exp, path); } }, error: function (jqXHR, textStatus, errorThrown) { console.log(jqXHR); console.log(textStatus); console.log(errorThrown); }, complete: function () { EmbeddedWindowChild(IsOperatorOnline, MinimizedButtonText, MinimizedButtonType); } }); } catch (e) { } } else { NewWindowChild(IsOperatorOnline); } }, error: function (jqXHR, textStatus, errorThrown) { console.log(jqXHR); console.log(textStatus); console.log(errorThrown); } }); } catch (e) { } } function GenerateNewGuid(Source) { var ARdata = []; var Token = localStorage.getItem("_vt"); try { $.ajax({ url: API_URL + "/Visitor/GenerateNewGuid", method: "POST", type: 'POST', data: { Token: Token }, success: function (data) { if (data.data.Guid != "") { var ResGuid = data.data.Guid; if (Source == 'SetGUID') { fname = SetGUID; if (DynamicNameSpace == "None") { } else { fname = SetGUID; CheckResponse(ResGuid, fname); } } else { GenerateNewGUIDAndSetCookie(ARdata); } } }, error: function (jqXHR, textStatus, errorThrown) { console.log(jqXHR); console.log(textStatus); console.log(errorThrown); } }); } catch (e) { } } function GenerateNewTrackID() { var Rdata = []; var Token = localStorage.getItem("_vt"); try { $.ajax({ url: API_URL + "/Visitor/GenerateNewTrackID", method: "POST", type: 'POST', data: { Token: Token }, success: function (data) { fname = GetTrackID; if (data.data.Guid != "") { var TrackID = data.data.Guid; CheckResponse(TrackID, fname); } }, error: function (jqXHR, textStatus, errorThrown) { console.log(jqXHR); console.log(textStatus); console.log(errorThrown); } }); } catch (e) { } } function SaveVisitorHistory(Guid, Title, OrganizationID, TrackID, Browser, SessionID, URL) { var Rdata = []; var Token = localStorage.getItem("_vt"); try { $.ajax({ url: API_URL + "/Visitor/SaveVisitorHistory", method: "POST", type: 'POST', data: { Token: Token, Guid: Guid, Title: Title, OrganizationID: OrganizationID, TrackID: TrackID, Browser: Browser, SessionID: SessionID, URL: URL }, success: function (data) { fname = GoForwardAfterSttingTrackID; if (fname != null && DynamicNameSpace != null) { CheckResponse('1', fname); } }, error: function (jqXHR, textStatus, errorThrown) { console.log(jqXHR); console.log(textStatus); console.log(errorThrown); } }); } catch (e) { } } function IsCustomerIPBlocked(SubCampaignID) { var CustData = []; var Token = localStorage.getItem("_vt"); try { $.ajax({ url: API_URL + "/Visitor/IsCustomerIPBlocked", method: "POST", type: 'POST', data: { Token: Token, SubCampaignID: SubCampaignID }, success: function (data) { fname = InitialFun; if (data.data != "") { CustData[0] = data.data.IsBlocked; CustData[1] = data.data.ChatURL; templateId = data.data.templateId; CheckResponse(CustData, fname); } }, error: function (jqXHR, textStatus, errorThrown) { console.log(jqXHR); console.log(textStatus); console.log(errorThrown); } }); } catch (e) { } } function IsOperatorAvailableCall(SubCampaignID) { fname = CallForDynamicButton; RecallOperator('0', fname); } function CheckURL(Guid, OrgId) { var Token = localStorage.getItem("_vt"); try { $.ajax({ url: API_URL + "/Visitor/CheckURL", method: "POST", type: 'POST', data: { Token: Token, Guid: Guid, OrgId: OrgId }, success: function (data) { }, error: function (jqXHR, textStatus, errorThrown) { console.log(jqXHR); console.log(textStatus); console.log(errorThrown); } }); } catch (e) { } } function AppendGAEvents() { var gaUrl = Resource_URL + '/js/GA.js'; if (!IsResourcExists(1, gaUrl)) { var script = document.createElement('script'); script.type = 'text/javascript'; script.src = gaUrl; window.document.head.appendChild(script); } } function IsResourcExists(Type, Url) { // type 1 = Js, 2 = Css var FilExists = false; if (Type == 1) { FilExists = $("script[src='" + Url + "'").length > 0 ? true : false; } else if (Type == 2) { FilExists = $("link[href='" + Url + "'").length > 0 ? true : false; } return FilExists; } function encodeSessionInfo() { if (chatURL.indexOf("SessionID={") > -1) { var sindex = chatURL.indexOf("SessionID=") + 10; //Added 10 to include sessionId key var eindex = chatURL.indexOf("}") + 1; //Added 1 to include closing bracket var sessionData = chatURL.substring(sindex + 1, eindex - 1); //Way 1 chatURL = chatURL.substring(0, sindex + 1) + encodeURIComponent(sessionData) + chatURL.substring(eindex - 1, chatURL.length); } } return { CometData: CometData, btnID: btnID, OrgID: OrgID, SetGUID: SetGUID, GetTrackID: GetTrackID, GoForwardAfterSttingTrackID: GoForwardAfterSttingTrackID, IsIpBlocked: IsIpBlocked, subcampaignID: subcampaignID, buttonControlID: buttonControlID, BootupScript: BootupScript, InitialFun: InitialFun, CreateButton: CreateButton, GenerateNewGUIDAndSetCookie: GenerateNewGUIDAndSetCookie, CheckResponse: CheckResponse, CallForDynamicButtonByComet: CallForDynamicButtonByComet, ForwardCall: ForwardCall, RecallOperator: RecallOperator, CreateDynamicControl: CreateDynamicControl, CallForDynamicButton: CallForDynamicButton, CheckOrgChatActive: CheckOrgChatActive }; };