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

편집 요약 없음
편집 요약 없음
3번째 줄: 3번째 줄:
     var passedTOC = false;
     var passedTOC = false;


     $('body').children().each(function() {
     $('h2, h3, h4, h5, h6').each(function() {
        var $el = $(this);
 
        // 목차 지나기
         if (!passedTOC) {
         if (!passedTOC) {
             if ($el.attr('id') === 'toc') {
             if ($(this).prevAll('#toc').length > 0) {
                 passedTOC = true;
                 passedTOC = true;
            } else {
                return;
             }
             }
            return; // 아직 목차 통과 전이면 스킵
         }
         }


         // 목차 지난 후 제목 찾기
         var numberLink = $('<a>')
        if ($el.is('h2, h3, h4, h5, h6')) {
            .attr('href', '#toc')
            var numberLink = $('<a>')
            .text(count + '. ')
                .attr('href', '#toc')
            .addClass('mw-link') // 목차 숫자 파란색 링크
                .text(count + '. ')
            .css({
                .addClass('mw-link') // 목차 숫자랑 똑같은 파란색 링크
                'text-decoration': 'none',
                .css({
                'margin-right': '5px'
                    'text-decoration': 'none',
            });
                    'margin-right': '5px'
                });


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

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