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

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


    // 목차(div#toc) 다음부터 시작
     $('*').each(function() {
    var tocSeen = false;
 
     $('body').find('h2, h3, h4, h5, h6').each(function() {
         var $this = $(this);
         var $this = $(this);


         // 목차 이후 본문 제목부터 번호 매기기
         if ($this.attr('id') === 'toc') {
        if (!tocSeen) {
             passedToc = true;
            if ($this.prevAll('#toc').length > 0 || $this.parents('#toc').length > 0) {
                // 아직 목차 구간이다 => 패스
                return;
            }
             tocSeen = true;
         }
         }


         var backLink = $('<a>')
         // 목차를 지나간 후부터 제목 찾기
            .attr('href', '#toc')
        if (passedToc && $this.is('h2, h3, h4, h5, h6')) {
            .text(count + '. ')
            var backLink = $('<a>')
            .addClass('mw-link')
                .attr('href', '#toc')
            .css({
                .text(count + '. ')
                'text-decoration': 'none',
                .addClass('mw-link') // 미디어위키 기본 파란 링크 색
                'margin-right': '5px'
                .css({
            });
                    'text-decoration': 'none',
                    'margin-right': '5px'
                });


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

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