1var _urlParams = new URLSearchParams(window.location.search); 2 3var isArabicLang = window._spPageContextInfo ? window._spPageContextInfo.currentLanguage === 1025 ? true : false : false; 4if (_urlParams.get('language') == 'ar') { 5 isArabicLang = true; 6} 7if (_urlParams.get('language') == 'ar') { 8 isArabicLang = true; 9} 10function initNiceChat() { 11 (async function (i, s, o, r, g, v, a, m) { 12 // Define a promise to handle the script loading 13 function loadScript(src) { 14 return new Promise((resolve, reject) => { 15 a = s.createElement(o); 16 m = s.getElementsByTagName(o)[0]; 17 a.async = 1; 18 a.src = src; 19 a.onload = resolve; // Resolve the promise when the script is loaded 20 a.onerror = reject; // Reject the promise if there's an error loading the script 21 m.parentNode.insertBefore(a, m); 22 }); 23 } 24 25 // Load the script asynchronously 26 g = v ? g + "?v=" + v : g; 27 i["BrandEmbassy"] = r; 28 i[r] = 29 i[r] || 30 function () { 31 (i[r].q = i[r].q || []).push(arguments); 32 }; 33 i[r].l = +new Date(); 34 35 try { 36 await loadScript(g + "?" + Math.round(Date.now() / 1000 / 3600)); 37 if (isArabicLang) { 38 // Arabic Chat 39 brandembassy('init', 1012, 'chat_068bd3b4-ab84-40ce-a6b8-9658e65a9143'); 40 // Set Arabic Translation 41 brandembassy('setTranslations', arabicTranslation); 42 // Set Arabic Translation for [Email Address] 43 brandembassy('setTranslation', 'Email Address', 'Ø§ÙØ¨Ø±Ùد Ø§ÙØ§ÙÙØªØ±ÙÙÙ'); 44 // Set Arabic Translation for [Contact Number] 45 brandembassy('setTranslation', 'Contact Number', 'رÙÙ Ø§ÙØªÙاصÙ'); 46 brandembassy('setPositionX', 'left'); 47 brandembassy('sendFirstMessageAutomatically', '/begin_conversation'); 48 49 } else { 50 // English Chat 51 brandembassy("init", 1012, "chat_49579cea-2efd-411d-b531-5f31d688346d"); 52 brandembassy('setPositionX', 'right'); 53 brandembassy('sendFirstMessageAutomatically', '/begin_conversation'); 54 55 } 56 handelingUserCookies(brandembassy) 57 // handelMobileAppParams like [fullName, emailAddress, contactNumber] 58 handelMobileAppParams(brandembassy); 59 // Check If this is a mobile app channel to [Hide Header, Hide Popups, Open Chat Window, Set Full Display] 60 handelMobileChannel(brandembassy); 61 // Set the Customer Name, Email, and Phone 62 brandembassy("setCustomCss", liveChatStyle(getColorTheme(), checkDarkMode())); 63 64 // set horizontal and vertical offset 65 brandembassy('setOffsetX', '30'); // default = 20 66 brandembassy('setOffsetY', '20'); // default = 20 67 68 handelStyleIcon(); 69 } catch (error) { 70 // Error occurred while loading the script 71 console.error("Error loading BrandEmbassy script:", error); 72 } 73 })( 74 window, 75 document, 76 "script", 77 "brandembassy", 78 "https://livechat-static-de-ae1.nicecxone.com/4/chat.js" 79 ); 80} 81 82//====================================================================== 83// Live Chat Style 84//====================================================================== 85const liveChatStyle = (primaryColor = "#99742d", isDark = false) => { 86 return ` 87 :root { 88 --primary-color: ${primaryColor}; 89 --light-color: ${isDark ? "#18181b" : "#fff"} ; 90 --body-bg: ${isDark ? "#18181b" : "#fff"}; 91 --text-color: ${isDark ? "#fff" : "#333"}; 92 --disabled-color: ${isDark ? "#303030" : "#e4e4e4c4"}; 93 --chat-icon: "\\e006" 94 } 95 96 #be-app{ 97 display: flex; 98 align-items: center; 99 justify-content: center; 100 width: 60px; 101 } 102 103 #be-messenger { 104 background-color: transparent !important; 105 106 } 107 108 body:has(#be-messenger) { 109 background-color: transparent !important; 110 } 111 112 #be-messenger [data-selector="CUSTOMER_MESSAGE_BUBBLE"] { 113 background-color: var(--primary-color, #99742d) !important; 114 color: #fff !important; 115 border-radius: 0.5rem !important; 116 } 117 118 #be-messenger [data-selector="AGENT_MESSAGE_BUBBLE"] { 119 background-color: var(--light-color, #f5f5f5) !important; 120 color: var(--text-color, #333) !important; 121 border-radius: 0.5rem !important; 122 } 123 124 [data-selector="INPUT"] input { 125 border-radius: 0.5rem !important; 126 } 127 128 [data-selector="INPUT"] [class^="Input_Field__"] { 129 // border: 0 !important; 130 } 131 132 [data-selector="WINDOW"] * { 133 font-family: "Droid Arabic Kufi", "roboto", sans-serif !important; 134 ${isArabicLang ? "direction: rtl !important;" : ""} 135 } 136 [data-selector="INPUT"] [class^="FormField_Label__"] { 137 ${isArabicLang ? "text-align: right !important;" : ""} 138 } 139
140 [data-selector="QUICK_REPLIES"] button { 141 background-color: var(--primary-color, #99742d) !important; 142 padding: 0.5rem 1rem; 143 border-radius: 0.5rem; 144 height: 36px; 145 } 146 147 [data-selector="QUICK_REPLIES"] button:hover { 148 background-color: var(--primary-color, #99742d) !important; 149 } 150 151 #be-messenger .Widget_isOffline__adNnJ .Widget_Status__a9tYr { 152 background-color: #ff0000 !important; 153 } 154 155 #be-messenger [data-selector="PRIMARY_BUTTON"] { 156 padding-inline: 0rem !important; 157 background-color: transparent !important; 158 } 159 160 #be-messenger [data-selector="DELIMITER"] [class^="Transcript_Main"], 161 #be-messenger [data-selector="DELIMITER"] [class^="Delimiter_Label__"] { 162 background-color: var(--body-bg) !important; 163 } 164 165 #be-messenger [data-selector="PRIMARY_BUTTON"] [class^="Button_Button"] { 166 padding-inline: 0rem !important; 167 background-color: var(--primary-color, #99742d) !important; 168 color: #fff !important; 169 border-radius: 0.5rem !important; 170 } 171 172 #be-messenger [class^="EndSession_Footer__"] { 173 display: flex; 174 gap: 1rem; 175 flex-direction: column; 176 } 177 178 #be-messenger [class^="EndSession_Footer__"] [class^="EndSession_Button__"] { 179 padding: 0.5rem !important; 180 display: flex !important; 181 align-items: center; 182 justify-content: center; 183 gap: 0.5rem; 184 color: var(--text-color) !important; 185 } 186 187 #be-messenger [class^="EndSession_Footer__"] [class^="EndSession_Button__"] svg { 188 fill: var(--text-color) !important; 189 } 190 191 /* Form Fields */ 192 [data-selector="PRECONTACT_SURVEY"] [class^="StartSession_Overflow__"] { 193 display: flex !important; 194 flex-direction: column !important; 195 gap: 1rem !important; 196 } 197 198 #be-messenger .Widget_Status__a9tYr { 199 background-color: #00ff00 !important; 200 } 201 202 #be-messenger .BrandLabel_BrandLabel__KxS\+Y { 203 display: none !important; 204 } 205 206 #be-messenger .ScrollbarsCustom-Content [data-selector="INPUT"] { 207 margin: 0 !important; 208 } 209 210 /* Chat Header */ 211 #be-messenger [data-selector="HEADER"] { 212 background-color: var(--primary-color, #99742d) !important; 213 color: #fff !important; 214 border-radius: 0.5rem 0.5rem 0 0 !important; 215 } 216 217 #be-messenger [data-selector="HEADER"] button { 218 color: #fff !important; 219 background-color: transparent !important; 220 } 221 222 /* Button Chat */ 223 #be-messenger [data-selector="WIDGET"] { 224 border: 1px solid var(--primary-color) !important; 225 background-color: var(--body-bg) !important; 226 width: 55px !important; 227 height: 55px !important; 228 text-decoration: none !important; 229 border-radius: 50% !important; 230 transition: all 0.25s ease-in-out; 231 display: flex; 232 flex-direction: column; 233 align-items: center; 234 justify-content: center; 235 box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25) !important; 236 color: var(--primary-color) !important; 237 opacity: 1; 238 z-index: 998; 239 margin-bottom: 0 !important; 240 background-color: var(--body-bg) !important; 241 display: flex; 242 align-items: center; 243 justify-content: center; 244 margin: auto; 245 } 246 247 #be-messenger [data-selector="WIDGET"][class*="Widget_isOffline"] { 248 border: 2px solid #ff0000 !important; 249 } 250 251 #be-messenger [class^="Window_Body__"], 252 #be-messenger [class^="Window_Body__"]>div { 253 background-color: var(--body-bg) !important; 254 } 255 256 #be-messenger [class*="Widget_isOffline"] [class^="Widget_Icon__"] { 257 color: #ff0000 !important; 258 opacity: 1; 259 } 260 #be-messenger [class*="Widget_isOffline"] [class^="Widget_Icon__"] [class="be-icon-envelope"]:before{ 261 content: var(--chat-icon) !important 262 } 263 264 #be-messenger.be-messenger-minimized { 265 position: relative; 266 display: flex; 267 align-items: center; 268 justify-content: center; 269 width: 60px; 270 height: 60px; 271 } 272 #be-frame.be-frame-default { 273 width: 320px; 274 height: 465px; 275 } 276 /* Chat Window */ 277 #be-messenger { 278 border-radius: 0.25rem !important; 279 } 280 281 #be-messenger [data-selector="WIDGET"]:hover { 282 box-shadow: 0 0 5px 0 rgba(0, 0, 0, 0.3); 283 background-color: var(--primary-color, #99742d) !important; 284 color: #fff !important; 285 } 286 287 #be-messenger [class^="Widget_Icon__"] { 288 margin: 0 !important; 289 font-size: 1.5rem !important; 290 transition: all 0.3s ease; 291 } 292 293 #be-messenger [data-selector="WIDGET"]:hover [class^="Widget_Icon__"] { 294 transform: rotate(10deg); 295 } 296 297 [data-selector="ACTIVITY_BAR"] [class^="WaitingQueueModal_"] { 298 background-color: var(--disabled-color) !important; 299 } 300 301 #be-messenger [class^="Widget_Status__"], 302 #be-messenger [class^="Widget_Text__"] { 303 display: none !important; 304 } 305 306 #be-messenger [data-selector="UPLOAD_ATTACHMENT_BUTTON"], 307 #be-messenger [class^="ReplyBox_ReplyBox__"], 308 #be-messenger [class^="SystemMessage_HistoryItemContent__"], 309 #be-messenger [class^="Input_Field__"], 310 #be-messenger select, 311 #be-messenger textarea, 312 #be-messenger input { 313 background-color: var(--body-bg) !important; 314 color: var(--text-color) !important; 315 } 316 317 #be-messenger [class^="StartSession_StartSession__"], 318 #be-messenger [class^="StartSession_Footer__"] { 319 background-color: var(--body-bg) !important; 320 } 321 322 #be-messenger [class^="ConnectionStatus_ConnectionStatus__"] .mui-vubbuv, 323 [class^="ConnectionStatus_ConnectionStatus"] { 324 background-color: var(--body-bg) !important; 325 color: var(--text-color) !important; 326 } 327 328 .be-messenger-minimized { 329 background-color: transparent !important; 330 } 331 `; 332}; 333 334//====================================================================== 335// Get the color theme from the URL 336//====================================================================== 337const getColorTheme = () => { 338 var themeColor = $("body").attr("data-color"); 339 // themeColor
340 if (_urlParams.get("themeColor")) { 341 themeColor = _urlParams.get("themeColor").toLowerCase(); 342 // remove hash if exists from the color 343 themeColor = themeColor.replace("#", ""); 344 } 345 346 const colorsMap = { 347 red: "#d83731", 348 green: "#3f8e50", 349 blue: "#00abeb", 350 primary: "#99742d", 351 }; 352 353 switch (themeColor) { 354 case "gold-theme": 355 return colorsMap.primary; 356 case "gold": 357 return colorsMap.primary; 358 case "red-theme": 359 return colorsMap.red; 360 case "red": 361 return colorsMap.red; 362 case "green-theme": 363 return colorsMap.green; 364 case "green": 365 return colorsMap.green; 366 case "blue-theme": 367 return colorsMap.blue; 368 case "blue": 369 return colorsMap.blue; 370 case "99742d": 371 return colorsMap.primary; 372 case "d83731": 373 return colorsMap.red; 374 case "3f8e50": 375 return colorsMap.green; 376 case "00abeb": 377 return colorsMap.blue; 378 default: 379 return colorsMap.primary; 380 } 381}; 382 383//====================================================================== 384// Check if the dark mode is enabled 385//====================================================================== 386const checkDarkMode = () => { 387 const isDarkMode = document.body.classList.contains("dark-mode") ? true : false; 388 // brightness param dark/light 389 const isBrightnessDark = _urlParams.get("brightness") == "dark" ? true : false; 390 391 const isDarkEnable = localStorage.getItem("dark-mode") == "true" || localStorage.getItem("darkMode") == "true" ? true : false; 392 393 394 return isDarkMode || isBrightnessDark || isDarkEnable; 395}; 396 397//====================================================================== 398// Set Arabic Translation for the chat window 399//====================================================================== 400const arabicTranslation = { 401 allAgentsForQueueAreBusy: 'Ø¬Ù ÙØ¹ اÙÙÙÙØ§Ø¡ اÙ٠خصصÙ٠٠شغÙÙÙÙ ØØ§ÙÙÙØ§. ÙÙØ§Ù {queue, plural, one {شخص ÙØ§ØØ¯} other {أشخاص}} {queue, number} ÙØ¨ÙÙ ÙÙ Ø§ÙØ·Ø§Ø¨Ùر.', 402 beginButton: 'ابدأ Ø§ÙØ¯Ø±Ø¯Ø´Ø©!', 403 cancel: 'Ø¥ÙØºØ§Ø¡', 404 caseNumber: 'رÙÙ Ø§ÙØ·Ùب #{caseNumber}', 405 change: 'تغÙÙØ±', 406 chattedWith: 'ÙÙØ¯ Ø£Ø¬Ø±ÙØª ÙÙØªÙ Ù ØØ§Ø¯Ø«Ø© ٠ع', 407 commonErrorText: 'ØØ¯Ø« خطأ ØºÙØ± ٠تÙÙØ¹. Ø§ÙØ±Ø¬Ø§Ø¡ اÙÙ ØØ§ÙÙØ© ٠رة Ø£Ø®Ø±Ù ÙØ§ØÙÙØ§.', 408 done: 'ت٠', 409 dragAndDropDropzone: 'Ø§Ø³ØØ¨ ÙØ£ÙÙØª اÙÙ ÙÙØ§Øª ÙÙØ§ ÙØ¥Ø±Ø³Ø§ÙÙØ§', 410 dragAndDropDropzoneRejected: 'تعذر تØÙ Ù٠اÙÙ ÙÙ :(', 411 EmailLabel: 'Ø§ÙØ¨Ø±Ùد Ø§ÙØ¥ÙÙØªØ±ÙÙÙ', 412 endChat: 'Ø¥ÙÙØ§Ø¡ Ø§ÙØ¯Ø±Ø¯Ø´Ø©', 413 endChatTitle: 'ÙÙ Ø£ÙØª Ù ØªØ£ÙØ¯ Ø£ÙÙ ØªØ±ÙØ¯ Ø¥ÙÙØ§Ø¡ ÙØ°Ù اÙÙ ØØ§Ø¯Ø«Ø©Ø', 414 endGame: 'Ø¥ÙÙØ§Ø¡ اÙÙØ¹Ø¨Ø©', 415 ending: 'جار٠إÙÙØ§Ø¡ Ø§ÙØ¯Ø±Ø¯Ø´Ø©...', 416 fileSendingFailed: 'ÙØ´Ù إرسا٠اÙÙ ÙÙ', 417 getTranscriptDescription: 'Ø¥Ø±Ø³Ø§Ù ÙØ³Ø®Ø© Ù Ù ÙØ°Ù اÙÙ ØØ§Ø¯Ø«Ø© Ø¥ÙÙ Ø§ÙØ¹ÙÙØ§Ù Ø§ÙØ¨Ø±Ùد Ø§ÙØ¥ÙÙØªØ±ÙÙÙ Ø§ÙØªØ§ÙÙ:', 418 getTranscriptLink: 'Ø§ØØµÙ عÙÙ ÙØ³Ø®Ø© اÙÙ ØØ§Ø¯Ø«Ø©', 419 invalidToken: 'ر٠ز ØºÙØ± ØµØ§ÙØ', 420 ipAddressBlocked: 'ØªÙ ØØ¸Ø± عÙÙØ§Ù اÙÙ IP', 421 loading: 'Ø¬Ø§Ø±Ù Ø§ÙØªØÙ ÙÙ ...', 422 loadPreviousButton: 'تØÙ Ù٠اÙÙ ØØ§Ø¯Ø«Ø§Øª Ø§ÙØ³Ø§Ø¨ÙØ©', 423 messageLabel: 'Ø±Ø³Ø§ÙØ©', 424 networkErrorText: 'ÙØ§Ù ÙÙØ§Ù خطأ ÙÙ Ø§ÙØ´Ø¨ÙØ©. Ø§ÙØ±Ø¬Ø§Ø¡ اÙÙ ØØ§ÙÙØ© ٠رة أخرÙ.', 425 newCase: 'Ø·ÙØ¨ Ø¬Ø¯ÙØ¯Ø©', 426 noAgentOnlineForQueue: 'ÙØ§ ÙÙØ¬Ø¯ ÙÙÙÙ Ù ØªØ§Ø Ù٠اÙÙÙØª Ø§ÙØØ§ÙÙ.', 427 offline: 'ØºÙØ± ٠تصÙ', 428 offlineFormDesc: 'ÙØÙ ØºÙØ± ٠تاØÙÙ Ù٠اÙÙÙØª Ø§ÙØØ§ÙÙ', 429 offlineFormSuccessMsgHead: 'Ø´ÙØ±Ùا ÙÙ!', 430 offlineFormSuccessMsgSub: 'ØªÙ Ø¥Ø±Ø³Ø§Ù Ø¨Ø±ÙØ¯Ù Ø§ÙØ¥ÙÙØªØ±ÙÙÙ Ø¨ÙØ¬Ø§Ø. Ø³ÙØ¹Ùد Ø¥ÙÙÙ ÙØ±ÙØ¨ÙØ§.', 431 online: '٠تصÙ', 432 onlineFormText: 'ÙØ¨Ø¯Ø¡ Ø§ÙØ¯Ø±Ø¯Ø´Ø©Ø ÙØ±Ø¬Ù Ø¥Ø®Ø¨Ø§Ø±ÙØ§ باس٠Ù. Ø³ÙØ¨Ø¯Ø£ Ø£ØØ¯ ÙÙÙØ§Ø¦Ùا Ù٠٠ساعدت٠عÙ٠اÙÙÙØ±.', 433 pleaseSelect: 'ÙØ±Ø¬Ù Ø§ÙØ§Ø®ØªÙار...', 434 poweredBy: 'Ù Ø´ØºÙ Ø¨ÙØ§Ø³Ø·Ø©', 435 preparingSession: 'Ø¬Ø§Ø±Ù ØªØØ¶Ùر Ø§ÙØ¬Ùسة...', 436 replyBoxPlaceholder: 'Ø§ÙØªØ¨ ÙÙØ§Ø ÙØ§Ø¶ØºØ· ENTER ÙÙØ¥Ø±Ø³Ø§Ù', 437 retry: 'أعد اÙÙ ØØ§ÙÙØ©',
438 sendFileTextSize: 'Ø§ÙØ±Ø¬Ø§Ø¡ Ø±ÙØ¹ Ù ÙÙØ§Øª أصغر Ù Ù {filesize}', 439 sendFileTextSupportedFormat: 'ØªÙØ³ÙÙØ§Øª ٠دعÙÙ Ø©.', 440 sendFileTextSupportedFormatDesc: 'ØµÙØ±Ø ÙÙØ¯ÙÙÙØ§ØªØ {fileFormats}', 441 sendMessageButton: 'Ø¥Ø±Ø³Ø§Ù Ø±Ø³Ø§ÙØ©', 442 sendNewEmail: 'Ø¥Ø±Ø³Ø§Ù Ø¨Ø±ÙØ¯ Ø¥ÙÙØªØ±ÙÙÙ Ø¬Ø¯ÙØ¯', 443 sendTranscript: 'إرسا٠اÙÙØ³Ø®Ø©', 444 snakeWaiting: 'Ø£ÙØª {queue} ÙÙ .', 445 startChatInPopup: 'اسأÙÙØ§!', 446 startNewChat: 'ابدأ دردشة Ø¬Ø¯ÙØ¯Ø©', 447 statusReconnecting: 'ÙØØ§ÙÙ Ø§ÙØ§ØªØµØ§Ùâ¦', 448 surveySuccesfullySent: 'Ø´ÙØ±Ùا عÙÙ Ù ÙØ§ØØ¸Ø§ØªÙ!', 449 systemChattingWith: 'Ø£ÙØª Ø§ÙØ¢Ù تدردش ٠ع {name}', 450 topic: 'اÙÙ ÙØ¶Ùع', 451 transciptSentFailed: 'ÙØ´Ù Ø§ÙØ¥Ø±Ø³Ø§Ù.', 452 transciptSuccesfullySent: 'ت٠إرسا٠اÙÙØ³Ø®Ø© Ø¨ÙØ¬Ø§Ø!', 453 tryAgainButton: 'ØØ§Ù٠٠رة أخرÙ', 454 unexpectedError: 'خطأ ØºÙØ± ٠تÙÙØ¹.', 455 validationInvalidEmail: 'عÙÙØ§Ù Ø§ÙØ¨Ø±Ùد Ø§ÙØ¥ÙÙØªØ±ÙÙÙ ØºÙØ± ØµØ§ÙØ', 456 validationMandatory: 'ÙØ°Ø§ Ø§ÙØÙÙ Ø¥ÙØ²Ø§Ù Ù', 457 validationShorterName: 'Ø§ÙØ±Ø¬Ø§Ø¡ Ø§Ø³ØªØ®Ø¯Ø§Ù Ø§Ø³Ù Ø£ÙØµØ±', 458 validationShortMessage: 'Ø±Ø³Ø§ÙØªÙ ÙØµÙرة Ø¬Ø¯ÙØ§', 459 waiting: 'Ø§ÙØªØ¸Ø§Ø±...', 460 waitingDescription: 'Ø³ÙØªØØ¯Ø« Ù Ø¹Ù Ø£ØØ¯ ÙÙÙØ§Ø¦Ùا ÙØ±ÙØ¨ÙØ§.', 461 waitingFooter: 'اضغط عÙÙ <spacebar> ÙØªÙØµÙØ± ÙÙØª Ø§ÙØ§Ùتظار.', 462 waitingForAgent: 'ÙÙ Ø§ÙØªØ¸Ø§Ø± اÙÙÙÙÙ...', 463 waitingInQueue: 'ÙÙ Ø§ÙØªØ¸Ø§Ø± اÙÙÙÙÙ. Ø£ÙØª {queue} ÙÙ Ø§ÙØ·Ø§Ø¨Ùر.', 464 yourNameLabel: 'اس٠Ù', 465 turnOffAudioNotification:'Ø¥ÙÙØ§Ù Ø§ÙØ¥Ø´Ø¹Ø§Ø± Ø§ÙØµÙتÙ', 466 turnOnAudioNotification:'تشغÙÙ Ø§ÙØ¥Ø´Ø¹Ø§Ø± Ø§ÙØµÙتÙ', 467 chattedWith:'Ù٠ت Ø¨Ø§ÙØ¯Ø±Ø¯Ø´Ø© ٠ع {name}', 468 chattedWithAgent:'Ù٠ت Ø¨Ø§ÙØ¯Ø±Ø¯Ø´Ø© ٠ع', 469 backToConversations:'Ø±Ø¬ÙØ¹ Ø¥Ù٠اÙÙ ØØ§Ø¯Ø«Ø©', 470 agentHasJoinedTheChat:'{agentName} ÙØ§Ù Ø¨Ø§ÙØ§Ùض٠ا٠ÙÙÙ ØØ§Ø¯Ø«Ø© ', 471 youAreBeingTransferred:'ت٠تØÙÙÙ Ù ØØ§Ø¯Ø«ØªÙØ Ø§ÙØ±Ø¬Ø§Ø¡ Ø§ÙØ§Ùتظار.', 472 agentHasLeftTheChat:"{agentName} ÙØ§Ù Ø¨Ø§ÙØ®Ø±Ùج ٠٠اÙÙ ØØ§Ø¯Ø«Ø©" 473}; 474 475//====================================================================== 476// Get the value of a cookie by its name from the document 477//====================================================================== 478// 1) Get Cookies 479function getCookie(cookieName) { 480 const cookies = document.cookie.split(";"); 481 482 for (let i = 0; i < cookies.length; i++) { 483 const cookie = cookies[i].trim(); 484 485 // Check if the cookie starts with the desired name 486 if (cookie.startsWith(cookieName + "=")) { 487 // Return the value of the cookie 488 return cookie.substring(cookieName.length + 1); 489 } 490 } 491 492 // Return null if the cookie is not found 493 return null; 494} 495 496// 2) Handeling User Cookies 497const handelingUserCookies = (brandembassy) => { 498 try { 499 500 const userInfoCookieValue = getCookie("userInfo"); 501 502 // Check if the user info cookie exists 503 if (userInfoCookieValue) { 504 // Split the string into key-value pairs 505 const keyValuePairs = userInfoCookieValue.split("&"); 506 507 // Initialize an object to store the extracted values 508 const extractedValues = {}; 509 510 // Loop through key-value pairs and extract the values 511 keyValuePairs.forEach((pair) => { 512 const [key, value] = pair.split("="); 513 extractedValues[key] = value; 514 }); 515 516 // Access the extracted values 517 const userEmail = extractedValues["UserEmail"]; 518 const userPhone = extractedValues["UserPhone"]; 519 const userFullName = extractedValues["UserFullName"]; 520 521 brandembassy("setCustomerName", userFullName); 522 brandembassy("setCustomField", "emailaddress", userEmail); 523 brandembassy("setCustomField", "contactnumber", userPhone); 524 } else { 525 // brandembassy("autoStartSession"); 526 } 527 } catch (e) { 528 console.log('error in handelingUserCookies', e); 529 } 530} 531 532//====================================================================== 533// Set the user information in the chat window 534//====================================================================== 535const handelMobileAppParams = (brandembassy) => { 536 try { 537
538 if (_urlParams.has("fullName") || _urlParams.has("emailAddress") || _urlParams.has("contactNumber")) { 539 // Get the user name 540 const _userEmail = _urlParams.get("emailAddress") || ""; 541 // Get the user email 542 const _userFullName = _urlParams.get("fullName") || ""; 543 // Get the user phone 544 const _userPhone = _urlParams.get("contactNumber") || ""; 545 if (_userFullName) { 546 brandembassy("setCustomerName", _userFullName); 547 } 548 549 if (_userEmail) { 550 brandembassy("setCustomField", "emailaddress", _userEmail); 551 } 552 553 if (_userPhone) { 554 brandembassy("setCustomField", "contactnumber", _userPhone); 555 } 556 557 if (_userFullName && _userEmail) { 558 brandembassy("autoStartSession"); 559 brandembassy("sendFirstMessageAutomatically", "/begin_conversation"); 560 } 561 console.log(_userFullName, _userEmail, _userPhone); 562 } else if ((localStorage.getItem('userFullName') && localStorage.getItem('userFullName') != 'null') || (localStorage.getItem('userEmail') && localStorage.getItem('userEmail') != 'null') || (localStorage.getItem('userPhone') && localStorage.getItem('userPhone') != 'null')) { 563 // Get the user name 564 const _userEmail = localStorage.getItem('userEmail') || ""; 565 // Get the user email 566 const _userFullName = localStorage.getItem('userFullName') || ""; 567 // Get the user phone 568 const _userPhone = localStorage.getItem('userPhone') || ""; 569 if (_userFullName) { 570 brandembassy("setCustomerName", _userFullName); 571 } 572 573 if (_userEmail) { 574 brandembassy("setCustomField", "emailaddress", _userEmail); 575 } 576 577 if (_userPhone) { 578 brandembassy("setCustomField", "contactnumber", _userPhone); 579 } 580 581 if (_userFullName && _userEmail) { 582 brandembassy("autoStartSession"); 583 brandembassy("sendFirstMessageAutomatically", "/begin_conversation"); 584 } 585 console.log(_userFullName, _userEmail, _userPhone); 586 } else { 587 console.log('No Params Found to Set User Info in Chat Window') 588 } 589 } catch (e) { 590 console.log('error in handelMobileAppParams', e); 591 } 592} 593 594//====================================================================== 595// Check If this is a mobile app channel to [Hide Header, Hide Popups, Open Chat Window, Set Full Display] 596//====================================================================== 597const handelMobileChannel = (brandembassy) => { 598 try { 599 if (_urlParams.get("channel") == "2" || (localStorage.getItem('sourceChannel') && localStorage.getItem('sourceChannel') == 'mobileWebView') && window.location.pathname.includes('Live-Chat.aspx')) { 600 brandembassy("setFullDisplay"); 601 brandembassy("openChatWindow"); 602 brandembassy("hidePopups"); 603 brandembassy("hideHeader"); 604 console.log('Mobile App Channel Detected') 605 } 606 } catch (e) { 607 console.log('error in handelMobileChannel', e); 608 } 609} 610 611const handelStyleIcon = () => { 612 // Create a <style> element 613 var styleElement = document.createElement('style'); 614 615 // Define your CSS rules 616 var css = ` 617 .ms-SPZone .loading-spinner, 618 /* .ms-webpart-zone .loading-spinner, */ 619 .ms-core-form .loading-spinner { 620 display: none !important; 621 } 622 623 #be-frame.be-frame-minimized { 624 width: 60px !important; 625 padding-inline: 0 !important; 626 height: 60px !important; 627 bottom: 16px !important; 628 } 629 #be-frame { 630 } 631 632 633 @media (max-width: 768px) { 634 #be-frame { 635 left: 12px !important; 636 right: auto !important; 637 } 638 639 // .be-frame-minimized { 640 // width: 100px !important; 641 // } 642 } 643 644 .rtl #be-frame { 645 left: 30px !important; 646 } 647 648 .rtl .be-frame-minimized { 649 width: 140px !important; 650 } 651 652 .loading-spinner { 653 position: fixed; 654 top: 50%; 655 left: 50%; 656 transform: translate(-50%, -50%); 657 z-index: 99999999; 658 display: flex; 659 align-items: center; 660 justify-content: center; 661 background-color: var(--body-bg); 662 width: 100%; 663 height: 100%; 664 } 665 666 .chatbot-icon-btn { 667 visibility: hidden !important; 668 max-height: 20px !important; 669 } 670 `; 671 672 // Set the style content 673 styleElement.innerHTML = css; 674 675 // Append the <style> element to the <head> 676 document.head.appendChild(styleElement); 677 678} 679 680initNiceChat() 681window.liveChatStyle = liveChatStyle; 682window.getColorTheme = getColorTheme; 683window.checkDarkMode = checkDarkMode;
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.