کتاب مقدس آنلاین: تفاوت میان نسخهها
ظاهر
بدون خلاصۀ ویرایش |
بدون خلاصۀ ویرایش |
||
| خط ۳۰: | خط ۳۰: | ||
padding: 0; | padding: 0; | ||
margin: 0; | margin: 0; | ||
} | |||
/* مخفی کردن هدرهای اضافی ویکی */ | |||
body > header:first-child, | |||
.wiki-header, | |||
.mw-header, | |||
#mw-header, | |||
#header, | |||
.header { | |||
display: none !important; | |||
} | } | ||
| خط ۱۷۳: | خط ۱۸۳: | ||
.content-display { | .content-display { | ||
width: 100%; | width: 100%; | ||
height: 650px; | |||
border: 1px solid var(--border-color); | border: 1px solid var(--border-color); | ||
border-radius: 6px; | border-radius: 6px; | ||
background: white; | background: white; | ||
} | } | ||
| خط ۲۹۱: | خط ۲۶۱: | ||
} | } | ||
. | .access-denied { | ||
text-align: center; | text-align: center; | ||
padding: 40px; | padding: 40px; | ||
color: | background: #fee; | ||
border-radius: 8px; | |||
border: 2px solid #f5c6cb; | |||
color: #721c24; | |||
margin-top: 20px; | |||
} | } | ||
. | .access-denied h3 { | ||
color: #721c24; | |||
margin-bottom: 15px; | margin-bottom: 15px; | ||
font-size: 1.5rem; | |||
} | } | ||
| خط ۳۴۶: | خط ۳۲۰: | ||
.content-display { | .content-display { | ||
height: 500px; | |||
} | } | ||
| خط ۳۶۳: | خط ۳۳۶: | ||
@media (max-width: 480px) { | @media (max-width: 480px) { | ||
.content-display { | .content-display { | ||
height: 450px; | |||
} | } | ||
| خط ۴۲۸: | خط ۴۰۰: | ||
<script> | <script> | ||
// 🔒 سیستم حفاظتی - بررسی دامنه مجاز | |||
const ALLOWED_DOMAINS = [ | |||
'pediabible.com', | |||
'www.pediabible.com', | |||
'localhost', | |||
'127.0.0.1' | |||
]; | |||
// تابع بررسی مجاز بودن دامنه | |||
function isDomainAllowed() { | |||
const currentDomain = window.location.hostname; | |||
console.log('🔍 بررسی دامنه:', currentDomain); | |||
// اگر روی فایل محلی هستیم، اجازه بده | |||
if (!currentDomain || currentDomain === '' || currentDomain === 'null') { | |||
console.log('✅ فایل محلی - مجاز'); | |||
return true; | |||
} | |||
const isAllowed = ALLOWED_DOMAINS.some(domain => { | |||
const match = currentDomain === domain || currentDomain.endsWith('.' + domain); | |||
if (match) { | |||
console.log(`✅ دامنه ${currentDomain} مجاز است`); | |||
} | |||
return match; | |||
}); | |||
if (!isAllowed) { | |||
console.log(`❌ دامنه ${currentDomain} غیرمجاز است`); | |||
} | |||
return isAllowed; | |||
} | |||
// تابع نمایش پیام دسترسی غیرمجاز | |||
function showAccessDenied() { | |||
const wrapper = document.getElementById('content-wrapper'); | |||
wrapper.innerHTML = ` | |||
<div class="access-denied"> | |||
<h3><i class="fas fa-ban"></i> دسترسی محدود شده</h3> | |||
<p>این صفحه فقط بر روی دامنه <strong>pediabible.com</strong> قابل دسترسی است.</p> | |||
<p>دامنه فعلی: <code>${window.location.hostname}</code></p> | |||
<p>لطفاً از <a href="https://www.pediabible.com" style="color: #721c24; text-decoration: underline;">سایت اصلی</a> بازدید کنید.</p> | |||
</div> | |||
`; | |||
} | |||
// تابع برای اضافه کردن target="_blank" به تمام لینکهای داخل iframe | |||
function addTargetBlankToIframeLinks(iframe) { | |||
if (!iframe) return; | |||
iframe.onload = function() { | |||
try { | |||
const iframeDoc = iframe.contentDocument || iframe.contentWindow.document; | |||
const links = iframeDoc.querySelectorAll('a'); | |||
links.forEach(link => { | |||
if (link.href && | |||
!link.href.startsWith('javascript:') && | |||
!link.href.startsWith('#')) { | |||
// برای تمام لینکها (داخلی و خارجی) target="_blank" اضافه کن | |||
link.setAttribute('target', '_blank'); | |||
link.setAttribute('rel', 'noopener noreferrer'); | |||
} | |||
}); | |||
console.log(`✅ ${links.length} لینک پردازش شد`); | |||
} catch (error) { | |||
console.log('⚠️ امکان دسترسی به محتوای iframe وجود ندارد (محدودیت CORS)'); | |||
} | |||
}; | |||
} | |||
// تابع اصلی بارگذاری برنامه | |||
function loadApplication() { | |||
console.log('🚀 شروع بارگذاری با بررسی امنیتی...'); | |||
if (!isDomainAllowed()) { | |||
console.log('❌ دسترسی غیرمجاز - نمایش پیام خطا'); | |||
showAccessDenied(); | |||
return; | |||
} | |||
console.log('✅ دامنه مجاز - بارگذاری برنامه اصلی'); | |||
// اگر دامنه مجاز باشد، برنامه اصلی بارگذاری میشود | |||
initializeBibleApp(); | |||
} | |||
// دادههای کامل کتابهای مقدس | // دادههای کامل کتابهای مقدس | ||
const bibleBooks = { | const bibleBooks = { | ||
| خط ۵۸۰: | خط ۶۴۰: | ||
name: 'ترجمه قدیم', | name: 'ترجمه قدیم', | ||
baseUrl: 'https://www.pediabible.com/index.php?title=', | baseUrl: 'https://www.pediabible.com/index.php?title=', | ||
// برای ترجمه قدیم از الگوی ساده با displayName استفاده میکنیم | |||
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=', | ||
// برای ترجمههای جدید از displayName + نام ترجمه استفاده میکنیم | |||
getPageTitle: function(bookDisplayName, chapter) { | getPageTitle: function(bookDisplayName, chapter) { | ||
return `${bookDisplayName} هزاره نو فصل ${chapter}`; | return `${bookDisplayName} هزاره نو فصل ${chapter}`; | ||
| خط ۷۰۱: | خط ۷۶۳: | ||
if (currentChapter) { | if (currentChapter) { | ||
displayChapterWithIframe(); | |||
} else { | } else { | ||
resetContent(); | resetContent(); | ||
| خط ۷۰۷: | خط ۷۶۹: | ||
}); | }); | ||
// نمایش محتوای | // نمایش فصل با iframe - فقط محتوای اصلی | ||
function displayChapterWithIframe() { | |||
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}`; | ||
// استفاده از الگوی مناسب برای هر ترجمه | // استفاده از الگوی مناسب برای هر ترجمه | ||
const pageTitle = translations[currentTranslation].getPageTitle(bookDisplayName, currentChapter); | const pageTitle = translations[currentTranslation].getPageTitle(bookDisplayName, currentChapter); | ||
// | // استفاده از action=render برای نمایش فقط محتوای اصلی | ||
const contentUrl = `${translations[currentTranslation].baseUrl}${encodeURIComponent(pageTitle)}`; | 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 = | wikiPageLink.href = `${translations[currentTranslation].baseUrl}${encodeURIComponent(pageTitle)}`; | ||
wikiPageLink.style.display = 'flex'; | wikiPageLink.style.display = 'flex'; | ||
// اضافه کردن ویژگی باز کردن لینکها در پنجره جدید | |||
const iframe = document.getElementById('content-iframe'); | |||
addTargetBlankToIframeLinks(iframe); | |||
updateNavigationButtons(); | updateNavigationButtons(); | ||
} | } | ||
| خط ۷۹۶: | خط ۸۱۸: | ||
currentChapter--; | currentChapter--; | ||
chapterSelect.value = currentChapter; | chapterSelect.value = currentChapter; | ||
displayChapterWithIframe(); | |||
} | } | ||
}); | }); | ||
| خط ۸۰۷: | خط ۸۲۹: | ||
currentChapter++; | currentChapter++; | ||
chapterSelect.value = currentChapter; | chapterSelect.value = currentChapter; | ||
displayChapterWithIframe(); | |||
} | } | ||
}); | }); | ||
| خط ۸۳۶: | خط ۸۵۸: | ||
} | } | ||
console.log('✅ برنامه کتاب مقدس بارگذاری شد'); | console.log('✅ برنامه کتاب مقدس روی دامنه مجاز بارگذاری شد'); | ||
} | } | ||
// شروع برنامه | // 🔒 شروع برنامه با بررسی امنیتی | ||
document.addEventListener('DOMContentLoaded', function() { | document.addEventListener('DOMContentLoaded', function() { | ||
console.log('🚀 شروع بارگذاری | console.log('🚀 شروع بارگذاری با بررسی امنیتی...'); | ||
loadApplication(); | |||
}); | |||
// 🔒 جلوگیری از دسترسی به توابع از کنسول | |||
Object.defineProperty(window, 'translations', { | |||
value: null, | |||
writable: false, | |||
configurable: false | |||
}); | }); | ||
</script> | </script> | ||
</body> | </body> | ||
</html> | </html> | ||