מדיה ויקי:Common.js: הבדלים בין גרסאות בדף

מתוך אוצר מהרי''ט
קפיצה לניווט קפיצה לחיפוש
אין תקציר עריכה
אין תקציר עריכה
שורה 13: שורה 13:
     }
     }
})();
})();
<script>
document.addEventListener('DOMContentLoaded', function() {
    const toc = document.querySelector('#toc');
    const headers = document.querySelectorAll('h2, h3');
    const tocLinks = document.querySelectorAll('#toc a');
   
    window.addEventListener('scroll', function() {
        const headerHeight = document.querySelector('#firstHeading').offsetHeight;
       
        if (window.scrollY > headerHeight) {
            toc.style.top = '0px';
        } else {
            toc.style.top = '220px';
        }
    });
    window.addEventListener('scroll', function() {
        let currentSection = '';
        headers.forEach(header => {
            const sectionTop = header.offsetTop;
            if (window.scrollY >= sectionTop - 100) {
                currentSection = header.id;
            }
        });
        tocLinks.forEach(link => {
            link.classList.remove('toc-highlight');
            if (link.getAttribute('href').slice(1) === currentSection) {
                link.classList.add('toc-highlight');
            }
        });
    });
});
</script>

גרסה מ־18:00, 2 בפברואר 2025

(function () {
    var userLang = mw.config.get('wgUserLanguage'); // זיהוי שפת המשתמש
    var pageName = mw.config.get('wgPageName'); // שם הדף הנוכחי

    // אם הדף הנוכחי הוא "רבי יואל טייטלבוים" וכולנו נמצאים בשפת יידיש, מפנים לדף היידיש
    if (pageName === 'רבי_יואל_טייטלבוים' && userLang === 'yi') {
        window.location.href = mw.util.getUrl('רבי_יואל_טייטלבוים/yi'); // מפנה לדף ביידיש
    }

    // אם הדף הנוכחי הוא "רבי יואל טייטלבוים/yi" ושפת המשתמש היא עברית, מחזירים לדף העברי
    if (pageName === 'רבי_יואל_טייטלבוים/yi' && userLang === 'he') {
        window.location.href = mw.util.getUrl('רבי_יואל_טייטלבוים'); // מחזיר לדף העברי
    }
})();

<script>
document.addEventListener('DOMContentLoaded', function() {
    const toc = document.querySelector('#toc');
    const headers = document.querySelectorAll('h2, h3');
    const tocLinks = document.querySelectorAll('#toc a');
    
    window.addEventListener('scroll', function() {
        const headerHeight = document.querySelector('#firstHeading').offsetHeight;
        
        if (window.scrollY > headerHeight) {
            toc.style.top = '0px';
        } else {
            toc.style.top = '220px';
        }
    });

    window.addEventListener('scroll', function() {
        let currentSection = '';
        headers.forEach(header => {
            const sectionTop = header.offsetTop;
            if (window.scrollY >= sectionTop - 100) {
                currentSection = header.id;
            }
        });
        tocLinks.forEach(link => {
            link.classList.remove('toc-highlight');
            if (link.getAttribute('href').slice(1) === currentSection) {
                link.classList.add('toc-highlight');
            }
        });
    });
});
</script>