PageSourceSearch

https://www.chacos.com/on/demandware.static/Sites-chacos_us-Site/-…/lib/cyangate/chatCode2020.js

js chacos.com collected 2026-09-24 21:09:58 UTC 3,818 bytes, 93 lines download raw bytes

1/**
2 * This code relates to the Live Chat functionality and was provided by
3 *   CyanGate in a document called ChatFunctionalityMigration_Updated2020.
4 * See https://wwwinc.atlassian.net/browse/SUP-3590 for details.
5 */
6
7if(document.readyState !== 'loading') {
8  fireRepeatingFunction();
9} 
10else {
11  document.addEventListener('DOMContentLoaded',fireRepeatingFunction);
12}
13function getOS() {
14  var userAgent = window.navigator.userAgent,
15      platform = window.navigator.platform,
16      macosPlatforms = ['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'],
17      windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE'],
18      iosPlatforms = ['iPhone', 'iPad', 'iPod'],
19      os = null;
20  
21  if (macosPlatforms.indexOf(platform) !== -1) {
22      os = 'Mac OS';
23  } else if (iosPlatforms.indexOf(platform) !== -1) {
24      os = 'iOS';
25  } else if (windowsPlatforms.indexOf(platform) !== -1) {
26      os = 'Windows';
27  } else if (/Android/.test(userAgent)) {
28      os = 'Android';
29  } else if (!os && /Linux/.test(platform)) {
30      os = 'Linux';
31  }
32  
33  return os;
34}
35function fireRepeatingFunction() {
36  var osSystem = getOS();
37  if(osSystem != 'Android' && osSystem != 'iOS') {
38      setTimeout(function(){
39          var desktopChatIcon = document.querySelector(".uiButton.helpButtonEnabled");
40          if(desktopChatIcon != null || desktopChatIcon != undefined) {
41              desktopChatIcon.addEventListener("click", addRepeatingFuncEndChat);
42          }
43      }, 2000);
44      
45  }
46  else {
47      var mobileChatIcon = document.querySelector(".toggleEmbeddedChat");
48      if(mobileChatIcon != null || mobileChatIcon != undefined) {
49          mobileChatIcon.addEventListener("click", addRepeatingFuncEndChat);
50      }
51  }
52}
53function addRepeatingFuncEndChat() {
54  setTimeout(repeatingFuncEndChat, 200);
55}
56function repeatingFuncGiveFeedback() {  
57  var giveFeedback = document.querySelector(".endChatButton.postChatButton.uiButton--inverse.uiButton.embeddedServiceSidebarButton");
58  if(giveFeedback == null || giveFeedback  == 'undefined') {
59      setTimeout(repeatingFuncGiveFeedback, 100);
60  }
61  else {
62      giveFeedback.click();
63  }
64}
65function repeatingFuncCloseChat() { 
66  var closeButton = document.evaluate('//header/button[2]',document,null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
67  if(closeButton == null || closeButton  == 'undefined'){
68  }
69  else {
70      document.evaluate('//header/button[2]',document,null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.click();
71      setTimeout(repeatingFuncCloseChat, 10);
72  }
73}
74function repeatingFuncEndChat() {   
75  var confirmEndChat = document.querySelector(".dialogButton.dialog-button-0.uiButton.embeddedServiceSidebarButton");
76  var goBack = document.querySelector(".dialogButton.dialog-button-1.uiButton--inverse.uiButton.embeddedServiceSidebarButton");
77  if(confirmEndChat == null || confirmEndChat  == 'undefined' || goBack == null || goBack  == 'undefined'){
78      setTimeout(repeatingFuncEndChat, 200);
79  }
80  else {
81      var funcGiveFeedback = function() {
82          setTimeout(repeatingFuncGiveFeedback, 100);
83      };
84      var funcCloseButton = function(event) {
85          event.preventDefault();
86          debugger;
87          document.evaluate('//header/button[2]',document,null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.click();
88          setTimeout(repeatingFuncCloseChat, 10);
89      };
90      document.querySelector(".dialogButton.dialog-button-0.uiButton.embeddedServiceSidebarButton").addEventListener('click', funcGiveFeedback, false);
91      document.querySelector(".dialogButton.dialog-button-1.uiButton--inverse.uiButton.embeddedServiceSidebarButton").addEventListener('click',funcCloseButton, false);
92  }
93}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.