کتابخانه دانشنامه کتاب مقدس: تفاوت میان نسخهها
ظاهر
بدون خلاصۀ ویرایش |
بدون خلاصۀ ویرایش |
||
خط ۷: | خط ۷: | ||
<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; | ||
خط ۳۶۱: | خط ۳۶۰: | ||
</div> | </div> | ||
<div class="selector-container"> | <div class="selector-container"> | ||
<div class="selector-box"> | <div class="selector-box"> | ||
خط ۴۳۱: | خط ۴۲۹: | ||
} | } | ||
]; | ]; | ||
// راهحل جایگزین برای مشکل CORS | |||
async function fetchWithCorsFallback(url) { | |||
try { | |||
// ابتدا سعی میکنیم با fetch معمولی درخواست بزنیم | |||
const response = await fetch(url); | |||
if (response.ok) { | |||
return await response.json(); | |||
} | |||
} catch (error) { | |||
console.log('خطا در fetch معمولی، استفاده از روش جایگزین...'); | |||
} | |||
// اگر fetch معمولی کار نکرد، از proxy استفاده میکنیم | |||
const proxyUrl = `https://api.allorigins.win/raw?url=${encodeURIComponent(url)}`; | |||
try { | |||
const response = await fetch(proxyUrl); | |||
if (response.ok) { | |||
return await response.json(); | |||
} | |||
} catch (proxyError) { | |||
console.error('خطا در proxy:', proxyError); | |||
throw new Error('امکان اتصال به سرور وجود ندارد'); | |||
} | |||
} | |||
// تابع برای دریافت صفحات از رده | // تابع برای دریافت صفحات از رده | ||
خط ۴۳۶: | خط ۴۵۹: | ||
try { | try { | ||
// استفاده از API مدیاویکی برای دریافت صفحات رده | // استفاده از API مدیاویکی برای دریافت صفحات رده | ||
const apiUrl = `https://www.pediabible.com/api.php?action=query&list=categorymembers&cmtitle=${encodeURIComponent(categoryName)}&cmlimit=500&format=json | const apiUrl = `https://www.pediabible.com/api.php?action=query&list=categorymembers&cmtitle=${encodeURIComponent(categoryName)}&cmlimit=500&format=json`; | ||
const data = await | const data = await fetchWithCorsFallback(apiUrl); | ||
if (data.error) { | if (data.error) { | ||
خط ۴۶۶: | خط ۴۸۳: | ||
} | } | ||
// تابع برای | // تابع برای نمایش محتوای صفحه با iframe | ||
function displayPageWithIframe(pageTitle) { | |||
const contentUrl = `https://www.pediabible.com/index.php?title=${encodeURIComponent(pageTitle)}&printable=yes`; | |||
return ` | |||
<iframe | |||
src="${contentUrl}" | |||
class="content-display" | |||
frameborder="0" | |||
loading="lazy" | |||
style="width: 100%; height: 650px; border: none;" | |||
sandbox="allow-same-origin allow-scripts allow-popups allow-forms" | |||
allowfullscreen> | |||
</iframe> | |||
`; | |||
} | } | ||
خط ۵۴۳: | خط ۵۴۹: | ||
<i class="fas fa-exclamation-triangle"></i> | <i class="fas fa-exclamation-triangle"></i> | ||
<p>${error.message}</p> | <p>${error.message}</p> | ||
<p style="margin-top: 10px; font-size: 0.9rem;">لطفاً اتصال اینترنت خود را بررسی کنید</p> | |||
</div> | </div> | ||
`; | `; | ||
خط ۵۵۶: | خط ۵۶۳: | ||
// رویداد تغییر صفحه | // رویداد تغییر صفحه | ||
pageSelect.addEventListener('change', | pageSelect.addEventListener('change', function() { | ||
currentPageIndex = parseInt(this.value); | currentPageIndex = parseInt(this.value); | ||
if (!isNaN(currentPageIndex)) { | if (!isNaN(currentPageIndex)) { | ||
displayPageContent(); | |||
} else { | } else { | ||
resetContent(); | resetContent(); | ||
خط ۵۶۷: | خط ۵۷۴: | ||
// نمایش محتوای صفحه | // نمایش محتوای صفحه | ||
function displayPageContent() { | |||
const page = currentPages[currentPageIndex]; | const page = currentPages[currentPageIndex]; | ||
const category = categories.find(cat => cat.id === currentCategory); | const category = categories.find(cat => cat.id === currentCategory); | ||
خط ۵۸۰: | خط ۵۸۷: | ||
`; | `; | ||
// استفاده از setTimeout برای نمایش بهتر انیمیشن بارگذاری | |||
setTimeout(() => { | |||
versesContainer.innerHTML = displayPageWithIframe(page.title); | |||
// به روز رسانی لینک صفحه کامل | // به روز رسانی لینک صفحه کامل | ||
خط ۵۹۳: | خط ۵۹۵: | ||
wikiPageLink.style.display = 'flex'; | wikiPageLink.style.display = 'flex'; | ||
updateNavigationButtons(); | |||
}, 500); | |||
} | |||
} | } | ||
خط ۶۱۱: | خط ۶۰۴: | ||
} | } | ||
prevPageBtn.addEventListener('click', | prevPageBtn.addEventListener('click', function() { | ||
if (currentPageIndex > 0) { | if (currentPageIndex > 0) { | ||
currentPageIndex--; | currentPageIndex--; | ||
pageSelect.value = currentPageIndex; | pageSelect.value = currentPageIndex; | ||
displayPageContent(); | |||
} | } | ||
}); | }); | ||
nextPageBtn.addEventListener('click', | nextPageBtn.addEventListener('click', function() { | ||
if (currentPageIndex < currentPages.length - 1) { | if (currentPageIndex < currentPages.length - 1) { | ||
currentPageIndex++; | currentPageIndex++; | ||
pageSelect.value = currentPageIndex; | pageSelect.value = currentPageIndex; | ||
displayPageContent(); | |||
} | } | ||
}); | }); |
نسخهٔ ۱۰ اکتبر ۲۰۲۵، ساعت ۰۱:۰۸
<!DOCTYPE html>
دستهبندی
صفحه
لطفاً دستهبندی و صفحه مورد نظر را انتخاب کنید
برای مطالعه محتوا، لطفاً ابتدا دستهبندی و سپس صفحه مورد نظر خود را انتخاب کنید.