کتاب مقدس آنلاین: تفاوت میان نسخهها
ظاهر
بدون خلاصۀ ویرایش |
بدون خلاصۀ ویرایش |
||
| خط ۲۷۷: | خط ۲۷۷: | ||
} | } | ||
@media (max-width: 768px) { | @media (max-width: 768px) { | ||
.container { | .container { | ||
| خط ۳۵۸: | خط ۳۵۷: | ||
} | } | ||
.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 => | |||
currentDomain === domain || currentDomain.endsWith('.' + domain) | |||
); | |||
} | } | ||
function showAccessDenied() { | function showAccessDenied() { | ||
const wrapper = document.getElementById('content-wrapper'); | const wrapper = document.getElementById('content-wrapper'); | ||
| خط ۴۴۷: | خط ۴۲۷: | ||
} | } | ||
const bibleBooks = { | const bibleBooks = { | ||
old: [ | old: [ | ||
| خط ۵۳۶: | خط ۵۰۰: | ||
}; | }; | ||
// | // ✅ تابع جدید: بازنویسی لینکهای داخلی در iframe | ||
function interceptInternalLinks(iframe) { | |||
try { | |||
const doc = iframe.contentDocument || iframe.contentWindow.document; | |||
if (!doc) return; | |||
const links = doc.querySelectorAll('a[href]'); | |||
links.forEach(link => { | |||
const href = link.getAttribute('href'); | |||
if (!href) return; | |||
// فقط لینکهای داخلی به pediabible.com را هدف قرار بده | |||
if (href.startsWith('/') || href.includes('pediabible.com')) { | |||
link.addEventListener('click', function(e) { | |||
e.preventDefault(); | |||
let url; | |||
try { | |||
url = href.startsWith('http') ? new URL(href) : new URL(href, window.location.origin); | |||
} catch { | |||
return; | |||
} | |||
let title = url.searchParams.get('title'); | |||
if (!title) { | |||
// پشتیبانی از /index.php/عنوان | |||
const path = url.pathname; | |||
if (path.includes('/index.php/')) { | |||
title = path.split('/index.php/')[1]; | |||
} else if (path.startsWith('/')) { | |||
const parts = path.split('/').filter(p => p); | |||
if (parts.length > 0) title = 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) { | |||
// اگر دسترسی نبود (مثلاً CORS)، خطا نده — فقط لاگ کن | |||
console.debug('دسترسی به iframe محدود شد (غیرضروری):', err.message); | |||
} | |||
} | |||
function initializeBibleApp() { | function initializeBibleApp() { | ||
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': { | ||
name: 'ترجمه قدیم', | name: 'ترجمه قدیم', | ||
baseUrl: 'https://www.pediabible.com/index.php?title=', | baseUrl: 'https://www.pediabible.com/index.php?title=', | ||
getPageTitle: function(bookDisplayName, chapter) { | getPageTitle: function(bookDisplayName, chapter) { | ||
return `${bookDisplayName} فصل ${chapter}`; | return `${bookDisplayName} فصل ${chapter}`; | ||
| خط ۶۲۲: | خط ۶۳۰: | ||
name: 'هزاره نو', | name: 'هزاره نو', | ||
baseUrl: 'https://www.pediabible.com/index.php?title=', | baseUrl: 'https://www.pediabible.com/index.php?title=', | ||
getPageTitle: function(bookDisplayName, chapter) { | getPageTitle: function(bookDisplayName, chapter) { | ||
return `${bookDisplayName} هزاره نو فصل ${chapter}`; | return `${bookDisplayName} هزاره نو فصل ${chapter}`; | ||
| خط ۶۴۳: | خط ۶۵۰: | ||
}; | }; | ||
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; | ||
// | function resetContent() { | ||
chapterTitle.textContent = 'لطفاً ترجمه، کتاب و فصل مورد نظر را انتخاب کنید'; | |||
versesContainer.innerHTML = ` | |||
<div class="instructions"> | |||
<div class="placeholder"> | |||
<i class="fas fa-book-open"></i> | |||
<p>برای مطالعه کتاب مقدس، لطفاً ابتدا ترجمه، سپس عهد، کتاب و فصل مورد نظر خود را انتخاب کنید.</p> | |||
</div> | |||
</div> | |||
`; | |||
prevChapterBtn.disabled = true; | |||
nextChapterBtn.disabled = true; | |||
wikiPageLink.style.display = 'none'; | |||
} | |||
function resetAll() { | |||
testamentSelect.disabled = true; | |||
testamentSelect.innerHTML = '<option value="">انتخاب عهد</option>'; | |||
bookSelect.disabled = true; | |||
bookSelect.innerHTML = '<option value="">انتخاب کتاب</option>'; | |||
chapterSelect.disabled = true; | |||
chapterSelect.innerHTML = '<option value="">انتخاب فصل</option>'; | |||
resetContent(); | |||
} | |||
function updateNavigationButtons() { | |||
const bookIndex = parseInt(currentBook); | |||
const chaptersCount = bibleBooks[currentTestament][bookIndex].chapters; | |||
prevChapterBtn.disabled = currentChapter <= 1; | |||
nextChapterBtn.disabled = currentChapter >= chaptersCount; | |||
} | |||
// ✅ نمایش فصل با iframe + فعالسازی لینکهای هوشمند | |||
function displayChapterWithIframe() { | |||
const bookIndex = parseInt(currentBook); | |||
const bookData = bibleBooks[currentTestament][bookIndex]; | |||
const bookName = bookData.name; | |||
const bookDisplayName = bookData.displayName; | |||
const translationName = translations[currentTranslation].name; | |||
chapterTitle.textContent = `${translationName} - ${bookName} - فصل ${currentChapter}`; | |||
const pageTitle = translations[currentTranslation].getPageTitle(bookDisplayName, currentChapter); | |||
const contentUrl = `${translations[currentTranslation].baseUrl}${encodeURIComponent(pageTitle)}&action=render`; | |||
versesContainer.innerHTML = ` | |||
<iframe | |||
id="content-iframe" | |||
src="${contentUrl}" | |||
class="content-display" | |||
frameborder="0" | |||
loading="lazy" | |||
allowfullscreen> | |||
</iframe> | |||
`; | |||
wikiPageLink.href = `${translations[currentTranslation].baseUrl}${encodeURIComponent(pageTitle)}`; | |||
wikiPageLink.style.display = 'flex'; | |||
updateNavigationButtons(); | |||
// ✅ فعالسازی لینکهای داخلی بعد از بارگذاری iframe | |||
const iframe = document.getElementById('content-iframe'); | |||
iframe.onload = function() { | |||
interceptInternalLinks(iframe); | |||
}; | |||
} | |||
translationSelect.addEventListener('change', function() { | translationSelect.addEventListener('change', function() { | ||
currentTranslation = this.value; | currentTranslation = this.value; | ||
if (currentTranslation) { | if (currentTranslation) { | ||
testamentSelect.disabled = false; | testamentSelect.disabled = false; | ||
testamentSelect.value = ''; | testamentSelect.value = ''; | ||
resetAll(); | |||
} else { | } else { | ||
resetAll(); | resetAll(); | ||
| خط ۶۷۷: | خط ۷۴۳: | ||
}); | }); | ||
testamentSelect.addEventListener('change', function() { | testamentSelect.addEventListener('change', function() { | ||
currentTestament = this.value; | currentTestament = this.value; | ||
if (currentTestament) { | if (currentTestament) { | ||
bookSelect.disabled = false; | bookSelect.disabled = false; | ||
bookSelect.innerHTML = '<option value="">انتخاب کتاب</option>'; | bookSelect.innerHTML = '<option value="">انتخاب کتاب</option>'; | ||
bibleBooks[currentTestament].forEach((book, index) => { | bibleBooks[currentTestament].forEach((book, index) => { | ||
const option = document.createElement('option'); | const option = document.createElement('option'); | ||
| خط ۶۹۱: | خط ۷۵۴: | ||
bookSelect.appendChild(option); | bookSelect.appendChild(option); | ||
}); | }); | ||
chapterSelect.disabled = true; | chapterSelect.disabled = true; | ||
chapterSelect.innerHTML = '<option value="">انتخاب فصل</option>'; | chapterSelect.innerHTML = '<option value="">انتخاب فصل</option>'; | ||
resetContent(); | resetContent(); | ||
} else { | } else { | ||
resetAll(); | |||
} | } | ||
}); | }); | ||
bookSelect.addEventListener('change', function() { | bookSelect.addEventListener('change', function() { | ||
currentBook = this.value; | currentBook = this.value; | ||
if (currentBook !== '') { | if (currentBook !== '') { | ||
chapterSelect.disabled = false; | chapterSelect.disabled = false; | ||
chapterSelect.innerHTML = '<option value="">انتخاب فصل</option>'; | chapterSelect.innerHTML = '<option value="">انتخاب فصل</option>'; | ||
const bookIndex = parseInt(currentBook); | const bookIndex = parseInt(currentBook); | ||
const chaptersCount = bibleBooks[currentTestament][bookIndex].chapters; | const chaptersCount = bibleBooks[currentTestament][bookIndex].chapters; | ||
for (let i = 1; i <= chaptersCount; i++) { | for (let i = 1; i <= chaptersCount; i++) { | ||
const option = document.createElement('option'); | const option = document.createElement('option'); | ||
| خط ۷۲۱: | خط ۷۷۵: | ||
chapterSelect.appendChild(option); | chapterSelect.appendChild(option); | ||
} | } | ||
prevChapterBtn.disabled = true; | prevChapterBtn.disabled = true; | ||
nextChapterBtn.disabled = true; | nextChapterBtn.disabled = true; | ||
| خط ۷۳۲: | خط ۷۸۵: | ||
}); | }); | ||
chapterSelect.addEventListener('change', function() { | chapterSelect.addEventListener('change', function() { | ||
currentChapter = parseInt(this.value); | currentChapter = parseInt(this.value); | ||
if (currentChapter) { | if (currentChapter) { | ||
displayChapterWithIframe(); | displayChapterWithIframe(); | ||
| خط ۷۴۲: | خط ۷۹۳: | ||
} | } | ||
}); | }); | ||
prevChapterBtn.addEventListener('click', function() { | prevChapterBtn.addEventListener('click', function() { | ||
| خط ۷۹۵: | خط ۸۰۵: | ||
const bookIndex = parseInt(currentBook); | const bookIndex = parseInt(currentBook); | ||
const chaptersCount = bibleBooks[currentTestament][bookIndex].chapters; | const chaptersCount = bibleBooks[currentTestament][bookIndex].chapters; | ||
if (currentChapter < chaptersCount) { | if (currentChapter < chaptersCount) { | ||
currentChapter++; | currentChapter++; | ||
| خط ۸۰۳: | خط ۸۱۲: | ||
}); | }); | ||
console.log('✅ برنامه کتاب مقدس روی دامنه مجاز بارگذاری شد'); | |||
} | |||
function loadApplication() { | |||
if (!isDomainAllowed()) { | |||
showAccessDenied(); | |||
return; | |||
} | } | ||
initializeBibleApp(); | |||
} | } | ||
document.addEventListener('DOMContentLoaded', function() { | document.addEventListener('DOMContentLoaded', function() { | ||
loadApplication(); | loadApplication(); | ||
}); | }); | ||
Object.defineProperty(window, 'translations', { | Object.defineProperty(window, 'translations', { | ||
value: null, | value: null, | ||