// ═══════════════════════════════════════════════════════════
// فراخوانی چتبات در حالت Full Page
// ═══════════════════════════════════════════════════════════
document.addEventListener(‘DOMContentLoaded’, function() {
// مخفی کردن لودینگ
const loadingElement = document.getElementById(‘loading’);
if (loadingElement) {
loadingElement.style.display = ‘none’;
}
if (window.HexoChatbot && window.HexoChatbot.initFull) {
window.HexoChatbot.initFull({
element: ‘#chat-container’,
…fullScreenChatConfig
});
} else {
console.error(‘HexoChatbot not loaded. Check chatbot.js inclusion.’);
// نمایش خطا
const errorDiv = document.createElement(‘div’);
errorDiv.style.cssText = `
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: #fff;
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 20px rgba(0,0,0,0.2);
text-align: center;
z-index: 10000;
`;
errorDiv.innerHTML = `
خطا در بارگذاری چت بات
لطفاً صفحه را رفرش کنید یا با پشتیبانی تماس بگیرید.
`;
document.body.appendChild(errorDiv);
}
});
// هندل کردن خطاهای شبکه
window.addEventListener(‘error’, function(e) {
if (e.target && e.target.tagName === ‘SCRIPT’ && e.target.src.includes(‘chatbot.js’)) {
console.error(‘Failed to load chatbot.js’);
}
});