מדיה ויקי:Common.js: הבדלים בין גרסאות בדף
קפיצה לניווט
קפיצה לחיפוש
אין תקציר עריכה |
אין תקציר עריכה |
||
שורה 1: | שורה 1: | ||
// הקוד הקיים | |||
(function () { | (function () { | ||
var userLang = mw.config.get('wgUserLanguage'); | var userLang = mw.config.get('wgUserLanguage'); | ||
var pageName = mw.config.get('wgPageName'); | var pageName = mw.config.get('wgPageName'); | ||
if (pageName === 'רבי_יואל_טייטלבוים' && userLang === 'yi') { | if (pageName === 'רבי_יואל_טייטלבוים' && userLang === 'yi') { | ||
window.location.href = mw.util.getUrl('רבי_יואל_טייטלבוים/yi'); | window.location.href = mw.util.getUrl('רבי_יואל_טייטלבוים/yi'); | ||
} | } | ||
if (pageName === 'רבי_יואל_טייטלבוים/yi' && userLang === 'he') { | if (pageName === 'רבי_יואל_טייטלבוים/yi' && userLang === 'he') { | ||
window.location.href = mw.util.getUrl('רבי_יואל_טייטלבוים'); | window.location.href = mw.util.getUrl('רבי_יואל_טייטלבוים'); | ||
} | } | ||
})(); | })(); | ||
// הקוד החדש לתוכן העניינים | |||
document. | $(document).ready(function() { | ||
const toc = document.querySelector('#toc'); | const toc = document.querySelector('#toc'); | ||
const headers = document.querySelectorAll('h2, h3'); | const headers = document.querySelectorAll('h2, h3'); | ||
const tocLinks = document.querySelectorAll('#toc a'); | const tocLinks = document.querySelectorAll('#toc a'); | ||
window. | $(window).on('scroll', function() { | ||
const headerHeight = | const headerHeight = $('#firstHeading').outerHeight(); | ||
if (window. | if ($(window).scrollTop() > headerHeight) { | ||
toc.style.top = '0px'; | toc.style.top = '0px'; | ||
} else { | } else { | ||
שורה 30: | שורה 29: | ||
}); | }); | ||
window. | $(window).on('scroll', function() { | ||
let currentSection = ''; | let currentSection = ''; | ||
headers.forEach(header => { | headers.forEach(header => { | ||
const sectionTop = header.offsetTop; | const sectionTop = header.offsetTop; | ||
if (window. | if ($(window).scrollTop() >= sectionTop - 100) { | ||
currentSection = header.id; | currentSection = header.id; | ||
} | } | ||
}); | }); | ||
tocLinks.forEach(link => { | tocLinks.forEach(link => { | ||
link.classList.remove('toc-highlight'); | link.classList.remove('toc-highlight'); | ||
שורה 46: | שורה 47: | ||
}); | }); | ||
}); | }); | ||
גרסה מ־18:01, 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'); } if (pageName === 'רבי_יואל_טייטלבוים/yi' && userLang === 'he') { window.location.href = mw.util.getUrl('רבי_יואל_טייטלבוים'); } })(); // הקוד החדש לתוכן העניינים $(document).ready(function() { const toc = document.querySelector('#toc'); const headers = document.querySelectorAll('h2, h3'); const tocLinks = document.querySelectorAll('#toc a'); $(window).on('scroll', function() { const headerHeight = $('#firstHeading').outerHeight(); if ($(window).scrollTop() > headerHeight) { toc.style.top = '0px'; } else { toc.style.top = '220px'; } }); $(window).on('scroll', function() { let currentSection = ''; headers.forEach(header => { const sectionTop = header.offsetTop; if ($(window).scrollTop() >= 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'); } }); }); });