کتابخانه دانشنامه کتاب مقدس: تفاوت میان نسخهها
ظاهر
بدون خلاصۀ ویرایش |
بدون خلاصۀ ویرایش |
||
خط ۷: | خط ۷: | ||
<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> | ||
/* تمام استایلهای CSS مانند قبل */ | |||
:root { | :root { | ||
--primary-color: #2c3e50; | --primary-color: #2c3e50; | ||
خط ۳۸: | خط ۳۹: | ||
} | } | ||
.app-header { | .app-header { | ||
text-align: center; | text-align: center; | ||
خط ۹۷: | خط ۹۷: | ||
} | } | ||
.selector-container { | .selector-container { | ||
display: grid; | display: grid; | ||
خط ۲۷۷: | خط ۲۷۶: | ||
} | } | ||
option { | option { | ||
direction: rtl; | direction: rtl; | ||
خط ۲۸۳: | خط ۲۸۱: | ||
} | } | ||
@media (max-width: 768px) { | @media (max-width: 768px) { | ||
.selector-container { | .selector-container { | ||
خط ۳۰۸: | خط ۳۰۵: | ||
<body> | <body> | ||
<div class="container"> | <div class="container"> | ||
<div class="app-header"> | <div class="app-header"> | ||
<nav class="breadcrumb"> | <nav class="breadcrumb"> | ||
خط ۳۴۴: | خط ۳۴۰: | ||
]; | ]; | ||
// تابع | // تابع JSONP برای دور زدن CORS | ||
function | function jsonpRequest(url) { | ||
return new Promise((resolve, reject) => { | |||
const callbackName = 'jsonp_callback_' + Math.round(100000 * Math.random()); | |||
const script = document.createElement('script'); | |||
window[callbackName] = function(data) { | |||
delete window[callbackName]; | |||
document.body.removeChild(script); | |||
if (data.error) { | |||
reject(new Error(data.error.info)); | |||
} else { | |||
resolve(data); | |||
} | |||
}; | |||
script.src = url + (url.includes('?') ? '&' : '?') + 'callback=' + callbackName; | |||
script.onerror = () => { | |||
delete window[callbackName]; | |||
document.body.removeChild(script); | |||
reject(new Error('JSONP request failed')); | |||
}; | |||
document.body.appendChild(script); | |||
}); | |||
} | |||
// تابع برای دریافت صفحات از رده با JSONP | |||
async function loadPagesFromCategory(categoryName) { | |||
try { | |||
const apiUrl = `https://www.pediabible.com/api.php?action=query&list=categorymembers&cmtitle=${encodeURIComponent(categoryName)}&cmlimit=500&format=json`; | |||
const data = await jsonpRequest(apiUrl); | |||
if (data.query && data.query.categorymembers) { | |||
return data.query.categorymembers | |||
.filter(member => member.ns === 0) | |||
.map(member => ({ | |||
title: member.title, | |||
displayName: member.title.replace(/_/g, ' '), | |||
pageId: member.pageid | |||
})); | |||
} else { | |||
throw new Error('دادهای دریافت نشد'); | |||
} | |||
} catch (error) { | |||
throw new Error('خطا در بارگذاری صفحات: ' + error.message); | |||
} | |||
} | } | ||
// | // تابع اصلی بارگذاری برنامه | ||
function initializeEncyclopediaApp() { | function initializeEncyclopediaApp() { | ||
const wrapper = document.getElementById('content-wrapper'); | const wrapper = document.getElementById('content-wrapper'); | ||
خط ۴۲۰: | خط ۴۶۱: | ||
// رویداد تغییر دستهبندی | // رویداد تغییر دستهبندی | ||
categorySelect.addEventListener('change', function() { | categorySelect.addEventListener('change', async function() { | ||
currentCategory = this.value; | currentCategory = this.value; | ||
if (currentCategory) { | if (currentCategory) { | ||
pageSelect.innerHTML = '<option value="">در حال بارگذاری...</option>'; | pageSelect.innerHTML = '<option value="">در حال بارگذاری...</option>'; | ||
pageSelect.disabled = true; | pageSelect.disabled = true; | ||
const category = categories.find(cat => cat.id === currentCategory); | const category = categories.find(cat => cat.id === currentCategory); | ||
try { | |||
currentPages = await loadPagesFromCategory(category.category); | |||
currentPages = | |||
pageSelect.disabled = false; | pageSelect.disabled = false; | ||
pageSelect.innerHTML = '<option value="">انتخاب صفحه</option>'; | pageSelect.innerHTML = '<option value="">انتخاب صفحه</option>'; | ||
خط ۴۷۲: | خط ۴۸۳: | ||
}); | }); | ||
console.log(`✅ ${currentPages.length} صفحه از رده ${ | console.log(`✅ ${currentPages.length} صفحه از رده ${category.category} بارگذاری شد`); | ||
} | } catch (error) { | ||
console.error('خطا در بارگذاری صفحات:', error); | |||
pageSelect.innerHTML = '<option value="">خطا در بارگذاری</option>'; | |||
pageSelect.disabled = true; | |||
versesContainer.innerHTML = ` | |||
<div class="loading"> | |||
<i class="fas fa-exclamation-triangle"></i> | |||
<p>${error.message}</p> | |||
</div> | |||
`; | |||
} | } | ||
resetContent(); | |||
} else { | |||
pageSelect.disabled = true; | pageSelect.disabled = true; | ||
pageSelect.innerHTML = '<option value="">انتخاب صفحه</option>'; | |||
resetContent(); | |||
} | } | ||
} | }); | ||
// رویداد تغییر صفحه | // رویداد تغییر صفحه | ||
خط ۵۰۹: | خط ۵۲۳: | ||
chapterTitle.textContent = `${category.name} - ${page.displayName}`; | chapterTitle.textContent = `${category.name} - ${page.displayName}`; | ||
const contentUrl = `https://www.pediabible.com/index.php?title=${encodeURIComponent(page.title)}&action=render`; | const contentUrl = `https://www.pediabible.com/index.php?title=${encodeURIComponent(page.title)}&action=render`; | ||
خط ۵۱۹: | خط ۵۳۲: | ||
`; | `; | ||
setTimeout(() => { | setTimeout(() => { | ||
versesContainer.innerHTML = ` | versesContainer.innerHTML = ` | ||
<iframe | <iframe | ||
src="${contentUrl}" | src="${contentUrl}" | ||
class="content-display" | class="content-display" | ||
خط ۵۳۴: | خط ۵۴۵: | ||
}, 500); | }, 500); | ||
wikiPageLink.href = `https://www.pediabible.com/index.php?title=${encodeURIComponent(page.title)}`; | wikiPageLink.href = `https://www.pediabible.com/index.php?title=${encodeURIComponent(page.title)}`; | ||
wikiPageLink.style.display = 'flex'; | wikiPageLink.style.display = 'flex'; | ||
خط ۵۷۵: | خط ۵۸۵: | ||
wikiPageLink.style.display = 'none'; | wikiPageLink.style.display = 'none'; | ||
} | } | ||
} | } | ||
خط ۵۸۲: | خط ۵۹۰: | ||
document.addEventListener('DOMContentLoaded', function() { | document.addEventListener('DOMContentLoaded', function() { | ||
console.log('🚀 شروع بارگذاری کتابخانه دانشنامه...'); | console.log('🚀 شروع بارگذاری کتابخانه دانشنامه...'); | ||
initializeEncyclopediaApp(); | |||
}); | }); | ||
</script> | </script> | ||
</body> | </body> | ||
</html> | </html> |
نسخهٔ ۱۰ اکتبر ۲۰۲۵، ساعت ۰۰:۴۸
<!DOCTYPE html>