کتاب مقدس آنلاین: تفاوت میان نسخهها
ظاهر
بدون خلاصۀ ویرایش |
بدون خلاصۀ ویرایش |
||
| خط ۱۷۹: | خط ۱۷۹: | ||
border-radius: 6px; | border-radius: 6px; | ||
background: white; | background: white; | ||
padding: | padding: 25px; | ||
line-height: 2; | line-height: 2; | ||
font-size: 1.1rem; | font-size: 1.1rem; | ||
| خط ۱۸۷: | خط ۱۸۷: | ||
margin-bottom: 15px; | margin-bottom: 15px; | ||
padding-right: 15px; | padding-right: 15px; | ||
} | } | ||
| خط ۲۰۴: | خط ۲۰۳: | ||
border-bottom: 1px dotted var(--secondary-color); | border-bottom: 1px dotted var(--secondary-color); | ||
transition: all 0.3s; | transition: all 0.3s; | ||
cursor: pointer; | |||
} | } | ||
| خط ۳۶۹: | خط ۳۶۹: | ||
} | } | ||
.placeholder { | .placeholder { | ||
display: flex; | display: flex; | ||
| خط ۴۱۱: | خط ۳۸۵: | ||
} | } | ||
option { | option { | ||
direction: rtl; | direction: rtl; | ||
| خط ۴۴۴: | خط ۴۱۷: | ||
]; | ]; | ||
function isDomainAllowed() { | function isDomainAllowed() { | ||
const currentDomain = window.location.hostname; | const currentDomain = window.location.hostname; | ||
if (!currentDomain || currentDomain === '' || currentDomain === 'null') { | if (!currentDomain || currentDomain === '' || currentDomain === 'null') { | ||
return true; | return true; | ||
} | } | ||
return ALLOWED_DOMAINS.some(domain => { | return ALLOWED_DOMAINS.some(domain => { | ||
return currentDomain === domain || currentDomain.endsWith('.' + domain); | return currentDomain === domain || currentDomain.endsWith('.' + domain); | ||
| خط ۴۵۷: | خط ۴۲۷: | ||
} | } | ||
function showAccessDenied() { | function showAccessDenied() { | ||
const wrapper = document.getElementById('content-wrapper'); | const wrapper = document.getElementById('content-wrapper'); | ||
| خط ۴۶۴: | خط ۴۳۳: | ||
<h3><i class="fas fa-ban"></i> دسترسی محدود شده</h3> | <h3><i class="fas fa-ban"></i> دسترسی محدود شده</h3> | ||
<p>این صفحه فقط بر روی دامنه <strong>pediabible.com</strong> قابل دسترسی است.</p> | <p>این صفحه فقط بر روی دامنه <strong>pediabible.com</strong> قابل دسترسی است.</p> | ||
<p>لطفاً از <a href="https://www.pediabible.com" style="color: #721c24; text-decoration: underline;">سایت اصلی</a> بازدید کنید.</p> | <p>لطفاً از <a href="https://www.pediabible.com" style="color: #721c24; text-decoration: underline;">سایت اصلی</a> بازدید کنید.</p> | ||
</div> | </div> | ||
| خط ۵۴۸: | خط ۵۱۶: | ||
const wrapper = document.getElementById('content-wrapper'); | const wrapper = document.getElementById('content-wrapper'); | ||
wrapper.innerHTML = ` | wrapper.innerHTML = ` | ||
<div class="selector-container"> | <div class="selector-container"> | ||
| خط ۶۱۷: | خط ۵۸۴: | ||
`; | `; | ||
const translations = { | const translations = { | ||
'old': { | 'old': { | ||
| خط ۶۴۹: | خط ۶۱۵: | ||
}; | }; | ||
const translationSelect = document.getElementById('translation-select'); | const translationSelect = document.getElementById('translation-select'); | ||
const testamentSelect = document.getElementById('testament-select'); | const testamentSelect = document.getElementById('testament-select'); | ||
| خط ۶۶۰: | خط ۶۲۵: | ||
const wikiPageLink = document.getElementById('wiki-page-link'); | const wikiPageLink = document.getElementById('wiki-page-link'); | ||
let currentTranslation = ''; | let currentTranslation = ''; | ||
let currentTestament = ''; | let currentTestament = ''; | ||
| خط ۶۶۶: | خط ۶۳۰: | ||
let currentChapter = 1; | let currentChapter = 1; | ||
translationSelect.addEventListener('change', function() { | translationSelect.addEventListener('change', function() { | ||
currentTranslation = this.value; | currentTranslation = this.value; | ||
| خط ۶۸۳: | خط ۶۴۶: | ||
}); | }); | ||
testamentSelect.addEventListener('change', function() { | testamentSelect.addEventListener('change', function() { | ||
currentTestament = this.value; | currentTestament = this.value; | ||
| خط ۷۱۰: | خط ۶۷۲: | ||
}); | }); | ||
bookSelect.addEventListener('change', function() { | bookSelect.addEventListener('change', function() { | ||
currentBook = this.value; | currentBook = this.value; | ||
| خط ۷۳۸: | خط ۶۹۹: | ||
}); | }); | ||
chapterSelect.addEventListener('change', function() { | chapterSelect.addEventListener('change', function() { | ||
currentChapter = parseInt(this.value); | currentChapter = parseInt(this.value); | ||
if (currentChapter) { | if (currentChapter) { | ||
loadContent(); | |||
} else { | } else { | ||
resetContent(); | resetContent(); | ||
| خط ۷۴۹: | خط ۷۰۹: | ||
}); | }); | ||
// | // تابع اصلی برای بارگذاری محتوا | ||
async function | async function loadContent(pageTitle = null) { | ||
const bookIndex = parseInt(currentBook); | let title; | ||
let displayTitle; | |||
if (pageTitle) { | |||
// اگر صفحه خاصی درخواست شده (مثل اسحاق) | |||
title = pageTitle; | |||
displayTitle = decodeURIComponent(pageTitle); | |||
} else { | |||
// اگر فصل کتاب درخواست شده | |||
const bookIndex = parseInt(currentBook); | |||
const bookData = bibleBooks[currentTestament][bookIndex]; | |||
const bookName = bookData.name; | |||
const bookDisplayName = bookData.displayName; | |||
const translationName = translations[currentTranslation].name; | |||
title = translations[currentTranslation].getPageTitle(bookDisplayName, currentChapter); | |||
displayTitle = `${translationName} - ${bookName} - فصل ${currentChapter}`; | |||
} | |||
chapterTitle.textContent = displayTitle; | |||
// نمایش loading | // نمایش loading | ||
versesContainer.innerHTML = ` | versesContainer.innerHTML = ` | ||
| خط ۷۶۶: | خط ۷۳۹: | ||
</div> | </div> | ||
`; | `; | ||
// استفاده از action=render برای دریافت فقط محتوای اصلی | // استفاده از action=render برای دریافت فقط محتوای اصلی | ||
const contentUrl = ` | const contentUrl = `https://www.pediabible.com/index.php?title=${encodeURIComponent(title)}&action=render`; | ||
try { | try { | ||
const response = await fetch(contentUrl); | const response = await fetch(contentUrl); | ||
const html = await response.text(); | const html = await response.text(); | ||
// پردازش HTML و استخراج محتوای اصلی | // پردازش HTML و استخراج فقط محتوای اصلی | ||
const processedContent = | const processedContent = processContent(html); | ||
// نمایش محتوا | // نمایش محتوا در container | ||
versesContainer.innerHTML = ` | versesContainer.innerHTML = ` | ||
<div class="content-display"> | <div class="content-display"> | ||
| خط ۷۸۶: | خط ۷۵۶: | ||
</div> | </div> | ||
`; | `; | ||
// | // تنظیم event listener برای تمام لینکهای داخلی | ||
setupInternalLinks(); | |||
} catch (error) { | } catch (error) { | ||
versesContainer.innerHTML = ` | versesContainer.innerHTML = ` | ||
| خط ۷۹۵: | خط ۷۶۵: | ||
<h3><i class="fas fa-exclamation-triangle"></i> خطا در بارگذاری</h3> | <h3><i class="fas fa-exclamation-triangle"></i> خطا در بارگذاری</h3> | ||
<p>مشکلی در بارگذاری محتوا پیش آمده است.</p> | <p>مشکلی در بارگذاری محتوا پیش آمده است.</p> | ||
</div> | </div> | ||
`; | `; | ||
} | } | ||
// لینک صفحه کامل | |||
wikiPageLink.href = `https://www.pediabible.com/index.php?title=${encodeURIComponent(title)}`; | |||
wikiPageLink.style.display = 'flex'; | |||
if (!pageTitle) { | |||
updateNavigationButtons(); | |||
} | |||
} | } | ||
// پردازش | // پردازش محتوا و حذف المانهای اضافی | ||
function | function processContent(html) { | ||
const tempDiv = document.createElement('div'); | const tempDiv = document.createElement('div'); | ||
tempDiv.innerHTML = html; | tempDiv.innerHTML = html; | ||
// حذف | // حذف تمام المانهای اضافی | ||
const elementsToRemove = tempDiv.querySelectorAll( | const elementsToRemove = tempDiv.querySelectorAll( | ||
'header, nav, .mw-header, .wiki-header, .header, #header, .navigation, .nav, .mw-nav, #mw-navigation' | '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' | ||
); | ); | ||
elementsToRemove.forEach(el => el.remove()); | elementsToRemove.forEach(el => el.remove()); | ||
// بهبود لینکها - تبدیل به لینکهای داخلی برنامه | |||
// بهبود لینکها - تبدیل به لینکهای داخلی | |||
const links = tempDiv.querySelectorAll('a[href*="pediabible.com"]'); | const links = tempDiv.querySelectorAll('a[href*="pediabible.com"]'); | ||
links.forEach(link => { | links.forEach(link => { | ||
| خط ۸۳۱: | خط ۷۹۵: | ||
const titleParam = url.searchParams.get('title'); | const titleParam = url.searchParams.get('title'); | ||
if (titleParam) { | if (titleParam) { | ||
link.href = 'javascript:void(0)'; | |||
link.setAttribute('data-wiki-title', titleParam); | link.setAttribute('data-wiki-title', titleParam); | ||
link.classList.add(' | link.classList.add('internal-link'); | ||
} | } | ||
}); | }); | ||
return tempDiv.innerHTML; | return tempDiv.innerHTML; | ||
} | } | ||
// تنظیم event | // تنظیم event listener برای لینکهای داخلی | ||
function | function setupInternalLinks() { | ||
const links = versesContainer.querySelectorAll('. | const links = versesContainer.querySelectorAll('.internal-link'); | ||
links.forEach(link => { | links.forEach(link => { | ||
| خط ۸۴۹: | خط ۸۱۴: | ||
if (title) { | if (title) { | ||
// بارگذاری صفحه جدید | // بارگذاری صفحه جدید با همان روش | ||
loadContent(title); | |||
} | } | ||
}); | }); | ||
}); | }); | ||
} | } | ||
| خط ۹۱۲: | خط ۸۳۳: | ||
currentChapter--; | currentChapter--; | ||
chapterSelect.value = currentChapter; | chapterSelect.value = currentChapter; | ||
loadContent(); | |||
} | } | ||
}); | }); | ||
| خط ۹۲۳: | خط ۸۴۴: | ||
currentChapter++; | currentChapter++; | ||
chapterSelect.value = currentChapter; | chapterSelect.value = currentChapter; | ||
loadContent(); | |||
} | } | ||
}); | }); | ||