Привет, это загрузчик чатбро. По сути, я пытаюсь сделать его совместимым с дневным и ночным режимом для моего веб-сайта, но он загружает 2 чата на странице 1 белый 1 черный чат, когда я переключаю дневной/ночной режим, он даже загружает больше, я просто хочу обновить текущий код, чтобы больше не загружать чаты, я хочу 1 блок чата! я загружаю Chatbro.php, используя тег php include, кстати, я не знаю, если это проблема.. вот код
function ChatbroLoader(chats, async) {
async = !1 !== async;
var params = {
embedChatsParameters: chats instanceof Array ? chats : [chats],
lang: navigator.language || navigator.userLanguage,
needLoadCode: 'undefined' == typeof Chatbro,
embedParamsVersion: localStorage.embedParamsVersion,
chatbroScriptVersion: localStorage.chatbroScriptVersion
},
xhr = new XMLHttpRequest;
xhr.withCredentials = !0;
xhr.onload = function() {
eval(xhr.responseText);
};
xhr.onerror = function() {
console.error('Chatbro loading error')
};
xhr.open('GET', '//www.chatbro.com/embed.js?' +
btoa(unescape(encodeURIComponent(JSON.stringify(params)))), async);
xhr.send();
}
// Function to get the chat header background color for night mode
function getChatHeaderBackgroundColor() {
var body = document.querySelector('body');
if (body && body.getAttribute('data-style') === 'dark-layout') {
return '#7367f0'; // Replace with your desired dark mode color
} else {
return '#ffffff'; // Default day mode color
}
}
// Function to get the chat body background color for night mode
function getChatBodyBackgroundColor() {
var body = document.querySelector('body');
if (body && body.getAttribute('data-style') === 'dark-layout') {
return '#1F2937'; // Replace with your desired dark mode body color
} else {
return '#ffffff'; // Default day mode color
}
}
// Function to get the chat input background color for night mode
function getChatInputBackgroundColor() {
var body = document.querySelector('body');
if (body && body.getAttribute('data-style') === 'dark-layout') {
return '#1F2937'; // Replace with your desired dark mode input color
} else {
return '#ffffff'; // Default day mode color
}
}
// Function to reload the Chatbro widget with the correct colors
function reloadChatbroWidget() {
var chatContainer = document.getElementById('chatbroContainer');
if (chatContainer) {
chatContainer.innerHTML = ''; // Clear the existing widget
}
ChatbroLoader({
encodedChatId: '',
siteDomain: '',
chatHeaderBackgroundColor: getChatHeaderBackgroundColor(),
chatBodyBackgroundColor: getChatBodyBackgroundColor(),
chatInputBackgroundColor: getChatInputBackgroundColor(),
showChatShadow: 'true',
siteUserExternalId: '',
siteUserFullName: '',
siteUserAvatarUrl: '',
siteUserProfileUrl: '',
siteUserFullNameColor: '',
permissions: ,
signature: ''
});
}
// Set up a MutationObserver to watch for changes to the data-style attribute
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.attributeName === 'data-style') {
reloadChatbroWidget();
}
});
});
// Start observing the body element for attribute changes
var body = document.querySelector('body');
if (body) {
observer.observe(body, {
attributes: true // Configure it to listen for attribute changes
});
}
// Initial load of the Chatbro widget
reloadChatbroWidget();
Подробнее здесь: https://stackoverflow.com/questions/787 ... many-chats
Javascript загружает так много чатов ⇐ Jquery
Программирование на jquery
1720489765
Anonymous
Привет, это загрузчик чатбро. По сути, я пытаюсь сделать его совместимым с дневным и ночным режимом для моего веб-сайта, но он загружает 2 чата на странице 1 белый 1 черный чат, когда я переключаю дневной/ночной режим, он даже загружает больше, я просто хочу обновить текущий код, чтобы больше не загружать чаты, я хочу 1 блок чата! я загружаю Chatbro.php, используя тег php include, кстати, я не знаю, если это проблема.. вот код
function ChatbroLoader(chats, async) {
async = !1 !== async;
var params = {
embedChatsParameters: chats instanceof Array ? chats : [chats],
lang: navigator.language || navigator.userLanguage,
needLoadCode: 'undefined' == typeof Chatbro,
embedParamsVersion: localStorage.embedParamsVersion,
chatbroScriptVersion: localStorage.chatbroScriptVersion
},
xhr = new XMLHttpRequest;
xhr.withCredentials = !0;
xhr.onload = function() {
eval(xhr.responseText);
};
xhr.onerror = function() {
console.error('Chatbro loading error')
};
xhr.open('GET', '//www.chatbro.com/embed.js?' +
btoa(unescape(encodeURIComponent(JSON.stringify(params)))), async);
xhr.send();
}
// Function to get the chat header background color for night mode
function getChatHeaderBackgroundColor() {
var body = document.querySelector('body');
if (body && body.getAttribute('data-style') === 'dark-layout') {
return '#7367f0'; // Replace with your desired dark mode color
} else {
return '#ffffff'; // Default day mode color
}
}
// Function to get the chat body background color for night mode
function getChatBodyBackgroundColor() {
var body = document.querySelector('body');
if (body && body.getAttribute('data-style') === 'dark-layout') {
return '#1F2937'; // Replace with your desired dark mode body color
} else {
return '#ffffff'; // Default day mode color
}
}
// Function to get the chat input background color for night mode
function getChatInputBackgroundColor() {
var body = document.querySelector('body');
if (body && body.getAttribute('data-style') === 'dark-layout') {
return '#1F2937'; // Replace with your desired dark mode input color
} else {
return '#ffffff'; // Default day mode color
}
}
// Function to reload the Chatbro widget with the correct colors
function reloadChatbroWidget() {
var chatContainer = document.getElementById('chatbroContainer');
if (chatContainer) {
chatContainer.innerHTML = ''; // Clear the existing widget
}
ChatbroLoader({
encodedChatId: '',
siteDomain: '',
chatHeaderBackgroundColor: getChatHeaderBackgroundColor(),
chatBodyBackgroundColor: getChatBodyBackgroundColor(),
chatInputBackgroundColor: getChatInputBackgroundColor(),
showChatShadow: 'true',
siteUserExternalId: '',
siteUserFullName: '',
siteUserAvatarUrl: '',
siteUserProfileUrl: '',
siteUserFullNameColor: '',
permissions: ,
signature: ''
});
}
// Set up a MutationObserver to watch for changes to the data-style attribute
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.attributeName === 'data-style') {
reloadChatbroWidget();
}
});
});
// Start observing the body element for attribute changes
var body = document.querySelector('body');
if (body) {
observer.observe(body, {
attributes: true // Configure it to listen for attribute changes
});
}
// Initial load of the Chatbro widget
reloadChatbroWidget();
Подробнее здесь: [url]https://stackoverflow.com/questions/78723382/javascript-is-loading-so-many-chats[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия