کتاب مقدس آنلاین: تفاوت میان نسخهها
ظاهر
بدون خلاصۀ ویرایش |
بدون خلاصۀ ویرایش |
||
| خط ۳۰: | خط ۳۰: | ||
padding: 0; | padding: 0; | ||
margin: 0; | margin: 0; | ||
} | } | ||
| خط ۱۸۳: | خط ۱۷۳: | ||
.content-display { | .content-display { | ||
width: 100%; | width: 100%; | ||
height: | min-height: 600px; | ||
max-height: 700px; | |||
overflow-y: auto; | |||
border: 1px solid var(--border-color); | border: 1px solid var(--border-color); | ||
border-radius: 6px; | border-radius: 6px; | ||
background: white; | background: white; | ||
padding: 20px; | |||
line-height: 2; | |||
font-size: 1.1rem; | |||
} | |||
.content-display .verse { | |||
margin-bottom: 15px; | |||
padding-right: 15px; | |||
border-right: 3px solid var(--border-color); | |||
} | |||
.content-display .verse-number { | |||
background-color: var(--accent-color); | |||
color: white; | |||
padding: 2px 8px; | |||
border-radius: 50%; | |||
font-size: 0.8rem; | |||
margin-left: 5px; | |||
} | |||
.content-display a { | |||
color: var(--secondary-color); | |||
text-decoration: none; | |||
border-bottom: 1px dotted var(--secondary-color); | |||
transition: all 0.3s; | |||
} | |||
.content-display a:hover { | |||
color: var(--accent-color); | |||
border-bottom: 1px solid var(--accent-color); | |||
} | |||
.loading { | |||
text-align: center; | |||
padding: 40px; | |||
color: var(--accent-color); | |||
} | |||
.loading i { | |||
font-size: 2rem; | |||
margin-bottom: 15px; | |||
} | } | ||
| خط ۳۲۰: | خط ۳۵۳: | ||
.content-display { | .content-display { | ||
height: 500px; | min-height: 400px; | ||
max-height: 500px; | |||
padding: 15px; | |||
} | } | ||
| خط ۳۳۶: | خط ۳۷۱: | ||
@media (max-width: 480px) { | @media (max-width: 480px) { | ||
.content-display { | .content-display { | ||
height: 450px; | min-height: 350px; | ||
max-height: 450px; | |||
} | } | ||
| خط ۴۱۱: | خط ۴۴۷: | ||
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 currentDomain === domain || currentDomain.endsWith('.' + domain); | |||
}); | }); | ||
} | } | ||
| خط ۴۴۵: | خط ۴۶۸: | ||
</div> | </div> | ||
`; | `; | ||
} | } | ||
| خط ۵۱۰: | خط ۵۱۸: | ||
{ name: "لوقا", chapters: 24, displayName: "انجیل به قلم لوقا" }, | { name: "لوقا", chapters: 24, displayName: "انجیل به قلم لوقا" }, | ||
{ name: "یوحنا", chapters: 21, displayName: "انجیل به قلم یوحنا" }, | { name: "یوحنا", chapters: 21, displayName: "انجیل به قلم یوحنا" }, | ||
{ name: "اعمال ", chapters: 28, displayName: "اعمال " }, | { name: "اعمال", chapters: 28, displayName: "اعمال" }, | ||
{ name: "رومیان", chapters: 16, displayName: "رساله به رومیان" }, | { name: "رومیان", chapters: 16, displayName: "رساله به رومیان" }, | ||
{ name: "اول قرنتیان", chapters: 16, displayName: "رساله اول به قرنتیان" }, | { name: "اول قرنتیان", chapters: 16, displayName: "رساله اول به قرنتیان" }, | ||
| خط ۵۳۲: | خط ۵۴۰: | ||
{ name: "سوم یوحنا", chapters: 1, displayName: "رساله سوم یوحنا" }, | { name: "سوم یوحنا", chapters: 1, displayName: "رساله سوم یوحنا" }, | ||
{ name: "یهودا", chapters: 1, displayName: "رساله یهودا" }, | { name: "یهودا", chapters: 1, displayName: "رساله یهودا" }, | ||
{ name: "کتاب مکاشفه", chapters: 22, displayName: "کتاب مکاشفه " } | { name: "کتاب مکاشفه", chapters: 22, displayName: "کتاب مکاشفه" } | ||
] | ] | ||
}; | }; | ||
| خط ۶۱۴: | خط ۶۲۲: | ||
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}`; | ||
| خط ۷۳۷: | خط ۷۴۳: | ||
if (currentChapter) { | if (currentChapter) { | ||
displayChapterContent(); | |||
} else { | } else { | ||
resetContent(); | resetContent(); | ||
| خط ۷۴۳: | خط ۷۴۹: | ||
}); | }); | ||
// نمایش فصل با | // نمایش فصل با Fetch API | ||
function | async function displayChapterContent() { | ||
const bookIndex = parseInt(currentBook); | const bookIndex = parseInt(currentBook); | ||
const bookData = bibleBooks[currentTestament][bookIndex]; | const bookData = bibleBooks[currentTestament][bookIndex]; | ||
| خط ۷۵۲: | خط ۷۵۸: | ||
chapterTitle.textContent = `${translationName} - ${bookName} - فصل ${currentChapter}`; | chapterTitle.textContent = `${translationName} - ${bookName} - فصل ${currentChapter}`; | ||
// نمایش loading | |||
versesContainer.innerHTML = ` | |||
<div class="loading"> | |||
<i class="fas fa-spinner fa-spin"></i> | |||
<p>در حال بارگذاری محتوا...</p> | |||
</div> | |||
`; | |||
// استفاده از الگوی مناسب برای هر ترجمه | // استفاده از الگوی مناسب برای هر ترجمه | ||
const pageTitle = translations[currentTranslation].getPageTitle(bookDisplayName, currentChapter); | const pageTitle = translations[currentTranslation].getPageTitle(bookDisplayName, currentChapter); | ||
// استفاده از action=render برای | // استفاده از action=render برای دریافت فقط محتوای اصلی | ||
const contentUrl = `${translations[currentTranslation].baseUrl}${encodeURIComponent(pageTitle)}&action=render`; | const contentUrl = `${translations[currentTranslation].baseUrl}${encodeURIComponent(pageTitle)}&action=render`; | ||
versesContainer.innerHTML = ` | try { | ||
const response = await fetch(contentUrl); | |||
const html = await response.text(); | |||
class=" | // پردازش HTML و استخراج محتوای اصلی | ||
const processedContent = processWikiContent(html); | |||
// نمایش محتوا | |||
versesContainer.innerHTML = ` | |||
<div class="content-display"> | |||
${processedContent} | |||
</div> | |||
`; | |||
// اضافه کردن event listener به لینکها | |||
setupLinkHandlers(); | |||
} catch (error) { | |||
versesContainer.innerHTML = ` | |||
<div class="access-denied"> | |||
<h3><i class="fas fa-exclamation-triangle"></i> خطا در بارگذاری</h3> | |||
<p>مشکلی در بارگذاری محتوا پیش آمده است.</p> | |||
<p>لطفاً دوباره تلاش کنید.</p> | |||
</div> | |||
`; | |||
} | |||
// لینک صفحه کامل برای باز کردن در تب جدید | // لینک صفحه کامل برای باز کردن در تب جدید | ||
| خط ۷۷۴: | خط ۸۰۴: | ||
wikiPageLink.style.display = 'flex'; | wikiPageLink.style.display = 'flex'; | ||
updateNavigationButtons(); | updateNavigationButtons(); | ||
} | |||
// پردازش محتوای ویکی و حذف المانهای اضافی | |||
function processWikiContent(html) { | |||
const tempDiv = document.createElement('div'); | |||
tempDiv.innerHTML = html; | |||
// حذف هدرها و منوها | |||
const elementsToRemove = tempDiv.querySelectorAll( | |||
'header, nav, .mw-header, .wiki-header, .header, #header, .navigation, .nav, .mw-nav, #mw-navigation' | |||
); | |||
elementsToRemove.forEach(el => el.remove()); | |||
// حذف اسکریپتها | |||
const scripts = tempDiv.querySelectorAll('script'); | |||
scripts.forEach(script => script.remove()); | |||
// حذف استایلها | |||
const styles = tempDiv.querySelectorAll('style, link[rel="stylesheet"]'); | |||
styles.forEach(style => style.remove()); | |||
// بهبود لینکها - تبدیل به لینکهای داخلی | |||
const links = tempDiv.querySelectorAll('a[href*="pediabible.com"]'); | |||
links.forEach(link => { | |||
const url = new URL(link.href); | |||
const titleParam = url.searchParams.get('title'); | |||
if (titleParam) { | |||
link.setAttribute('data-wiki-title', titleParam); | |||
link.classList.add('wiki-internal-link'); | |||
} | |||
}); | |||
return tempDiv.innerHTML; | |||
} | } | ||
// | // تنظیم event handler برای لینکها | ||
function | function setupLinkHandlers() { | ||
const | const links = versesContainer.querySelectorAll('.wiki-internal-link'); | ||
links.forEach(link => { | |||
link.addEventListener('click', function(e) { | |||
e.preventDefault(); | |||
const | const title = this.getAttribute('data-wiki-title'); | ||
if (title) { | |||
// | // بارگذاری صفحه جدید | ||
loadWikiPage(title); | |||
} | |||
}); | |||
}); | |||
} | |||
// بارگذاری صفحه ویکی | |||
async function loadWikiPage(title) { | |||
chapterTitle.textContent = `صفحه: ${decodeURIComponent(title)}`; | |||
// نمایش loading | |||
versesContainer.innerHTML = ` | |||
<div class="loading"> | |||
<i class="fas fa-spinner fa-spin"></i> | |||
<p>در حال بارگذاری محتوا...</p> | |||
</div> | |||
`; | |||
const contentUrl = `${translations[currentTranslation].baseUrl}${title}&action=render`; | |||
try { | |||
const response = await fetch(contentUrl); | |||
const html = await response.text(); | |||
// پردازش HTML و استخراج محتوای اصلی | |||
const processedContent = processWikiContent(html); | |||
// نمایش محتوا | |||
versesContainer.innerHTML = ` | |||
<div class="content-display"> | |||
${processedContent} | |||
</div> | |||
} catch (error) { | `; | ||
// | |||
// اضافه کردن event listener به لینکها | |||
setupLinkHandlers(); | |||
}; | |||
} catch (error) { | |||
versesContainer.innerHTML = ` | |||
<div class="access-denied"> | |||
<h3><i class="fas fa-exclamation-triangle"></i> خطا در بارگذاری</h3> | |||
<p>مشکلی در بارگذاری محتوا پیش آمده است.</p> | |||
</div> | |||
`; | |||
} | |||
// بهروزرسانی لینک صفحه کامل | |||
wikiPageLink.href = `${translations[currentTranslation].baseUrl}${title}`; | |||
} | } | ||
| خط ۸۴۱: | خط ۹۱۲: | ||
currentChapter--; | currentChapter--; | ||
chapterSelect.value = currentChapter; | chapterSelect.value = currentChapter; | ||
displayChapterContent(); | |||
} | } | ||
}); | }); | ||
| خط ۸۵۲: | خط ۹۲۳: | ||
currentChapter++; | currentChapter++; | ||
chapterSelect.value = currentChapter; | chapterSelect.value = currentChapter; | ||
displayChapterContent(); | |||
} | } | ||
}); | }); | ||
| خط ۸۷۳: | خط ۹۴۴: | ||
function resetAll() { | function resetAll() { | ||
testamentSelect.disabled = true; | testamentSelect.disabled = true; | ||
testamentSelect. | testamentSelect.value = ''; | ||
bookSelect.disabled = true; | bookSelect.disabled = true; | ||
bookSelect.innerHTML = '<option value="">انتخاب کتاب</option>'; | bookSelect.innerHTML = '<option value="">انتخاب کتاب</option>'; | ||
| خط ۸۸۰: | خط ۹۵۱: | ||
resetContent(); | resetContent(); | ||
} | } | ||
} | } | ||
// | // شروع برنامه | ||
document.addEventListener('DOMContentLoaded', function() { | document.addEventListener('DOMContentLoaded', function() { | ||
if (!isDomainAllowed()) { | |||
showAccessDenied(); | |||
return; | |||
} | |||
initializeBibleApp(); | |||
}); | }); | ||
</script> | </script> | ||
</body> | </body> | ||
</html> | </html> | ||