미디어위키:Common.js: 두 판 사이의 차이

편집 요약 없음
편집 요약 없음
1번째 줄: 1번째 줄:
$(document).ready(function() {
$(document).ready(function() {
     var count = 1;
     var count = 1;
     var passedToc = false;
     var passedTOC = false;


     $('*').each(function() {
     $('body').children().each(function() {
         var $this = $(this);
         var $el = $(this);


         if ($this.attr('id') === 'toc') {
        // 목차 지나기
            passedToc = true;
         if (!passedTOC) {
            if ($el.attr('id') === 'toc') {
                passedTOC = true;
            }
            return; // 아직 목차 통과 전이면 스킵
         }
         }


         // 목차를 지나간 후부터 제목 찾기
         // 목차 지난 후 제목 찾기
         if (passedToc && $this.is('h2, h3, h4, h5, h6')) {
         if ($el.is('h2, h3, h4, h5, h6')) {
             var backLink = $('<a>')
             var numberLink = $('<a>')
                 .attr('href', '#toc')
                 .attr('href', '#toc')
                 .text(count + '. ')
                 .text(count + '. ')
                 .addClass('mw-link') // 미디어위키 기본 파란 링크
                 .addClass('mw-link') // 목차 숫자랑 똑같은 파란색 링크
                 .css({
                 .css({
                     'text-decoration': 'none',
                     'text-decoration': 'none',
21번째 줄: 25번째 줄:
                 });
                 });


             $this.prepend(backLink);
             $el.prepend(numberLink);
             count++;
             count++;
         }
         }
     });
     });
});
});

2025년 4월 26일 (토) 21:36 판