var _urlParams = new URLSearchParams(window.location.search);
var isArabicLang = window._spPageContextInfo ? window._spPageContextInfo.currentLanguage === 1025 ? true : false : false;
if (_urlParams.get('language') == 'ar') {
isArabicLang = true;
}
if (_urlParams.get('language') == 'ar') {
isArabicLang = true;
}
function initNiceChat() {
(function (n, u) {
window.CXoneDfo = n,
window[n] = window[n] || function () { (window[n].q = window[n].q || []).push(arguments) }, window[n].u = u,
e = document.createElement("script"), e.type = "module", e.src = u + "?" + Math.round(Date.now() / 1e3 / 3600),
document.head.appendChild(e)
})('cxone', 'https://web-modules-de-ae1.nicecxone.com/loader/1/loader.js');
try {
if (isArabicLang) {
// Arabic Chat
cxone('init', '1012');
cxone('chat', 'init', 1012, 'chat_aa799d70-14d9-49ed-883d-0c375fe87ebc');
//cxone('chat','setLocale', 'locale');
cxone('chat', 'setTranslations', arabicTranslation);
cxone('chat', 'setTranslation', 'Email Address', 'البريد الالكتروني');
// Set Arabic Translation for [Contact Number]
cxone('chat', 'setTranslation', 'Contact Number', 'رقم التواصل');
cxone('sendFirstMessageAutomatically', '/begin_conversation');
cxone('setCustomerName', '');
cxone('setCustomField', 'emailaddress', '');
cxone('setCustomField', 'contactnumber', '');
} else {
// English Chat
cxone('init', '1012');
cxone('chat', 'init', 1012, 'chat_f457f67a-f8e9-4298-858d-4353cc126482');
cxone('sendFirstMessageAutomatically', '/begin_conversation');
cxone('setCustomerName', '');
cxone('setCustomField', 'emailaddress', '');
cxone('setCustomField', 'contactnumber', '');
}
handelingUserCookies(cxone)
// handelMobileAppParams like [fullName, emailAddress, contactNumber]
handelMobileAppParams(cxone);
// Check If this is a mobile app channel to [Hide Header, Hide Popups, Open Chat Window, Set Full Display]
handelMobileChannel(cxone);
// Set the Customer Name, Email, and Phone
cxone('chat', 'setCustomCss', liveChatStyle(getColorTheme(), checkDarkMode()));
// set horizontal and vertical offset
cxone('setOffsetX', '30'); // default = 20
cxone('setOffsetY', '20'); // default = 20
handelStyleIcon();
} catch (error) {
// Error occurred while loading the script
console.error("Error loading BrandEmbassy script:", error);
}
}
//======================================================================
// Live Chat Style
//======================================================================
const liveChatStyle = (primaryColor = "#99742d", isDark = false) => {
return `
:root {
--primary-color: ${primaryColor};
--light-color: ${isDark ? "#18181b" : "#fff"} ;
--body-bg: ${isDark ? "#18181b" : "#fff"};
--text-color: ${isDark ? "#fff" : "#333"};
--disabled-color: ${isDark ? "#303030" : "#e4e4e4c4"};
--chat-icon: "\\e006"
}
#be-app{
display: flex;
align-items: center;
justify-content: center;
width: 60px;
}
.rtl [data-selector="WINDOW"] {direction: rtl !important;}
.rtl [data-selector="WIDGET"] {direction: rtl !important;}
.rtl [data-selector="CONTENT"] {direction: rtl !important;}
.rtl [data-selector="HEADER"] {direction: rtl !important;}
.rtl [data-selector="INPUT"] {direction: rtl !important;}
.rtl [class="FormField_Label__h-gnc"] {display: block !important; text-align: right !important}
.rtl [data-selector="MESSENGER"] {direction: rtl !important;}
.rtl [data-selector="POPUP"] {direction: rtl !important;}
.rtl [data-selector="REPLY_BOX"] {direction: rtl !important;}
.rtl [data-selector="SEND_BUTTON"] {direction: rtl !important;}
.rtl [data-selector="TEXTAREA"] {direction: rtl !important;}
.rtl [data-selector="TEXT_BUTTON"] {direction: rtl !important;}
.rtl [data-selector="ACTIVITY_BAR"] {direction: rtl !important;}
.rtl [data-selector="INPUT"] {direction: rtl !important;}
#be-messenger {
background-color: transparent !important;
}
body:has(#be-messenger) {
background-color: transparent !important;
}
#be-messenger [data-selector="CUSTOMER_MESSAGE_BUBBLE"] {
background-color: var(--primary-color, #99742d) !important;
color: #fff !important;
border-radius: 0.5rem !important;
}
#be-messenger [data-selector="AGENT_MESSAGE_BUBBLE"] {
background-color: var(--light-color, #f5f5f5) !important;
color: var(--text-color, #333) !important;
border-radius: 0.5rem !important;
}
[data-selector="INPUT"] input {
border-radius: 0.5rem !important;
}
[data-selector="INPUT"] [class^="Input_Field__"] {
// border: 0 !important;
}
[data-selector="WINDOW"] * {
font-family: "Droid Arabic Kufi", "roboto", sans-serif !important;
${isArabicLang ? "direction: rtl !important;" : ""}
}
[data-selector="INPUT"] [class^="FormField_Label__"] {
${isArabicLang ? "text-align: right !important;" : ""}
}
[data-selector="QUICK_REPLIES"] button {
background-color: var(--primary-color, #99742d) !important;
padding: 0.5rem 1rem;
border-radius: 0.5rem;
height: 36px;
}
[data-selector="QUICK_REPLIES"] button:hover {
background-color: var(--primary-color, #99742d) !important;
}
#be-messenger .Widget_isOffline__adNnJ .Widget_Status__a9tYr {
background-color: #ff0000 !important;
}
#be-messenger [data-selector="PRIMARY_BUTTON"] {
padding-inline: 0rem !important;
background-color: transparent !important;
}
#be-messenger [data-selector="DELIMITER"] [class^="Transcript_Main"],
#be-messenger [data-selector="DELIMITER"] [class^="Delimiter_Label__"] {
background-color: var(--body-bg) !important;
}
#be-messenger [data-selector="PRIMARY_BUTTON"] [class^="Button_Button"] {
padding-inline: 0rem !important;
background-color: var(--primary-color, #99742d) !important;
color: #fff !important;
border-radius: 0.5rem !important;
}
#be-messenger [class^="EndSession_Footer__"] {
display: flex;
gap: 1rem;
flex-direction: column;
}
#be-messenger [class^="EndSession_Footer__"] [class^="EndSession_Button__"] {
padding: 0.5rem !important;
display: flex !important;
align-items: center;
justify-content: center;
gap: 0.5rem;
color: var(--text-color) !important;
}
#be-messenger [class^="EndSession_Footer__"] [class^="EndSession_Button__"] svg {
fill: var(--text-color) !important;
}
/* Form Fields */
[data-selector="PRECONTACT_SURVEY"] [class^="StartSession_Overflow__"] {
display: flex !important;
flex-direction: column !important;
gap: 1rem !important;
}
#be-messenger .Widget_Status__a9tYr {
background-color: #00ff00 !important;
}
#be-messenger .BrandLabel_BrandLabel__KxS\+Y {
display: none !important;
}
#be-messenger .ScrollbarsCustom-Content [data-selector="INPUT"] {
margin: 0 !important;
}
/* Chat Header */
#be-messenger [data-selector="HEADER"] {
background-color: var(--primary-color, #99742d) !important;
color: #fff !important;
border-radius: 0.5rem 0.5rem 0 0 !important;
}
#be-messenger [data-selector="HEADER"] button {
color: #fff !important;
background-color: transparent !important;
}
/* Button Chat */
#be-messenger [data-selector="WIDGET"] {
border: 1px solid var(--primary-color) !important;
background-color: var(--body-bg) !important;
width: 55px !important;
height: 55px !important;
text-decoration: none !important;
border-radius: 50% !important;
transition: all 0.25s ease-in-out;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25) !important;
color: var(--primary-color) !important;
opacity: 1;
z-index: 998;
margin-bottom: 0 !important;
background-color: var(--body-bg) !important;
display: flex;
align-items: center;
justify-content: center;
margin: auto;
}
#be-messenger [data-selector="WIDGET"][class*="Widget_isOffline"] {
border: 2px solid #ff0000 !important;
}
#be-messenger [class^="Window_Body__"],
#be-messenger [class^="Window_Body__"]>div {
background-color: var(--body-bg) !important;
}
#be-messenger [class*="Widget_isOffline"] [class^="Widget_Icon__"] {
color: #ff0000 !important;
opacity: 1;
}
#be-messenger [class*="Widget_isOffline"] [class^="Widget_Icon__"] [class="be-icon-envelope"]:before{
content: var(--chat-icon) !important
}
#be-messenger.be-messenger-minimized {
position: relative;
display: flex;
align-items: center;
justify-content: center;
width: 60px;
height: 60px;
}
#be-frame.be-frame-default {
width: 320px;
height: 465px;
}
/* Chat Window */
#be-messenger {
border-radius: 0.25rem !important;
}
#be-messenger [data-selector="WIDGET"]:hover {
box-shadow: 0 0 5px 0 rgba(0, 0, 0, 0.3);
background-color: var(--primary-color, #99742d) !important;
color: #fff !important;
}
#be-messenger [class^="Widget_Icon__"] {
margin: 0 !important;
font-size: 1.5rem !important;
transition: all 0.3s ease;
}
#be-messenger [data-selector="WIDGET"]:hover [class^="Widget_Icon__"] {
transform: rotate(10deg);
}
[data-selector="ACTIVITY_BAR"] [class^="WaitingQueueModal_"] {
background-color: var(--disabled-color) !important;
}
#be-messenger [class^="Widget_Status__"],
#be-messenger [class^="Widget_Text__"] {
display: none !important;
}
#be-messenger [data-selector="UPLOAD_ATTACHMENT_BUTTON"],
#be-messenger [class^="ReplyBox_ReplyBox__"],
#be-messenger [class^="SystemMessage_HistoryItemContent__"],
#be-messenger [class^="Input_Field__"],
#be-messenger select,
#be-messenger textarea,
#be-messenger input {
background-color: var(--body-bg) !important;
color: var(--text-color) !important;
}
#be-messenger [class^="StartSession_StartSession__"],
#be-messenger [class^="StartSession_Footer__"] {
background-color: var(--body-bg) !important;
}
#be-messenger [class^="ConnectionStatus_ConnectionStatus__"] .mui-vubbuv,
[class^="ConnectionStatus_ConnectionStatus"] {
background-color: var(--body-bg) !important;
color: var(--text-color) !important;
}
.be-messenger-minimized {
background-color: transparent !important;
}
`;
};
//======================================================================
// Get the color theme from the URL
//======================================================================
const getColorTheme = () => {
var themeColor = $("body").attr("data-color");
// themeColor
if (_urlParams.get("themeColor")) {
themeColor = _urlParams.get("themeColor").toLowerCase();
// remove hash if exists from the color
themeColor = themeColor.replace("#", "");
}
const colorsMap = {
red: "#d83731",
green: "#3f8e50",
blue: "#00abeb",
primary: "#99742d",
};
switch (themeColor) {
case "gold-theme":
return colorsMap.primary;
case "gold":
return colorsMap.primary;
case "red-theme":
return colorsMap.red;
case "red":
return colorsMap.red;
case "green-theme":
return colorsMap.green;
case "green":
return colorsMap.green;
case "blue-theme":
return colorsMap.blue;
case "blue":
return colorsMap.blue;
case "99742d":
return colorsMap.primary;
case "d83731":
return colorsMap.red;
case "3f8e50":
return colorsMap.green;
case "00abeb":
return colorsMap.blue;
default:
return colorsMap.primary;
}
};
//======================================================================
// Check if the dark mode is enabled
//======================================================================
const checkDarkMode = () => {
const isDarkMode = document.body.classList.contains("dark-mode") ? true : false;
// brightness param dark/light
const isBrightnessDark = _urlParams.get("brightness") == "dark" ? true : false;
const isDarkEnable = localStorage.getItem("dark-mode") == "true" || localStorage.getItem("darkMode") == "true" ? true : false;
return isDarkMode || isBrightnessDark || isDarkEnable;
};
//======================================================================
// Set Arabic Translation for the chat window
//======================================================================
const arabicTranslation = {
allAgentsForQueueAreBusy: 'جميع الوكلاء المخصصون مشغولون حاليًا. هناك {queue, plural, one {شخص واحد} other {أشخاص}} {queue, number} قبلك في الطابور.',
beginButton: 'ابدأ الدردشة!',
cancel: 'إلغاء',
caseNumber: 'رقم الطلب #{caseNumber}',
change: 'تغيير',
chattedWith: 'لقد أجريت للتو محادثة مع',
commonErrorText: 'حدث خطأ غير متوقع. الرجاء المحاولة مرة أخرى لاحقًا.',
done: 'تم',
dragAndDropDropzone: 'اسحب وأفلت الملفات هنا لإرسالها',
dragAndDropDropzoneRejected: 'تعذر تحميل الملف :(',
EmailLabel: 'البريد الإلكتروني',
endChat: 'إنهاء الدردشة',
endChatTitle: 'هل أنت متأكد أنك تريد إنهاء هذه المحادثة؟',
endGame: 'إنهاء اللعبة',
ending: 'جارٍ إنهاء الدردشة...',
fileSendingFailed: 'فشل إرسال الملف',
getTranscriptDescription: 'إرسال نسخة من هذه المحادثة إلى العنوان البريد الإلكتروني التالي:',
getTranscriptLink: 'احصل على نسخة المحادثة',
invalidToken: 'رمز غير صالح',
ipAddressBlocked: 'تم حظر عنوان الـ IP',
loading: 'جارٍ التحميل ...',
loadPreviousButton: 'تحميل المحادثات السابقة',
messageLabel: 'رسالة',
networkErrorText: 'كان هناك خطأ في الشبكة. الرجاء المحاولة مرة أخرى.',
newCase: 'طلب جديدة',
noAgentOnlineForQueue: 'لا يوجد وكيل متاح في الوقت الحالي.',
offline: 'غير متصل',
offlineFormDesc: 'نحن غير متاحين في الوقت الحالي',
offlineFormSuccessMsgHead: 'شكرًا لك!',
offlineFormSuccessMsgSub: 'تم إرسال بريدك الإلكتروني بنجاح. سنعود إليك قريبًا.',
online: 'متصل',
onlineFormText: ' مرحباً بكم في وزارة التعليم العالي والبحث العلمي!',
pleaseSelect: 'يرجى الاختيار...',
poweredBy: 'مشغل بواسطة',
preparingSession: 'جارٍ تحضير الجلسة...',
replyBoxPlaceholder: 'اكتب هنا، واضغط ENTER للإرسال',
retry: 'أعد المحاولة',
sendFileTextSize: 'الرجاء رفع ملفات أصغر من {filesize}',
sendFileTextSupportedFormat: 'تنسيقات مدعومة.',
sendFileTextSupportedFormatDesc: 'صور، فيديوهات، {fileFormats}',
sendMessageButton: 'إرسال رسالة',
sendNewEmail: 'إرسال بريد إلكتروني جديد',
sendTranscript: 'إرسال النسخة',
snakeWaiting: 'أنت {queue} في .',
startChatInPopup: 'اسألنا!',
startNewChat: 'ابدأ دردشة جديدة',
statusReconnecting: 'يحاول الاتصال…',
surveySuccesfullySent: 'شكرًا على ملاحظاتك!',
systemChattingWith: 'أنت الآن تدردش مع {name}',
topic: 'الموضوع',
transciptSentFailed: 'فشل الإرسال.',
transciptSuccesfullySent: 'تم إرسال النسخة بنجاح!',
tryAgainButton: 'حاول مرة أخرى',
unexpectedError: 'خطأ غير متوقع.',
validationInvalidEmail: 'عنوان البريد الإلكتروني غير صالح',
validationMandatory: 'هذا الحقل إلزامي',
validationShorterName: 'الرجاء استخدام اسم أقصر',
validationShortMessage: 'رسالتك قصيرة جدًا',
waiting: 'انتظار...',
waitingDescription: 'سيتحدث معك أحد وكلائنا قريبًا.',
waitingFooter: 'اضغط على