کتاب مقدس آنلاین: تفاوت میان نسخهها
ظاهر
بدون خلاصۀ ویرایش |
بدون خلاصۀ ویرایش |
||
| خط ۴۸۳: | خط ۴۸۳: | ||
}; | }; | ||
// ✅ تابع | // ✅ تابع هوشمند: لینکهای داخلی را با &action=render باز کن | ||
function | function makeLinksUseRender(iframe) { | ||
try { | try { | ||
const doc = iframe.contentDocument || iframe.contentWindow.document; | const doc = iframe.contentDocument || iframe.contentWindow.document; | ||
if (!doc | if (!doc) return; | ||
const links = doc.querySelectorAll('a[href]'); | const links = doc.querySelectorAll('a[href*="pediabible.com"], a[href^="/"]'); | ||
links.forEach(link => { | links.forEach(link => { | ||
if (link.dataset.renderHandled) return; // جلوگیری از دوبارهاتصال | |||
link.dataset.renderHandled = "true"; | |||
link.addEventListener('click', function(e) { | |||
e.preventDefault(); | |||
let href = link.getAttribute('href'); | |||
if (!href) return; | |||
try { | |||
const url = new URL(href, window.location.origin); | |||
let title = url.searchParams.get('title'); | |||
if (!title) { | |||
const path = url.pathname; | |||
if (path.includes('/index.php/')) { | |||
title = decodeURIComponent(path.split('/index.php/')[1]); | |||
} else if (path.startsWith('/')) { | |||
const parts = path.split('/').filter(p => p); | |||
if (parts.length > 0) title = decodeURIComponent(parts[parts.length - 1]); | |||
} | |||
} | |||
if (title) { | |||
const renderUrl = `${window.location.origin}/index.php?title=${encodeURIComponent(title)}&action=render`; | |||
iframe.src = renderUrl; | |||
document.getElementById('chapter-title').textContent = `مطلب: ${decodeURIComponent(title)}`; | |||
} | |||
} catch (err) { | |||
console.warn('خطا در پردازش لینک:', err); | |||
} | } | ||
}); | |||
}); | }); | ||
} catch (err) { | } catch (err) { | ||
console.debug('عدم دسترسی به iframe:', err.message); | |||
console.debug('دسترسی به iframe | |||
} | } | ||
} | } | ||
| خط ۶۶۳: | خط ۶۷۹: | ||
const pageTitle = translations[currentTranslation].getPageTitle(bookDisplayName, currentChapter); | const pageTitle = translations[currentTranslation].getPageTitle(bookDisplayName, currentChapter); | ||
const contentUrl = `${translations[currentTranslation].baseUrl}${encodeURIComponent(pageTitle)}&action=render`; | |||
const contentUrl = `${translations[currentTranslation].baseUrl}${encodeURIComponent(pageTitle)}`; | |||
versesContainer.innerHTML = ` | versesContainer.innerHTML = ` | ||
| خط ۶۷۷: | خط ۶۹۲: | ||
`; | `; | ||
wikiPageLink.href = | wikiPageLink.href = `${translations[currentTranslation].baseUrl}${encodeURIComponent(pageTitle)}`; | ||
wikiPageLink.style.display = 'flex'; | wikiPageLink.style.display = 'flex'; | ||
updateNavigationButtons(); | updateNavigationButtons(); | ||
// ✅ | // ✅ فعالسازی لینکهای هوشمند | ||
const iframe = document.getElementById('content-iframe'); | const iframe = document.getElementById('content-iframe'); | ||
iframe.onload = function() { | iframe.onload = function() { | ||
makeLinksUseRender(iframe); | |||
}; | }; | ||
} | } | ||