تنسيق المحتوى غير مألوف
سيتم عرضه كنص عادي
${escapeHtml(String(content))}
`;
} catch (error) {
console.error('Error processing message content:', error);
return `
خطأ في معالجة المحتوى
${error.message}
`;
}
}
// Helper function to escape HTML
function escapeHtml(text) {
const div = document.createElement('div');
div.textContent = text;
return div.innerHTML;
}
// Helper function to detect HTML content
function isHtmlContent(content) {
// Simple check for HTML tags
const htmlTagRegex = /<[^>]+>/;
return htmlTagRegex.test(content);
}
async function openMessage(messageId) {
try {
// Get message from API
const response = await fetch(`/api/v1/messages/${messageId}?email=${encodeURIComponent(currentEmail)}`, {
method: 'GET',
headers: {
'X-API-Key': FRONTEND_API_KEY,
'X-Frontend-Request': 'true',
'X-Bypass-Rate-Limit': 'frontend',
'X-Admin-Override': 'true',
'X-Skip-Auth': 'frontend-bypass'
}
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
if (!data.success || !data.message) {
throw new Error('Failed to load message');
}
const message = data.message;
if (message) {
// --- تحسين عرض الرسائل باستخدام iframe للأمان والقوة ---
const modal = document.createElement('div');
modal.style.cssText = `
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: transparent;
z-index: 1000;
display: flex;
align-items: center;
justify-content: center;
padding: 20px;
backdrop-filter: blur(15px);
`;
const modalContent = document.createElement('div');
modalContent.style.cssText = `
background: rgba(255, 255, 255, 0.6);
backdrop-filter: blur(25px);
border-radius: 15px;
width: 95vw;
max-width: 1400px;
height: 90vh;
max-height: 90vh;
overflow: hidden;
position: relative;
padding: 0;
box-shadow: 0 20px 60px rgba(0,0,0,0.2);
border: 1px solid rgba(255, 255, 255, 0.4);
display: flex;
flex-direction: column;
`;
// Hide scrollbar for webkit browsers
modalContent.style.setProperty('scrollbar-width', 'none');
modalContent.style.setProperty('-ms-overflow-style', 'none');
modalContent.classList.add('hide-scrollbar');
// إنشاء معلومات المرفقات إذا وجدت
let attachmentsHtml = '';
if (message.hasAttachments && message.attachments && message.attachments.length > 0) {
attachmentsHtml = `
لم يتمكن من عرض المحتوى الأصلي، و تم عرضه كنص عادي
`;
}
} catch (e) {
console.error('Error checking iframe content:', e);
}
};
iframe.onerror = function() {
console.error('Error loading iframe content');
iframe.srcdoc = `