پرش به محتوا

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

از دانشنامه کتاب مقدس
بدون خلاصۀ ویرایش
بدون خلاصۀ ویرایش
خط ۲۷۷: خط ۲۷۷:
         }
         }


        /* استایل‌های مخصوص موبایل */
         @media (max-width: 768px) {
         @media (max-width: 768px) {
             .container {
             .container {
خط ۳۵۸: خط ۳۵۷:
         }
         }


        /* استایل برای حالت انتخاب نشده */
         .placeholder {
         .placeholder {
             display: flex;
             display: flex;
خط ۳۷۵: خط ۳۷۳:
         }
         }


        /* استایل برای راست‌چین کامل */
         option {
         option {
             direction: rtl;
             direction: rtl;
خط ۴۰۸: خط ۴۰۵:
         ];
         ];


        // تابع بررسی مجاز بودن دامنه
         function isDomainAllowed() {
         function isDomainAllowed() {
             const currentDomain = window.location.hostname;
             const currentDomain = window.location.hostname;
            console.log('🔍 بررسی دامنه:', currentDomain);
           
            // اگر روی فایل محلی هستیم، اجازه بده
             if (!currentDomain || currentDomain === '' || currentDomain === 'null') {
             if (!currentDomain || currentDomain === '' || currentDomain === 'null') {
                console.log('✅ فایل محلی - مجاز');
                 return true;
                 return true;
             }
             }
              
             return ALLOWED_DOMAINS.some(domain =>  
            const isAllowed = ALLOWED_DOMAINS.some(domain => {
                 currentDomain === domain || currentDomain.endsWith('.' + domain)
                 const match = currentDomain === domain || currentDomain.endsWith('.' + domain);
             );
                if (match) {
                    console.log(`✅ دامنه ${currentDomain} مجاز است`);
                }
                return match;
            });
           
             if (!isAllowed) {
                console.log(`❌ دامنه ${currentDomain} غیرمجاز است`);
            }
           
            return isAllowed;
         }
         }


        // تابع نمایش پیام دسترسی غیرمجاز
         function showAccessDenied() {
         function showAccessDenied() {
             const wrapper = document.getElementById('content-wrapper');
             const wrapper = document.getElementById('content-wrapper');
خط ۴۴۷: خط ۴۲۷:
         }
         }


        // تابع اصلی بارگذاری برنامه
        function loadApplication() {
            console.log('🚀 شروع بارگذاری با بررسی امنیتی...');
           
            if (!isDomainAllowed()) {
                console.log('❌ دسترسی غیرمجاز - نمایش پیام خطا');
                showAccessDenied();
                return;
            }
            console.log('✅ دامنه مجاز - بارگذاری برنامه اصلی');
            // اگر دامنه مجاز باشد، برنامه اصلی بارگذاری می‌شود
            initializeBibleApp();
        }
        // داده‌های کامل کتاب‌های مقدس
         const bibleBooks = {
         const bibleBooks = {
             old: [
             old: [
خط ۵۳۶: خط ۵۰۰:
         };
         };


         // 🔧 برنامه اصلی کتاب مقدس
         // ✅ تابع جدید: بازنویسی لینک‌های داخلی در iframe
        function interceptInternalLinks(iframe) {
            try {
                const doc = iframe.contentDocument || iframe.contentWindow.document;
                if (!doc) return;
 
                const links = doc.querySelectorAll('a[href]');
                links.forEach(link => {
                    const href = link.getAttribute('href');
                    if (!href) return;
 
                    // فقط لینک‌های داخلی به pediabible.com را هدف قرار بده
                    if (href.startsWith('/') || href.includes('pediabible.com')) {
                        link.addEventListener('click', function(e) {
                            e.preventDefault();
                            let url;
                            try {
                                url = href.startsWith('http') ? new URL(href) : new URL(href, window.location.origin);
                            } catch {
                                return;
                            }
 
                            let title = url.searchParams.get('title');
                            if (!title) {
                                // پشتیبانی از /index.php/عنوان
                                const path = url.pathname;
                                if (path.includes('/index.php/')) {
                                    title = path.split('/index.php/')[1];
                                } else if (path.startsWith('/')) {
                                    const parts = path.split('/').filter(p => p);
                                    if (parts.length > 0) title = parts[parts.length - 1];
                                }
                            }
 
                            if (title) {
                                const renderUrl = `${window.location.origin}/index.php?title=${encodeURIComponent(title)}&action=render`;
                                iframe.src = renderUrl;
                                document.getElementById('chapter-title').textContent = `مطلب: ${decodeURIComponent(title)}`;
                            }
                        });
                    }
                });
            } catch (err) {
                // اگر دسترسی نبود (مثلاً CORS)، خطا نده — فقط لاگ کن
                console.debug('دسترسی به iframe محدود شد (غیرضروری):', err.message);
            }
        }
 
         function initializeBibleApp() {
         function initializeBibleApp() {
             const wrapper = document.getElementById('content-wrapper');
             const wrapper = document.getElementById('content-wrapper');
              
              
            // ایجاد ساختار HTML برنامه
             wrapper.innerHTML = `
             wrapper.innerHTML = `
                 <div class="selector-container">
                 <div class="selector-container">
خط ۶۰۹: خط ۶۱۹:
             `;
             `;


            // داده‌های ترجمه‌های مختلف
             const translations = {
             const translations = {
                 'old': {
                 'old': {
                     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}`;
خط ۶۴۳: خط ۶۵۰:
             };
             };


            // عناصر DOM
             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;


             // رویداد تغییر ترجمه
             function resetContent() {
                chapterTitle.textContent = 'لطفاً ترجمه، کتاب و فصل مورد نظر را انتخاب کنید';
                versesContainer.innerHTML = `
                    <div class="instructions">
                        <div class="placeholder">
                            <i class="fas fa-book-open"></i>
                            <p>برای مطالعه کتاب مقدس، لطفاً ابتدا ترجمه، سپس عهد، کتاب و فصل مورد نظر خود را انتخاب کنید.</p>
                        </div>
                    </div>
                `;
                prevChapterBtn.disabled = true;
                nextChapterBtn.disabled = true;
                wikiPageLink.style.display = 'none';
            }
 
            function resetAll() {
                testamentSelect.disabled = true;
                testamentSelect.innerHTML = '<option value="">انتخاب عهد</option>';
                bookSelect.disabled = true;
                bookSelect.innerHTML = '<option value="">انتخاب کتاب</option>';
                chapterSelect.disabled = true;
                chapterSelect.innerHTML = '<option value="">انتخاب فصل</option>';
                resetContent();
            }
 
            function updateNavigationButtons() {
                const bookIndex = parseInt(currentBook);
                const chaptersCount = bibleBooks[currentTestament][bookIndex].chapters;
                prevChapterBtn.disabled = currentChapter <= 1;
                nextChapterBtn.disabled = currentChapter >= chaptersCount;
            }
 
            // ✅ نمایش فصل با iframe + فعال‌سازی لینک‌های هوشمند
            function displayChapterWithIframe() {
                const bookIndex = parseInt(currentBook);
                const bookData = bibleBooks[currentTestament][bookIndex];
                const bookName = bookData.name;
                const bookDisplayName = bookData.displayName;
                const translationName = translations[currentTranslation].name;
               
                chapterTitle.textContent = `${translationName} - ${bookName} - فصل ${currentChapter}`;
               
                const pageTitle = translations[currentTranslation].getPageTitle(bookDisplayName, currentChapter);
                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 = `${translations[currentTranslation].baseUrl}${encodeURIComponent(pageTitle)}`;
                wikiPageLink.style.display = 'flex';
                updateNavigationButtons();
 
                // ✅ فعال‌سازی لینک‌های داخلی بعد از بارگذاری iframe
                const iframe = document.getElementById('content-iframe');
                iframe.onload = function() {
                    interceptInternalLinks(iframe);
                };
            }
 
             translationSelect.addEventListener('change', function() {
             translationSelect.addEventListener('change', function() {
                 currentTranslation = this.value;
                 currentTranslation = this.value;
               
                 if (currentTranslation) {
                 if (currentTranslation) {
                     testamentSelect.disabled = false;
                     testamentSelect.disabled = false;
                     testamentSelect.value = '';
                     testamentSelect.value = '';
                     bookSelect.disabled = true;
                     resetAll();
                    bookSelect.innerHTML = '<option value="">انتخاب کتاب</option>';
                    chapterSelect.disabled = true;
                    chapterSelect.innerHTML = '<option value="">انتخاب فصل</option>';
                    resetContent();
                 } else {
                 } else {
                     resetAll();
                     resetAll();
خط ۶۷۷: خط ۷۴۳:
             });
             });


            // رویداد تغییر عهد
             testamentSelect.addEventListener('change', function() {
             testamentSelect.addEventListener('change', function() {
                 currentTestament = this.value;
                 currentTestament = this.value;
               
                 if (currentTestament) {
                 if (currentTestament) {
                     bookSelect.disabled = false;
                     bookSelect.disabled = false;
                     bookSelect.innerHTML = '<option value="">انتخاب کتاب</option>';
                     bookSelect.innerHTML = '<option value="">انتخاب کتاب</option>';
                   
                     bibleBooks[currentTestament].forEach((book, index) => {
                     bibleBooks[currentTestament].forEach((book, index) => {
                         const option = document.createElement('option');
                         const option = document.createElement('option');
خط ۶۹۱: خط ۷۵۴:
                         bookSelect.appendChild(option);
                         bookSelect.appendChild(option);
                     });
                     });
                   
                     chapterSelect.disabled = true;
                     chapterSelect.disabled = true;
                     chapterSelect.innerHTML = '<option value="">انتخاب فصل</option>';
                     chapterSelect.innerHTML = '<option value="">انتخاب فصل</option>';
                     resetContent();
                     resetContent();
                 } else {
                 } else {
                     bookSelect.disabled = true;
                     resetAll();
                    bookSelect.innerHTML = '<option value="">انتخاب کتاب</option>';
                    chapterSelect.disabled = true;
                    chapterSelect.innerHTML = '<option value="">انتخاب فصل</option>';
                    resetContent();
                 }
                 }
             });
             });


            // رویداد تغییر کتاب
             bookSelect.addEventListener('change', function() {
             bookSelect.addEventListener('change', function() {
                 currentBook = this.value;
                 currentBook = this.value;
               
                 if (currentBook !== '') {
                 if (currentBook !== '') {
                     chapterSelect.disabled = false;
                     chapterSelect.disabled = false;
                     chapterSelect.innerHTML = '<option value="">انتخاب فصل</option>';
                     chapterSelect.innerHTML = '<option value="">انتخاب فصل</option>';
                   
                     const bookIndex = parseInt(currentBook);
                     const bookIndex = parseInt(currentBook);
                     const chaptersCount = bibleBooks[currentTestament][bookIndex].chapters;
                     const chaptersCount = bibleBooks[currentTestament][bookIndex].chapters;
                   
                     for (let i = 1; i <= chaptersCount; i++) {
                     for (let i = 1; i <= chaptersCount; i++) {
                         const option = document.createElement('option');
                         const option = document.createElement('option');
خط ۷۲۱: خط ۷۷۵:
                         chapterSelect.appendChild(option);
                         chapterSelect.appendChild(option);
                     }
                     }
                   
                     prevChapterBtn.disabled = true;
                     prevChapterBtn.disabled = true;
                     nextChapterBtn.disabled = true;
                     nextChapterBtn.disabled = true;
خط ۷۳۲: خط ۷۸۵:
             });
             });


            // رویداد تغییر فصل
             chapterSelect.addEventListener('change', function() {
             chapterSelect.addEventListener('change', function() {
                 currentChapter = parseInt(this.value);
                 currentChapter = parseInt(this.value);
               
                 if (currentChapter) {
                 if (currentChapter) {
                     displayChapterWithIframe();
                     displayChapterWithIframe();
خط ۷۴۲: خط ۷۹۳:
                 }
                 }
             });
             });
            // نمایش فصل با iframe - فقط محتوای اصلی
            function displayChapterWithIframe() {
                const bookIndex = parseInt(currentBook);
                const bookData = bibleBooks[currentTestament][bookIndex];
                const bookName = bookData.name;
                const bookDisplayName = bookData.displayName;
                const translationName = translations[currentTranslation].name;
               
                chapterTitle.textContent = `${translationName} - ${bookName} - فصل ${currentChapter}`;
               
                // استفاده از الگوی مناسب برای هر ترجمه
                const pageTitle = translations[currentTranslation].getPageTitle(bookDisplayName, currentChapter);
               
                // استفاده از action=render برای نمایش فقط محتوای اصلی
                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 = `${translations[currentTranslation].baseUrl}${encodeURIComponent(pageTitle)}`;
                wikiPageLink.style.display = 'flex';
                updateNavigationButtons();
            }
            function updateNavigationButtons() {
                const bookIndex = parseInt(currentBook);
                const chaptersCount = bibleBooks[currentTestament][bookIndex].chapters;
               
                prevChapterBtn.disabled = currentChapter <= 1;
                nextChapterBtn.disabled = currentChapter >= chaptersCount;
            }


             prevChapterBtn.addEventListener('click', function() {
             prevChapterBtn.addEventListener('click', function() {
خط ۷۹۵: خط ۸۰۵:
                 const bookIndex = parseInt(currentBook);
                 const bookIndex = parseInt(currentBook);
                 const chaptersCount = bibleBooks[currentTestament][bookIndex].chapters;
                 const chaptersCount = bibleBooks[currentTestament][bookIndex].chapters;
               
                 if (currentChapter < chaptersCount) {
                 if (currentChapter < chaptersCount) {
                     currentChapter++;
                     currentChapter++;
خط ۸۰۳: خط ۸۱۲:
             });
             });


             function resetContent() {
             console.log('✅ برنامه کتاب مقدس روی دامنه مجاز بارگذاری شد');
                chapterTitle.textContent = 'لطفاً ترجمه، کتاب و فصل مورد نظر را انتخاب کنید';
        }
                versesContainer.innerHTML = `
                    <div class="instructions">
                        <div class="placeholder">
                            <i class="fas fa-book-open"></i>
                            <p>برای مطالعه کتاب مقدس، لطفاً ابتدا ترجمه، سپس عهد، کتاب و فصل مورد نظر خود را انتخاب کنید.</p>
                        </div>
                    </div>
                `;
                prevChapterBtn.disabled = true;
                nextChapterBtn.disabled = true;
                wikiPageLink.style.display = 'none';
            }


            function resetAll() {
        function loadApplication() {
                testamentSelect.disabled = true;
            if (!isDomainAllowed()) {
                 testamentSelect.innerHTML = '<option value="">انتخاب عهد</option>';
                 showAccessDenied();
                 bookSelect.disabled = true;
                 return;
                bookSelect.innerHTML = '<option value="">انتخاب کتاب</option>';
                chapterSelect.disabled = true;
                chapterSelect.innerHTML = '<option value="">انتخاب فصل</option>';
                resetContent();
             }
             }
 
             initializeBibleApp();
             console.log('✅ برنامه کتاب مقدس روی دامنه مجاز بارگذاری شد');
         }
         }


function interceptInternalLinks(iframe) {
    try {
        const doc = iframe.contentDocument || iframe.contentWindow.document;
        const links = doc.querySelectorAll('a[href*="title="]');
        links.forEach(link => {
            const href = link.getAttribute('href');
            if (!href || href.startsWith('http') && !href.includes('pediabible.com')) return;
            link.addEventListener('click', function(e) {
                e.preventDefault();
                let url;
                try {
                    url = href.startsWith('http') ? new URL(href) : new URL(href, location.origin);
                } catch {
                    return;
                }
                const title = url.searchParams.get('title') || decodeURIComponent(url.pathname.split('/').pop());
                if (title) {
                    const renderUrl = `${location.origin}/index.php?title=${encodeURIComponent(title)}&action=render`;
                    iframe.src = renderUrl;
                    document.getElementById('chapter-title').textContent = `مطلب: ${decodeURIComponent(title)}`;
                }
            });
        });
    } catch (err) {
        console.warn('دسترسی به iframe محدود شد:', err.message);
    }
}
        // 🔒 شروع برنامه با بررسی امنیتی
         document.addEventListener('DOMContentLoaded', function() {
         document.addEventListener('DOMContentLoaded', function() {
            console.log('🚀 شروع بارگذاری با بررسی امنیتی...');
             loadApplication();
             loadApplication();
         });
         });


        // 🔒 جلوگیری از دسترسی به توابع از کنسول
         Object.defineProperty(window, 'translations', {
         Object.defineProperty(window, 'translations', {
             value: null,
             value: null,

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

کتاب مقدس - مطالعه آنلاین

کتاب مقدس

مطالعه کتاب مقدس با ترجمه‌های مختلف