کتاب مقدس آنلاین: تفاوت میان نسخهها
ظاهر
بدون خلاصۀ ویرایش |
بدون خلاصۀ ویرایش |
||
| خط ۷۱۵: | خط ۷۱۵: | ||
if (pageTitle) { | if (pageTitle) { | ||
// اگر صفحه خاصی درخواست شده (مثل | // اگر صفحه خاصی درخواست شده (مثل ابراهیم) | ||
title = pageTitle; | title = pageTitle; | ||
displayTitle = decodeURIComponent(pageTitle); | displayTitle = decodeURIComponent(pageTitle); | ||
| خط ۷۴۵: | خط ۷۴۵: | ||
try { | try { | ||
const response = await fetch(contentUrl); | const response = await fetch(contentUrl); | ||
if (!response.ok) { | |||
throw new Error('خطا در دریافت محتوا'); | |||
} | |||
const html = await response.text(); | const html = await response.text(); | ||
| خط ۷۶۱: | خط ۷۶۴: | ||
} catch (error) { | } catch (error) { | ||
console.error('خطا در بارگذاری:', error); | |||
versesContainer.innerHTML = ` | versesContainer.innerHTML = ` | ||
<div class="access-denied"> | <div class="access-denied"> | ||
<h3><i class="fas fa-exclamation-triangle"></i> خطا در بارگذاری</h3> | <h3><i class="fas fa-exclamation-triangle"></i> خطا در بارگذاری</h3> | ||
<p>مشکلی در بارگذاری محتوا پیش آمده است.</p> | <p>مشکلی در بارگذاری محتوا پیش آمده است.</p> | ||
<p>لطفاً دوباره تلاش کنید.</p> | |||
</div> | </div> | ||
`; | `; | ||
| خط ۷۸۵: | خط ۷۹۰: | ||
// حذف تمام المانهای اضافی | // حذف تمام المانهای اضافی | ||
const elementsToRemove = tempDiv.querySelectorAll( | const elementsToRemove = tempDiv.querySelectorAll( | ||
'header, nav, .mw-header, .wiki-header, .header, #header, .navigation, .nav, .mw-nav, #mw-navigation, script, style, link, meta, .mw-editsection, .reference, .references, .mw-cite-backlink' | 'header, nav, .mw-header, .wiki-header, .header, #header, .navigation, .nav, .mw-nav, #mw-navigation, script, style, link, meta, .mw-editsection, .reference, .references, .mw-cite-backlink, .printfooter, .catlinks, .visualClear' | ||
); | ); | ||
elementsToRemove.forEach(el => el.remove()); | elementsToRemove.forEach(el => el.remove()); | ||
// | // پردازش تمام لینکها | ||
const links = tempDiv.querySelectorAll('a | const links = tempDiv.querySelectorAll('a'); | ||
links.forEach(link => { | links.forEach(link => { | ||
const | const href = link.getAttribute('href'); | ||
const | |||
if (href && href.includes('pediabible.com')) { | |||
link.href = 'javascript:void(0)'; | // استخراج عنوان از URL | ||
let title = null; | |||
if (href.includes('index.php?title=')) { | |||
// لینکهای فرمت: index.php?title=ابراهیم | |||
const urlParams = new URLSearchParams(href.split('?')[1]); | |||
title = urlParams.get('title'); | |||
} else if (href.includes('/index.php/')) { | |||
// لینکهای فرمت: /index.php/ابراهیم | |||
const parts = href.split('/'); | |||
title = parts[parts.length - 1]; | |||
} else if (href.includes('pediabible.com/') && !href.includes('index.php')) { | |||
// لینکهای فرمت: pediabible.com/ابراهیم | |||
const domainParts = href.split('pediabible.com/'); | |||
if (domainParts[1]) { | |||
title = domainParts[1].split('?')[0].split('#')[0]; | |||
} | |||
} | |||
if (title) { | |||
// تبدیل لینک به لینک داخلی برنامه | |||
link.href = 'javascript:void(0)'; | |||
link.setAttribute('data-wiki-title', title); | |||
link.classList.add('internal-link'); | |||
} | |||
} | } | ||
}); | }); | ||