کتاب مقدس آنلاین: تفاوت میان نسخهها
ظاهر
بدون خلاصۀ ویرایش برچسب: برگرداندهشده |
بدون خلاصۀ ویرایش برچسب: برگرداندهشده |
||
خط ۱۸۸: | خط ۱۸۸: | ||
border-radius: 6px; | border-radius: 6px; | ||
background: white; | background: white; | ||
} | } | ||
خط ۳۶۰: | خط ۳۲۰: | ||
} | } | ||
.content-display | .content-display { | ||
height: 500px; | height: 500px; | ||
} | } | ||
خط ۳۷۶: | خط ۳۳۶: | ||
@media (max-width: 480px) { | @media (max-width: 480px) { | ||
.content-display | .content-display { | ||
height: 450px; | height: 450px; | ||
} | } | ||
خط ۷۸۲: | خط ۷۴۲: | ||
}); | }); | ||
// نمایش فصل با iframe | // نمایش فصل با iframe - فقط محتوای اصلی | ||
function displayChapterWithIframe() { | function displayChapterWithIframe() { | ||
const bookIndex = parseInt(currentBook); | const bookIndex = parseInt(currentBook); | ||
خط ۷۹۷: | خط ۷۵۷: | ||
// استفاده از action=render برای نمایش فقط محتوای اصلی | // استفاده از action=render برای نمایش فقط محتوای اصلی | ||
const contentUrl = `${translations[currentTranslation].baseUrl}${encodeURIComponent(pageTitle)}&action=render`; | const contentUrl = `${translations[currentTranslation].baseUrl}${encodeURIComponent(pageTitle)}&action=render`; | ||
versesContainer.innerHTML = ` | versesContainer.innerHTML = ` | ||
< | <iframe | ||
id="content-iframe" | |||
src="${contentUrl}" | |||
class="content-display" | |||
frameborder="0" | |||
loading="lazy" | |||
allowfullscreen> | |||
</iframe> | |||
`; | `; | ||
// | // مدیریت لینکهای داخل iframe | ||
setTimeout(() => { | |||
manageIframeLinks(); | |||
}, 2000); | |||
}); | |||
// لینک صفحه کامل برای باز کردن در تب جدید | // لینک صفحه کامل برای باز کردن در تب جدید | ||
wikiPageLink.href = | wikiPageLink.href = `${translations[currentTranslation].baseUrl}${encodeURIComponent(pageTitle)}`; | ||
wikiPageLink.style.display = 'flex'; | wikiPageLink.style.display = 'flex'; | ||
updateNavigationButtons(); | updateNavigationButtons(); | ||
} | |||
// تابع جدید برای مدیریت لینکهای داخل iframe | |||
function manageIframeLinks() { | |||
const iframe = document.getElementById('content-iframe'); | |||
if (!iframe) return; | |||
iframe.addEventListener('load', function() { | |||
try { | |||
const iframeDoc = iframe.contentDocument || iframe.contentWindow.document; | |||
const links = iframeDoc.querySelectorAll('a'); | |||
links.forEach(link => { | |||
// فقط لینکهای داخلی سایت pediabible.com را مدیریت میکنیم | |||
if (link.href && link.href.includes('pediabible.com')) { | |||
link.addEventListener('click', function(e) { | |||
e.preventDefault(); | |||
// ساخت URL جدید با action=render | |||
let newUrl = link.href; | |||
if (!newUrl.includes('action=render')) { | |||
if (newUrl.includes('?')) { | |||
newUrl += '&action=render'; | |||
} else { | |||
newUrl += '?action=render'; | |||
} | |||
} | |||
// بارگذاری لینک جدید در همان iframe | |||
iframe.src = newUrl; | |||
}); | |||
} else { | |||
// لینکهای خارجی در تب جدید باز شوند | |||
link.target = '_blank'; | |||
} | |||
}); | |||
console.log(`✅ ${links.length} لینک مدیریت شد`); | |||
} catch (error) { | |||
console.log('⚠️ امکان دسترسی به iframe به دلیل CORS وجود ندارد'); | |||
// استفاده از روش جایگزین | |||
useAlternativeLinkManagement(); | |||
} | |||
}); | |||
} | |||
// روش جایگزین برای زمانی که CORS مانع میشود | |||
function useAlternativeLinkManagement() { | |||
const iframe = document.getElementById('content-iframe'); | |||
if (!iframe) return; | |||
// گوش دادن به تغییرات iframe | |||
let currentUrl = iframe.src; | |||
const checkUrlChange = setInterval(() => { | |||
try { | |||
const iframeWindow = iframe.contentWindow; | |||
const iframeUrl = iframeWindow.location.href; | |||
if (iframeUrl !== currentUrl && !iframeUrl.includes('action=render')) { | |||
// اگر URL تغییر کرد و action=render ندارد، آن را اضافه کنیم | |||
let newUrl = iframeUrl; | |||
if (newUrl.includes('?')) { | |||
newUrl += '&action=render'; | |||
} else { | |||
newUrl += '?action=render'; | |||
} | |||
iframe.src = newUrl; | |||
currentUrl = newUrl; | |||
} | |||
} catch (error) { | |||
// خطای CORS - متوقف کردن چک | |||
clearInterval(checkUrlChange); | |||
console.log('⚠️ نظارت بر تغییرات iframe متوقف شد'); | |||
} | |||
}, 500); | |||
// بعد از 30 ثانیه چک کردن را متوقف کن | |||
setTimeout(() => { | |||
clearInterval(checkUrlChange); | |||
}, 30000); | |||
} | } | ||