کتاب مقدس آنلاین: تفاوت میان نسخهها
ظاهر
بدون خلاصۀ ویرایش |
بدون خلاصۀ ویرایش |
||
| خط ۶: | خط ۶: | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> | <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> | ||
<style> | <style> | ||
/* استایلها همانند قبل */ | |||
:root { | :root { | ||
--primary-color: #2c3e50; | --primary-color: #2c3e50; | ||
| خط ۳۰: | خط ۳۱: | ||
padding: 0; | padding: 0; | ||
margin: 0; | margin: 0; | ||
} | } | ||
| خط ۳۵۸: | خط ۳۴۹: | ||
} | } | ||
.placeholder { | .placeholder { | ||
display: flex; | display: flex; | ||
| خط ۳۷۵: | خط ۳۶۵: | ||
} | } | ||
option { | option { | ||
direction: rtl; | direction: rtl; | ||
text-align: right; | text-align: right; | ||
} | |||
/* استایل برای محتوای ویکی */ | |||
.wiki-content { | |||
line-height: 1.8; | |||
font-size: 1.1rem; | |||
padding: 20px; | |||
} | |||
.wiki-content h1, | |||
.wiki-content h2, | |||
.wiki-content h3 { | |||
color: var(--primary-color); | |||
margin: 25px 0 15px 0; | |||
border-bottom: 1px solid var(--border-color); | |||
padding-bottom: 8px; | |||
} | |||
.wiki-content p { | |||
margin-bottom: 15px; | |||
text-align: justify; | |||
} | |||
.wiki-content .verse { | |||
margin: 10px 0; | |||
padding-right: 15px; | |||
border-right: 3px solid var(--border-color); | |||
} | } | ||
</style> | </style> | ||
| خط ۴۰۸: | خط ۴۲۴: | ||
]; | ]; | ||
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); | |||
}); | }); | ||
} | } | ||
function showAccessDenied() { | function showAccessDenied() { | ||
const wrapper = document.getElementById('content-wrapper'); | const wrapper = document.getElementById('content-wrapper'); | ||
| خط ۴۴۵: | خط ۴۴۶: | ||
</div> | </div> | ||
`; | `; | ||
} | } | ||
| خط ۵۳۶: | خط ۵۲۲: | ||
}; | }; | ||
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': { | ||
| خط ۶۱۵: | خط ۵۹۸: | ||
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 | return bookDisplayName + ' فصل ' + chapter; | ||
} | } | ||
}, | }, | ||
| خط ۶۲۲: | خط ۶۰۵: | ||
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 | return bookDisplayName + ' هزاره نو فصل ' + chapter; | ||
} | } | ||
}, | }, | ||
| خط ۶۲۹: | خط ۶۱۲: | ||
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 | return bookDisplayName + ' مژده فصل ' + chapter; | ||
} | } | ||
}, | }, | ||
| خط ۶۳۶: | خط ۶۱۹: | ||
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 | 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; | ||
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.innerHTML = '<option value="">انتخاب کتاب</option>'; | bookSelect.innerHTML = '<option value="">انتخاب کتاب</option>'; | ||
bibleBooks[currentTestament].forEach((book, index) | bibleBooks[currentTestament].forEach(function(book, index) { | ||
const option = document.createElement('option'); | const option = document.createElement('option'); | ||
option.value = index; | option.value = index; | ||
| خط ۷۰۲: | خط ۶۸۱: | ||
}); | }); | ||
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); | ||
| خط ۷۴۱: | خط ۷۱۸: | ||
}); | }); | ||
function displayChapterWithIframe() { | function displayChapterWithIframe() { | ||
const bookIndex = parseInt(currentBook); | const bookIndex = parseInt(currentBook); | ||
| خط ۷۵۱: | خط ۷۲۷: | ||
chapterTitle.textContent = translationName + ' - ' + bookName + ' - فصل ' + currentChapter; | chapterTitle.textContent = translationName + ' - ' + bookName + ' - فصل ' + currentChapter; | ||
const pageTitle = translations[currentTranslation].getPageTitle(bookDisplayName, currentChapter); | const pageTitle = translations[currentTranslation].getPageTitle(bookDisplayName, currentChapter); | ||
const contentUrl = translations[currentTranslation].baseUrl + encodeURIComponent(pageTitle) + '&action=render'; | const contentUrl = translations[currentTranslation].baseUrl + encodeURIComponent(pageTitle) + '&action=render'; | ||
// استفاده از sandbox برای جلوگیری از اجرای JavaScript | |||
versesContainer.innerHTML = ` | versesContainer.innerHTML = ` | ||
<iframe | <iframe | ||
| خط ۷۶۴: | خط ۷۳۸: | ||
frameborder="0" | frameborder="0" | ||
loading="lazy" | loading="lazy" | ||
sandbox="allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox" | |||
allowfullscreen> | allowfullscreen> | ||
</iframe> | </iframe> | ||
`; | `; | ||
wikiPageLink.href = translations[currentTranslation].baseUrl + encodeURIComponent(pageTitle); | wikiPageLink.href = translations[currentTranslation].baseUrl + encodeURIComponent(pageTitle); | ||
wikiPageLink.style.display = 'flex'; | wikiPageLink.style.display = 'flex'; | ||
updateNavigationButtons(); | updateNavigationButtons(); | ||
setupIframeLinkHandler(); | setupIframeLinkHandler(); | ||
} | } | ||
function setupIframeLinkHandler() { | function setupIframeLinkHandler() { | ||
const iframe = document.getElementById('content-iframe'); | const iframe = document.getElementById('content-iframe'); | ||
iframe.onload = function() { | iframe.onload = function() { | ||
try { | try { | ||
const iframeDoc = iframe.contentDocument || iframe.contentWindow.document; | const iframeDoc = iframe.contentDocument || iframe.contentWindow.document; | ||
const links = iframeDoc.querySelectorAll('a'); | const links = iframeDoc.querySelectorAll('a'); | ||
links.forEach(function(link) { | links.forEach(function(link) { | ||
if (link.href && link.href.includes('pediabible.com')) { | if (link.href && link.href.includes('pediabible.com')) { | ||
link.addEventListener('click', function(e) { | link.addEventListener('click', function(e) { | ||
e.preventDefault(); | e.preventDefault(); | ||
const url = new URL(this.href); | const url = new URL(this.href); | ||
const titleParam = url.searchParams.get('title'); | const titleParam = url.searchParams.get('title'); | ||
if (titleParam) { | if (titleParam) { | ||
const newUrl = translations[currentTranslation].baseUrl + titleParam + '&action=render'; | const newUrl = translations[currentTranslation].baseUrl + titleParam + '&action=render'; | ||
iframe.src = newUrl; | iframe.src = newUrl; | ||
wikiPageLink.href = translations[currentTranslation].baseUrl + titleParam; | wikiPageLink.href = translations[currentTranslation].baseUrl + titleParam; | ||
chapterTitle.textContent = 'صفحه: ' + decodeURIComponent(titleParam); | chapterTitle.textContent = 'صفحه: ' + decodeURIComponent(titleParam); | ||
} | } | ||
| خط ۸۱۴: | خط ۷۷۶: | ||
}); | }); | ||
} catch (error) { | } catch (error) { | ||
console.log(' | console.log('خطا در مدیریت لینکهای iframe:', error); | ||
} | } | ||
}; | }; | ||
| خط ۸۷۰: | خط ۸۳۲: | ||
resetContent(); | resetContent(); | ||
} | } | ||
} | } | ||
// | // شروع برنامه | ||
document.addEventListener('DOMContentLoaded', function() { | document.addEventListener('DOMContentLoaded', function() { | ||
if (!isDomainAllowed()) { | |||
showAccessDenied(); | |||
return; | |||
} | |||
initializeBibleApp(); | |||
}); | }); | ||
</script> | </script> | ||
</body> | </body> | ||
</html> | </html> | ||