Khác biệt giữa bản sửa đổi của “MediaWiki:Common.js”

Không có tóm lược sửa đổi
Không có tóm lược sửa đổi
 
(Không hiển thị 18 phiên bản của 2 người dùng ở giữa)
Dòng 1: Dòng 1:
if(!mw.config.get('wgUserId')){
//문서 역사보는 버튼 히든
var currentUrl = window.location.href;
if (!mw.config.get('wgUserId')) {
var commJs = currentUrl.includes('Common.js');
    var currentUrl = window.location.href;
var commCss = currentUrl.includes('Common.css');
    var commJs = currentUrl.includes('Common.js');
var vectorJs = currentUrl.includes('Vector.js');
    var commCss = currentUrl.includes('Common.css');
var vectorCss = currentUrl.includes('Vector.css');  
    var vectorJs = currentUrl.includes('Vector.js');
if(commJs || commCss || vectorJs || vectorCss){
    var vectorCss = currentUrl.includes('Vector.css');
window.location.href = '/index.php';
    if (commJs || commCss || vectorJs || vectorCss) {
        window.location.href = '/index.php';
    }
    // 도구 메뉴들 숨김(사이드바);
    $pTb = document.getElementById('p-tb');
    if ($pTb) $pTb.parentElement.removeChild($pTb);
 
    // 문서의 역사롤 봅니다. (hidden 시킴)
    var $lastModifiedBar = document.querySelector('.last-modified-bar');
    if ($lastModifiedBar) $lastModifiedBar.parentElement.removeChild($lastModifiedBar);
 
    //파일중복 메세지 제거
    var $duplicates = document.getElementById('mw-imagepage-section-duplicates');
    if ($duplicates) $duplicates.parentElement.removeChild($duplicates);
}else{
const el = document.querySelector('.mw-htmlform-ooui-wrapper');
if (el) {
  el.style.display = 'block';
}
}
// 도구 메뉴들 숨김(사이드바);
$pTb = document.getElementById('p-tb');
if ($pTb) $pTb.parentElement.removeChild($pTb);
// 문서의 역사롤 봅니다. (hidden 시킴)
var $lastModifiedBar = document.querySelector('.last-modified-bar');
if($lastModifiedBar) $lastModifiedBar.parentElement.removeChild($lastModifiedBar);
//파일중복 메세지 제거
var $duplicates = document.getElementById('mw-imagepage-section-duplicates');
if($duplicates) $duplicates.parentElement.removeChild($duplicates);
}
}


/* 이 자바스크립트 설정은 모든 문서, 모든 사용자에게 적용됩니다. */
//Naver Analytics
//Google Analytics
var NaverCdn = document.createElement('script');
var GoogleCdn = document.createElement('script');
NaverCdn.src = '//wcs.naver.net/wcslog.js';
GoogleCdn.src = 'https://www.googletagmanager.com/gtag/js?id=G-MN2WCQEXLW';
document.body.appendChild(NaverCdn);
document.body.appendChild(GoogleCdn);
if (!wcs_add) var wcs_add = {};
window.dataLayer = window.dataLayer || [];
wcs_add['wa'] = 'ab0e0ecee3c040';
function gtag() {
    dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', 'G-MN2WCQEXLW');


/* TOP 버튼 */
/* TOP 버튼 */
var topButton = document.createElement('div');
var topButton = document.createElement('div');
topButton.id = 'top-button';
topButton.id = 'top-button';
document.body.appendChild(topButton);
document.body.appendChild(topButton);
window.addEventListener('scroll', function (e) {
window.addEventListener('scroll', function (e) {
Dòng 56: Dòng 56:
     }
     }
});
});
/* 대문 섹션 토글 */
/* 대문 섹션 토글 */
if (mw.config.get('wgPageName') == '대문' || mw.config.get('wgPageName') == '대문테스트') {
if (mw.config.get('wgPageName') == '대문' || mw.config.get('wgPageName') == '대문테스트') {
    window.location.href = 'https://churchofgod.wiki/%ED%95%98%EB%82%98%EB%8B%98%EC%9D%98_%EA%B5%90%ED%9A%8C_%EC%A7%80%EC%8B%9D%EC%82%AC%EC%A0%84';
}
if (mw.config.get('wgPageName') == '하나님의_교회_지식사전') {
     var titles = document.querySelectorAll('.cog-box-title');
     var titles = document.querySelectorAll('.cog-box-title');
     for (var i = 0; i < titles.length; i++) {
     for (var i = 0; i < titles.length; i++) {
Dòng 71: Dòng 76:


/*모든 문서 */
/*모든 문서 */
if (mw.config.get('wgPageName').toLowerCase() == 'list_of_all_documents') {
if (mw.config.get('wgPageName').toLowerCase() == '모든_문서_목록') {
     var list = document.querySelectorAll('.mw-allpages-body li');
     var list = document.querySelectorAll('.mw-allpages-body li');
     for (var i = 0; i < list.length; i++) {
     for (var i = 0; i < list.length; i++) {
Dòng 83: Dòng 88:


/* 각주 팝업창 위치 보정 */
/* 각주 팝업창 위치 보정 */
var observer = new MutationObserver(function (mutationList) {
// MutationObserver를 사용하여 DOM 변경 사항 감지
    mutationList.forEach(function (mutation) {
var observer = new MutationObserver(function (mutationList){
mutationList.forEach(function(mutation){
         mutation.addedNodes.forEach(function (node) {
         mutation.addedNodes.forEach(function (node) {
            if (node.classList && node.classList.contains('mwe-popups')) {
if (node.classList && node.classList.contains('mwe-popups')) {
                requestAnimationFrame(function () {
requestAnimationFrame(function () {
                    var bodyLeft = document.body.getBoundingClientRect().left;
var bodyLeft = document.body.getBoundingClientRect().left;
                    var left = parseInt(window.getComputedStyle(node).left);
            var left = parseInt(window.getComputedStyle(node).left);
                    node.style.left = left - bodyLeft + 'px';
            node.style.left = left - bodyLeft + 'px';
                });
        });
            }
        }      
         });
         })
    });
})
});
})
// 감시할 대상 설정
// 감시할 대상 설정
observer.observe(document.body, {
observer.observe(document.body, {
    childList: true,
childList:true,
    subtree: true,
subtree:true
});
})


/* 우클릭 방지 */
/* 우클릭 방지
if (mw.config.get('wgUserName') == null) {
if (mw.config.get('wgUserName') == null) {
window.oncontextmenu = function (e) {
window.oncontextmenu = function (e) {
Dòng 111: Dòng 117:
};
};
}
}
*/
/* 존재하지 않는 문서 페이지의 '기록' 링크 삭제 */
/* 존재하지 않는 문서 페이지의 '기록' 링크 삭제 */
if (mw.config.get('wgUserId') == null && document.querySelector('.plainlinks a')) {
if (mw.config.get('wgUserId') == null && document.querySelector('.plainlinks a')) {
Dòng 148: Dòng 156:
             if (window.Kakao && $kakao) {
             if (window.Kakao && $kakao) {
                 // 사용할 앱의 JavaScript 키를 설정해 주세요.
                 // 사용할 앱의 JavaScript 키를 설정해 주세요.
                 Kakao.init('214de4d25d41a7b837b7bbeb75631c90');
                 Kakao.init('132b053079230ffc0880fd0a8155f444');
                 $kakao.children[0].style.display = 'inline';
                 $kakao.children[0].style.display = 'inline';
                 $kakao.onclick = sendScrap; // 카카오 Link 공유 API 사용
                 $kakao.onclick = sendScrap; // 카카오 Link 공유 API 사용
Dòng 162: Dòng 170:
                 $copy.addEventListener('click', function (e) {
                 $copy.addEventListener('click', function (e) {
                     copyStringToClipboard(decodeURI(location.href));
                     copyStringToClipboard(decodeURI(location.href));
                     alert('Saved the link to the clipboard.');
                     alert('링크를 클립보드에 저장했습니다.');
                     e.preventDefault();
                     e.preventDefault();
                 });
                 });
Dòng 197: Dòng 205:
     Kakao.Link.sendScrap({
     Kakao.Link.sendScrap({
         requestUrl: location.href,
         requestUrl: location.href,
         templateId: 91817,
         templateId: 82911,
         templateArgs: {
         templateArgs: {
             TITLE: og('title', 'Church of God Knowledge Encyclopedia'),
             TITLE: og('title', '하나님의 교회 지식사전'),
             DESC: og('description'),
             DESC: og('description'),
             THUMB: thumb(),
             THUMB: thumb(),
Dòng 287: Dòng 295:


//넘겨주기 문서를 숨깁니다.
//넘겨주기 문서를 숨깁니다.
var redirectList = document.querySelectorAll('.mw-parser-output li.allpagesredirect')
var redirectList = document.querySelectorAll('.mw-parser-output li.allpagesredirect');
for (var i=0; i < redirectList.length; i++){
for (var i = 0; i < redirectList.length; i++) {
redirectList[i].style.display = 'none';
    redirectList[i].style.display = 'none';
}
}


// 이미지문서에서 commons 라이센스 관련 링크를 숨긴다.
window.addEventListener('load', function () {
var $sharedUploadNotice = document.querySelector('.sharedUploadNotice p');
    if (mw.user.getId() == 0) {
if($sharedUploadNotice){
        var $tb = document.querySelector('.mw-portlet-tb');
$sharedUploadNotice.parentElement.removeChild($sharedUploadNotice);
        if ($tb) $tb.parentElement.removeChild($tb);
}
    }
// origin file 영역 숨김.
});
var $fullMedia = document.querySelector('.fullMedia p');
 
if($fullMedia){
/* GA4: single ID + language tagging (MediaWiki 1.42.3) */
$fullMedia.parentElement.removeChild($fullMedia);
(function () {
}
// 중복 로드 방지
if (window.__GA4_LOADED__) return;
window.__GA4_LOADED__ = true;
var GA_ID = 'G-YGT3D2Q9QW';
 
// 언어 결정: 가장 신뢰도 높은 wgContentLanguage, 없으면 경로 프리픽스로 보완
var pathLang = (location.pathname.split('/')[1] || '').toLowerCase();
var lang = (mw.config && mw.config.get('wgContentLanguage'))
        || (['en','es','ko'].includes(pathLang) ? pathLang : 'ko');
// <head>에 gtag 로더 삽입
var s = document.createElement('script');
s.async = true;
s.src = 'https://www.googletagmanager.com/gtag/js?id=' + encodeURIComponent(GA_ID);
document.head.appendChild(s);
window.dataLayer = window.dataLayer || [];
function gtag(){ dataLayer.push(arguments); }
window.gtag = gtag;
gtag('js', new Date());
// 🔹 자동 page_view 끄기
gtag('config', GA_ID, {
send_page_view: false,
});
// 언어를 사용자 속성으로 항상 전송(보고서에서 맞춤차원으로 필터)
gtag('set', 'user_properties', {
site_language: lang,
browser_language: navigator.language || navigator.userLanguage
});
gtag('event', 'page_view', {
    page_location: location.href,
    page_path: location.pathname + location.search,
    page_title: document.title,
    content_group: lang
});;
    console.log('gtag', lang, document.title, navigator.language || navigator.userLanguage);
})();
 
mw.loader.using(['jquery']).then(function () {
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'
};
    // 인터위키 언어 목록 선택자
const languageLabel = $('#p-lang h3 .vector-menu-heading-label').text().trim();
    const $items = $('.vector-menu-content-list .interlanguage-link a');
 
    $items.each(function () {
        const $a = $(this);
 
        const langCode = $a.attr('lang'); // en, es, vi, ne, pt …
        const autonym = $a.find('span').text(); // English, Español, Tiếng Việt …
        const koreanName = langMap[langCode];
 
        if (!koreanName) return; // 배열에 없는 언어는 스킵
 
        // 이미 한국어 형식이 적용된 경우 중복 적용 방지
        if (autonym.includes('(')) return;
 
        // 링크 텍스트 변경: "English" → "English (영어)"
        $a.find('span').text(`${autonym} (${koreanName})`);
    });
 
    // ----------------------------
    // 2. 변환된 인터랭을 헤더로 복사
    // ----------------------------
    const $interLangList = $('#p-lang .vector-menu-content-list');
    if ($interLangList.length === 0) return;
 
    var langDiv = document.getElementById('right-navigation');
    if (!langDiv) return;
 
    var navHTML =
        '<nav id="p-cactions" class="mw-portlet mw-portlet-cactions vector-menu-dropdown-noicon vector-menu vector-menu-dropdown" aria-labelledby="p-cactions-label" role="navigation">' +
        '<input type="checkbox" id="p-cactions-checkbox" role="button" aria-haspopup="true" class="vector-menu-checkbox" aria-labelledby="p-cactions-label">' +
        '<label id="p-cactions-label" class="vector-menu-heading">' +
        '<span class="select-language"></span>' +
        '<span class="vector-menu-heading-label">'+languageLabel+'</span>' +
        '</label>' +
        '<div class="vector-menu-content">' +
        '<ul class="vector-menu-content-list" id="header-lang-list"></ul>' +
        '</div>' +
        '</nav>';
 
    langDiv.insertAdjacentHTML('afterbegin', navHTML);
    const $headerList = $('#header-lang-list');
 
    // 변환된 인터랭 li 를 그대로 복사
    $interLangList.find('li.interlanguage-link').each(function () {
        const $a = $(this).find('a');
        const href = $a.attr('href');
        const title = $a.attr('title') || '';
        const text = $a.find('span').text();
 
        const newLi = '<li class="mw-list-item">' + '<a href="' + href + '" title="' + title + '">' + '<span>' + text + '</span>' + '</a>' + '</li>';
 
        $headerList.append(newLi);
    });
});