|
|
| Dòng 1: |
Dòng 1: |
| /* All JavaScript here will be loaded for users of the MinervaNeue skin */
| | mw.loader.load('/resources/assets/common/minerva.js'); |
| function wikiLink(title) {
| |
| // 공백 → _ 치환 후 절대 경로 생성
| |
| return mw.config.get('wgServer') + '/vi/' + title.replace(/ /g, '_');
| |
| }
| |
| | |
| document
| |
| .querySelector('#mw-mf-page-left #p-navigation')
| |
| .insertAdjacentHTML(
| |
| 'afterend',
| |
| '<ul id="p-main-categories" class="recommended-open">' +
| |
| '<li class="title-recommended open"><a><span>Bài viết đề xuất</span></a><span class="ico-arrow"></span></li>' +
| |
| '<li class="recommended"><a href="' + wikiLink("Hội Thánh của Đức Chúa Trời Hiệp Hội Truyền Giáo Tin Lành Thế Giới") + '"><span>Hội Thánh của Đức Chúa Trời (Tài liệu)</span></a></li>' +
| |
| '<li class="recommended"><a href="' + wikiLink("An Xang Hồng") + '"><span>Đấng Christ An Xang Hồng</span></a></li>' +
| |
| '<li class="recommended"><a href="' + wikiLink("Đức Chúa Trời Mẹ") + '"><span>Đức Chúa Trời Mẹ</span></a></li>' +
| |
| '<li class="recommended"><a href="' + wikiLink("Ngày Sabát") + '"><span>Ngày Sabát</span></a></li>' +
| |
| '<li class="recommended"><a href="' + wikiLink("Lễ Vượt Qua") + '"><span>Lễ Vượt Qua</span></a></li>' +
| |
| '<li class="recommended"><a href="' + wikiLink("Tin Lành và giao ước mới") + '"><span>Tin Lành và giao ước mới</span></a></li>' +
| |
| '<li class="title-category"><a><span>Dò xem danh mục</span></a><span class="ico-arrow"></span></li>' +
| |
| '<li class="category"><a href="' + wikiLink("Category:Hội Thánh của Đức Chúa Trời") + '"><span>Hội Thánh của Đức Chúa Trời</span></a></li>' +
| |
| '<li class="category"><a href="' + wikiLink("Category:Ðức Chúa Trời Cha") + '"><span>Ðức Chúa Trời Cha</span></a></li>' +
| |
| '<li class="category"><a href="' + wikiLink("Category:Đức Chúa Trời Mẹ") + '"><span>Đức Chúa Trời Mẹ</span></a></li>' +
| |
| '<li class="category"><a href="' + wikiLink("Category:Tin Lành giao ước mới") + '"><span>Tin Lành giao ước mới</span></a></li>' +
| |
| '<li class="category"><a href="' + wikiLink("Category:Thường thức Kinh Thánh") + '"><span>Thường thức Kinh Thánh</span></a></li>' +
| |
| '<li class="category"><a href="' + wikiLink("Category:Vấn đề Kinh Thánh") + '"><span>Vấn đề Kinh Thánh</span></a></li>' +
| |
| '<li class="category"><a href="' + wikiLink("Category:Cống hiến cho xã hội") + '"><span>Cống hiến cho xã hội</span></a></li>' +
| |
| '<li class="category"><a href="' + wikiLink("Category:Hợp tác quốc tế") + '"><span>Hợp tác quốc tế</span></a></li>' +
| |
| '</ul>'
| |
| );
| |
| | |
| // Recommended Documents 토글
| |
| document.querySelector('#p-main-categories .title-recommended')
| |
| .addEventListener('click', function (event) {
| |
| event.stopPropagation(); // 사이드바 닫힘 방지
| |
| openList(this, '.recommended');
| |
| });
| |
| | |
| // Browse by Category 토글
| |
| document.querySelector('#p-main-categories .title-category')
| |
| .addEventListener('click', function (event) {
| |
| event.stopPropagation(); // 사이드바 닫힘 방지
| |
| openList(this, '.category');
| |
| });
| |
| | |
| function openList(titleLi, selector) {
| |
| titleLi.classList.toggle('open');
| |
| let next = titleLi.nextElementSibling;
| |
| while (next && !next.classList.contains('title-recommended') && !next.classList.contains('title-category')) {
| |
| if (next.matches(selector)) {
| |
| next.style.display = (next.style.display === 'none' || next.style.display === '') ? 'block' : 'none';
| |
| }
| |
| next = next.nextElementSibling;
| |
| }
| |
| }
| |
| | |
| // 유튜브 썸네일
| |
| document.querySelectorAll('iframe').forEach(function(iframe){
| |
| iframe.parentElement.classList.add('video-wrap');
| |
| });
| |
| | |
| mw.loader.using(['jquery']).then(function() { | |
| $(function() {
| |
| var modal = $('#myLayer');
| |
| var btn = $('#selectLanguage'); // jQuery 선택자 사용
| |
| var span = $('.close-button').first();
| |
| | |
| btn.click(function() {
| |
| modal.show();
| |
| });
| |
| | |
| span.click(function() {
| |
| modal.hide();
| |
| });
| |
| | |
| $(window).click(function(event) {
| |
| if ($(event.target).is(modal)) {
| |
| modal.hide();
| |
| }
| |
| });
| |
| });
| |
| });
| |
| function fillMobileLanguageFromInterwiki() {
| |
| var $mobileList = $('#mobile-language');
| |
| | |
| // 인터위키 링크 읽기
| |
| var $interwikiLinks = $('#p-lang ul.minerva-languages .interlanguage-link a');
| |
| if (!$interwikiLinks.length) return;
| |
| | |
| const langMap = {
| |
| 'ko': 'Tiếng Hàn',
| |
| 'en': 'Tiếng Anh',
| |
| 'es': 'Tiếng Tây Ban Nha',
| |
| 'vi': 'Tiếng Việt',
| |
| 'ne': 'Tiếng Nepal',
| |
| 'pt': 'Tiếng Bồ Đào Nha'
| |
| };
| |
| | |
| $mobileList.empty();
| |
| | |
| $interwikiLinks.each(function () {
| |
| var $a = $(this);
| |
| var href = $a.attr('href');
| |
| var langCode = $a.attr('lang');
| |
| var autonym = $a.find('span').text() || $a.text(); // English, Español ...
| |
| var korean = langMap[langCode] || '';
| |
| var label = korean ? (autonym + ' (' + korean + ')') : autonym;
| |
| | |
| var $li = $('<li>');
| |
| var $new = $('<a>', { href: href, text: label });
| |
| | |
| $li.append($new);
| |
| $mobileList.append($li);
| |
| });
| |
| }
| |
| | |
| mw.loader.using(['jquery']).then(function () {
| |
| $(function () {
| |
| // body DOM 변경 감시
| |
| var observer = new MutationObserver(function (mutations) {
| |
| mutations.forEach(function (m) {
| |
| $(m.addedNodes).each(function () {
| |
| var $node = $(this);
| |
| if ($node.is('#mobile-language') || $node.find('#mobile-language').length) {
| |
| fillMobileLanguageFromInterwiki();
| |
| }
| |
| });
| |
| });
| |
| });
| |
| | |
| observer.observe(document.body, {
| |
| childList: true,
| |
| subtree: true
| |
| });
| |
| | |
| // 혹시 이미 열려 있는 상태에서 로딩될 수도 있으니 한 번 시도
| |
| fillMobileLanguageFromInterwiki();
| |
| });
| |
| });
| |