کتاب مقدس آنلاین: تفاوت میان نسخهها
ظاهر
بدون خلاصۀ ویرایش |
بدون خلاصۀ ویرایش |
||
| خط ۷۸۶: | خط ۷۸۶: | ||
try { | try { | ||
const iframeDoc = iframe.contentDocument || iframe.contentWindow.document; | const iframeDoc = iframe.contentDocument || iframe.contentWindow.document; | ||
const links = iframeDoc.querySelectorAll('a | const links = iframeDoc.querySelectorAll('a'); | ||
links.forEach(link => { | links.forEach(link => { | ||
// بررسی تمام لینکها به pediabible.com | |||
if (link.href && link.href.includes('pediabible.com')) { | |||
link.onclick = function(e) { | |||
e.preventDefault(); | |||
e.stopPropagation(); | |||
// بهروزرسانی لینک و عنوان | const url = new URL(this.href); | ||
let titleParam = url.searchParams.get('title'); | |||
} | // اگر title وجود ندارد، از مسیر استخراج کنیم | ||
} | if (!titleParam) { | ||
const pathParts = url.pathname.split('/'); | |||
const lastPart = pathParts[pathParts.length - 1]; | |||
if (lastPart === 'index.php') { | |||
titleParam = url.searchParams.get('title'); | |||
} else { | |||
// استخراج عنوان از مسیر | |||
titleParam = decodeURIComponent(lastPart); | |||
} | |||
} | |||
if (titleParam) { | |||
// بارگذاری صفحه جدید در iframe با action=render | |||
const newUrl = `${translations[currentTranslation].baseUrl}${encodeURIComponent(titleParam)}&action=render`; | |||
iframe.src = newUrl; | |||
// بهروزرسانی لینک و عنوان | |||
wikiPageLink.href = `${translations[currentTranslation].baseUrl}${encodeURIComponent(titleParam)}`; | |||
chapterTitle.textContent = `صفحه: ${decodeURIComponent(titleParam)}`; | |||
} | |||
}; | |||
} | |||
}); | }); | ||
} catch (error) { | } catch (error) { | ||
// خطا را نادیده بگیر - به برنامه آسیب نمیزند | // خطا را نادیده بگیر - به برنامه آسیب نمیزند | ||
console.log('خطا در مدیریت لینکها:', error); | |||
} | } | ||
}; | }; | ||