پرش به محتوا

کتابخانه دانشنامه کتاب مقدس: تفاوت میان نسخه‌ها

از دانشنامه کتاب مقدس
بدون خلاصۀ ویرایش
بدون خلاصۀ ویرایش
خط ۷: خط ۷:
     <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;
خط ۳۶۱: خط ۳۶۰:
         </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&origin=*`;
                 const apiUrl = `https://www.pediabible.com/api.php?action=query&list=categorymembers&cmtitle=${encodeURIComponent(categoryName)}&cmlimit=500&format=json`;
               
                const response = await fetch(apiUrl);
               
                if (!response.ok) {
                    throw new Error(`خطای HTTP: ${response.status}`);
                }
                  
                  
                 const data = await response.json();
                 const data = await fetchWithCorsFallback(apiUrl);
                  
                  
                 if (data.error) {
                 if (data.error) {
خط ۴۶۶: خط ۴۸۳:
         }
         }


         // تابع برای دریافت محتوای صفحه
         // تابع برای نمایش محتوای صفحه با iframe
         async function loadPageContent(pageTitle) {
         function displayPageWithIframe(pageTitle) {
             try {
             const contentUrl = `https://www.pediabible.com/index.php?title=${encodeURIComponent(pageTitle)}&printable=yes`;
                // دریافت محتوای صفحه به صورت HTML
           
                const apiUrl = `https://www.pediabible.com/api.php?action=parse&page=${encodeURIComponent(pageTitle)}&format=json&prop=text&origin=*`;
            return `
               
                 <iframe
                const response = await fetch(apiUrl);
                     src="${contentUrl}"
                  
                    class="content-display"
                if (!response.ok) {
                    frameborder="0"
                     throw new Error(`خطای HTTP: ${response.status}`);
                    loading="lazy"
                }
                     style="width: 100%; height: 650px; border: none;"
               
                     sandbox="allow-same-origin allow-scripts allow-popups allow-forms"
                const data = await response.json();
                     allowfullscreen>
               
                 </iframe>
                if (data.error) {
             `;
                     throw new Error(data.error.info);
                }
               
                if (data.parse && data.parse.text && data.parse.text['*']) {
                     return data.parse.text['*'];
                } else {
                     throw new Error('محتوای صفحه یافت نشد');
                 }
             } catch (error) {
                throw new Error('خطا در بارگذاری محتوا: ' + error.message);
            }
         }
         }


خط ۵۴۳: خط ۵۴۹:
                                 <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', async function() {
             pageSelect.addEventListener('change', function() {
                 currentPageIndex = parseInt(this.value);
                 currentPageIndex = parseInt(this.value);
                  
                  
                 if (!isNaN(currentPageIndex)) {
                 if (!isNaN(currentPageIndex)) {
                     await displayPageContent();
                     displayPageContent();
                 } else {
                 } else {
                     resetContent();
                     resetContent();
خط ۵۶۷: خط ۵۷۴:


             // نمایش محتوای صفحه
             // نمایش محتوای صفحه
             async function displayPageContent() {
             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);
خط ۵۸۰: خط ۵۸۷:
                 `;
                 `;
                  
                  
                 try {
                 // استفاده از setTimeout برای نمایش بهتر انیمیشن بارگذاری
                     const content = await loadPageContent(page.title);
                setTimeout(() => {
                   
                     versesContainer.innerHTML = displayPageWithIframe(page.title);
                    versesContainer.innerHTML = `
                        <div class="content-display">
                            <div class="wiki-content">${content}</div>
                        </div>
                    `;
                      
                      
                     // به روز رسانی لینک صفحه کامل
                     // به روز رسانی لینک صفحه کامل
خط ۵۹۳: خط ۵۹۵:
                     wikiPageLink.style.display = 'flex';
                     wikiPageLink.style.display = 'flex';
                      
                      
                } catch (error) {
                     updateNavigationButtons();
                     console.error('خطا در بارگذاری محتوا:', error);
                 }, 500);
                    versesContainer.innerHTML = `
                        <div class="error">
                            <i class="fas fa-exclamation-triangle"></i>
                            <p>${error.message}</p>
                        </div>
                    `;
                 }
               
                updateNavigationButtons();
             }
             }


خط ۶۱۱: خط ۶۰۴:
             }
             }


             prevPageBtn.addEventListener('click', async function() {
             prevPageBtn.addEventListener('click', function() {
                 if (currentPageIndex > 0) {
                 if (currentPageIndex > 0) {
                     currentPageIndex--;
                     currentPageIndex--;
                     pageSelect.value = currentPageIndex;
                     pageSelect.value = currentPageIndex;
                     await displayPageContent();
                     displayPageContent();
                 }
                 }
             });
             });


             nextPageBtn.addEventListener('click', async function() {
             nextPageBtn.addEventListener('click', function() {
                 if (currentPageIndex < currentPages.length - 1) {
                 if (currentPageIndex < currentPages.length - 1) {
                     currentPageIndex++;
                     currentPageIndex++;
                     pageSelect.value = currentPageIndex;
                     pageSelect.value = currentPageIndex;
                     await displayPageContent();
                     displayPageContent();
                 }
                 }
             });
             });

نسخهٔ ‏۱۰ اکتبر ۲۰۲۵، ساعت ۰۱:۰۸

<!DOCTYPE html> کتابخانه دانشنامه تخصصی

کتابخانه دانشنامه تخصصی

دسترسی به مجموعه کامل کتاب‌ها، مقالات و ترجمه‌های تخصصی

دسته‌بندی

صفحه

لطفاً دسته‌بندی و صفحه مورد نظر را انتخاب کنید

برای مطالعه محتوا، لطفاً ابتدا دسته‌بندی و سپس صفحه مورد نظر خود را انتخاب کنید.