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

누리위키, 온 누리의 백과사전
(새 문서: 이 자바스크립트 설정은 모든 문서, 모든 사용자에게 적용됩니다.: // Overwriting deprecated functions that have a follower that (also) accepts the same sy...)
 
잔글
 
(같은 사용자의 중간 판 5개는 보이지 않습니다)
1번째 줄: 1번째 줄:
 
/* 이 자바스크립트 설정은 모든 문서, 모든 사용자에게 적용됩니다. */
 
/* 이 자바스크립트 설정은 모든 문서, 모든 사용자에게 적용됩니다. */
  
// Overwriting deprecated functions that have a follower that (also) accepts the same syntax:
+
mw.loader.using( ['mediawiki.user', 'mediawiki.util', 'mediawiki.notify'] ).done( function () {
// from [[commons:MediaWiki:Common.js]]
+
/* Begin of mw.loader.using callback */
window.addPortletLink = mw.util.addPortletLink;
 
window.getParamValue = mw.util.getParamValue;
 
  
// Import more specific scripts if necessary
+
/**
 +
* Main Page layout fixes
 +
*
 +
* Description: Adds an additional link to the complete list of languages available.
 +
* Maintainers: [[User:AzaToth]], [[User:R. Koot]], [[User:Alex Smotrov]]
 +
*/
 +
if ( mw.config.get( 'wgPageName' ) === '누리위키:대문' || mw.config.get( 'wgPageName' ) === '누리위키토론:대문' ) {
 +
$( function () {
 +
mw.util.addPortletLink( 'p-lang', '//meta.wikimedia.org/wiki/List_of_Wikipedias/ko',
 +
'전체 목록', 'interwiki-completelist', '누리위키 전체 목록' );
 +
} );
 +
}
  
if( wgNamespaceNumber == 6 ) {
+
/**
    importScript('MediaWiki:Common.js/file.js');
+
* Redirect User:Name/skin.js and skin.css to the current skin's pages
 +
* (unless the 'skin' page really exists)
 +
* @source: http://www.mediawiki.org/wiki/Snippets/Redirect_skin.js
 +
* @rev: 2
 +
*/
 +
if ( mw.config.get( 'wgArticleId' ) === 0 && mw.config.get( 'wgNamespaceNumber' ) === 2 ) {
 +
var titleParts = mw.config.get( 'wgPageName' ).split( '/' );
 +
/* Make sure there was a part before and after the slash
 +
  and that the latter is 'skin.js' or 'skin.css' */
 +
if ( titleParts.length == 2 ) {
 +
var userSkinPage = titleParts.shift() + '/' + mw.config.get( 'skin' );
 +
if ( titleParts.slice( -1 ) == 'skin.js' ) {
 +
window.location.href = mw.util.getUrl( userSkinPage + '.js' );
 +
} else if ( titleParts.slice( -1 ) == 'skin.css' ) {
 +
window.location.href = mw.util.getUrl( userSkinPage + '.css' );
 +
}
 +
}
 
}
 
}
 +
 +
/**
 +
* Map addPortletLink to mw.util
 +
* @deprecated: Use mw.util.addPortletLink instead.
 +
*/
 +
mw.log.deprecate( window, 'addPortletLink', mw.util.addPortletLink, 'Use mw.util.addPortletLink instead' );
 +
 +
/**
 +
* Extract a URL parameter from the current URL
 +
* @deprecated: Use mw.util.getParamValue with proper escaping
 +
*/
 +
mw.log.deprecate( window, 'getURLParamValue', mw.util.getParamValue, 'Use mw.util.getParamValue instead' );
 +
 +
/**
 +
* Test if an element has a certain class
 +
* @deprecated:  Use $(element).hasClass() instead.
 +
*/
 +
mw.log.deprecate( window, 'hasClass', function ( element, className ) {
 +
return $( element ).hasClass( className );
 +
}, 'jQuery.hasClass()를 대신 사용하십시오' );
 
   
 
   
/* 관리자용 css/js 불러오기.
+
/**
  * [[en:MediaWiki:Common.js]]에서.
+
  * @source www.mediawiki.org/wiki/Snippets/Load_JS_and_CSS_by_URL
  * 관리자일 경우 [[MediaWiki:Sysop.js]]를 불러오는 기능입니다.
+
  * @rev 6
 
  */
 
  */
if ( $.inArray( 'sysop', wgUserGroups) > -1 ) {
+
var extraCSS = mw.util.getParamValue( 'withCSS' ),
importStylesheet('MediaWiki:Sysop.css');
+
extraJS = mw.util.getParamValue( 'withJS' );
  if ( !window.disableSysopJS ) {
+
 
  $(function(){
+
if ( extraCSS ) {
  importScript('MediaWiki:Sysop.js');
+
if ( extraCSS.match( /^(MediaWiki|미디어위키):[^&<>=%#]*\.css$/ ) ) {
  });
+
mw.loader.load( '/w/index.php?title=' + extraCSS + '&action=raw&ctype=text/css', 'text/css' );
}
+
} else {
 +
mw.notify( '미디어위키 이름공간의 문서만 허용됩니다.', { title: '유효하지 않은 withCSS 값' } );
 +
}
 +
}
 +
   
 +
if ( extraJS ) {
 +
if ( extraJS.match( /^(MediaWiki|미디어위키):[^&<>=%#]*\.js$/ ) ) {
 +
mw.loader.load( '/w/index.php?title=' + extraJS + '&action=raw&ctype=text/javascript' );
 +
} else {
 +
mw.notify( '미디어위키 이름공간의 문서만 허용됩니다.', { title: '유효하지 않은 withJS 값' } );
 +
}
 
}
 
}
  
/* from en: */
+
/* 인터랙티브 지도. 영어 위키백과에서 가져옴. -- [[사용자:ChongDae]] 2010년 3월 28일 (일) 02:08 (KST) */
/* Test if an element has a certain class
+
/**
 +
* WikiMiniAtlas
 
  *
 
  *
  * @deprecatedUse $(element).hasClass() instead.
+
  * Description: WikiMiniAtlas is a popup click and drag world map.
 +
*              This script causes all of our coordinate links to display the WikiMiniAtlas popup button.
 +
*              The script itself is located on meta because it is used by many projects.
 +
*              See [[Meta:WikiMiniAtlas]] for more information.
 +
* Note - use of this service is recommended to be repalced with mw:Help:Extension:Kartographer
 +
  */
 +
( function () {
 +
var require_wikiminiatlas = false;
 +
var coord_filter = /geohack/;
 +
$( function () {
 +
$( 'a.external.text' ).each( function( key, link ) {
 +
if ( link.href && coord_filter.exec( link.href ) ) {
 +
require_wikiminiatlas = true;
 +
// break from loop
 +
return false;
 +
}
 +
} );
 +
if ( $( 'div.kmldata' ).length ) {
 +
require_wikiminiatlas = true;
 +
}
 +
if ( require_wikiminiatlas ) {
 +
mw.loader.load( '//meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js&action=raw&ctype=text/javascript' );
 +
}
 +
} );
 +
} )();
 +
 
 +
/**
 +
* Collapsible tables; reimplemented with mw-collapsibe
 +
* Styling is also in place to avoid FOUC
 +
*
 +
* Allows tables to be collapsed, showing only the header. See [[Help:Collapsing]].
 +
* @version 3.0.0 (2018-05-20)
 +
* @source https://www.mediawiki.org/wiki/MediaWiki:Gadget-collapsibleTables.js
 +
* @author [[User:R. Koot]]
 +
* @author [[User:Krinkle]]
 +
* @author [[User:TheDJ]]
 +
* @deprecated Since MediaWiki 1.20: Use class="mw-collapsible" instead which
 +
* is supported in MediaWiki core. Shimmable since MediaWiki 1.32
 
  */
 
  */
+
function makeCollapsibleMwCollapsible( $content ) {
var hasClass = (function () {
+
var $tables = $content
    var reCache = {};
+
.find( 'table.collapsible:not(.mw-collapsible)' )
    return function (element, className) {
+
.addClass( 'mw-collapsible' );
        return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className);
+
 
    };
+
$.each( $tables, function( index, table ) {
})();
+
// mw.log.warn( '이 문서는 구식 클래스 collapsible을 사용하고 있습니다. mw-collapsible로 변경해 주십시오.');
 +
if( $( table ).hasClass( 'collapsed') ) {
 +
$( table ).addClass( 'mw-collapsed' );
 +
// mw.log.warn( '이 문서는 구식 클래스 collapsed를 사용하고 있습니다. mw-collapsed로 변경해 주십시오.');
 +
}
 +
} );
 +
if( $tables.length > 0 ) {
 +
mw.loader.using( 'jquery.makeCollapsible' ).then( function() {
 +
$tables.makeCollapsible();
 +
} );
 +
}
 +
}
 +
mw.hook( 'wikipage.content' ).add( makeCollapsibleMwCollapsible );
  
/* ([[위키백과:관리자 요청/2007년 5월#스크립트 추가 요청]]) */
+
/**
/** Collapsible tables *********************************************************
+
* Add support to mw-collapsible for autocollapse, innercollapse and outercollapse
 
  *
 
  *
  * Description: Allows tables to be collapsed, showing only the header. See
+
  * Maintainers: TheDJ
*              [[:en:Wikipedia:NavFrame]].
 
Maintainers: [[:en:User:R. Koot]]
 
 
  */
 
  */
+
function mwCollapsibleSetup( $collapsibleContent ) {
var autoCollapse = 2;
+
var $element,
var collapseCaption = "숨기기";
+
$toggle,
var expandCaption = "보이기";
+
autoCollapseThreshold = 2;
+
$.each( $collapsibleContent, function (index, element) {
function collapseTable( tableIndex ){
+
$element = $( element );
    var Button = document.getElementById( "collapseButton" + tableIndex );
+
if ( $element.hasClass( 'collapsible' ) ) {
    var Table = document.getElementById( "collapsibleTable" + tableIndex );
+
$element.find('tr:first > th:first').prepend( $element.find('tr:first > * > .mw-collapsible-toggle'));
+
}
    if ( !Table || !Button ) {
+
if ( $collapsibleContent.length >= autoCollapseThreshold && $element.hasClass( 'autocollapse' ) ) {
        return false;
+
$element.data( 'mw-collapsible' ).collapse();
    }
+
} else if ( $element.hasClass( 'innercollapse' ) ) {
+
if ( $element.parents( '.outercollapse' ).length > 0 ) {
    var Rows = Table.rows;
+
$element.data( 'mw-collapsible' ).collapse();
+
}
    if ( Button.firstChild.data == collapseCaption ) {
+
}
        for ( var i = 1; i < Rows.length; i++ ) {
+
// because of colored backgrounds, style the link in the text color
            Rows[i].style.display = "none";
+
// to ensure accessible contrast
        }
+
$toggle = $element.find( '.mw-collapsible-toggle' );
        Button.firstChild.data = expandCaption;
+
if ( $toggle.length ) {
    } else {
+
// Make the toggle inherit text color
        for ( var i = 1; i < Rows.length; i++ ) {
+
if( $toggle.parent()[0].style.color ) {
            Rows[i].style.display = Rows[0].style.display;
+
$toggle.find( 'a' ).css( 'color', 'inherit' );
        }
+
}
        Button.firstChild.data = collapseCaption;
+
}
    }
+
} );
 
}
 
}
 +
 +
mw.hook( 'wikipage.collapsibleContent' ).add( mwCollapsibleSetup );
 +
 +
/**
 +
* Dynamic Navigation Bars (experimental)
 +
*
 +
* Description: See [[Wikipedia:NavFrame]].
 +
* Maintainers: UNMAINTAINED
 +
*/
 
   
 
   
function createCollapseButtons(){
+
var collapseCaption = '숨기기';
    var tableIndex = 0;
+
var expandCaption = '보이기';
    var NavigationBoxes = new Object();
+
 
    var Tables = document.getElementsByTagName( "table" );
+
// Set up the words in your language
+
var navigationBarHide = '[' + collapseCaption + ']';
    for ( var i = 0; i < Tables.length; i++ ) {
+
var navigationBarShow = '[' + expandCaption + ']';
        if ( hasClass( Tables[i], "collapsible" ) ) {
+
 
+
/**
            /* only add button and increment count if there is a header row to work with */
+
* Shows and hides content and picture (if available) of navigation bars.
            var HeaderRow = Tables[i].getElementsByTagName( "tr" )[0];
+
*
            if (!HeaderRow) continue;
+
* @param {number} indexNavigationBar The index of navigation bar to be toggled
            var Header = HeaderRow.getElementsByTagName( "th" )[0];
+
  * @param {jQuery.Event} event Event object
            if (!Header) continue;
+
*/
   
+
function toggleNavigationBar( indexNavigationBar, event ) {
            NavigationBoxes[ tableIndex ] = Tables[i];
+
var navToggle = document.getElementById( 'NavToggle' + indexNavigationBar );
            Tables[i].setAttribute( "id", "collapsibleTable" + tableIndex );
+
var navFrame = document.getElementById( 'NavFrame' + indexNavigationBar );
+
var navChild;
            var Button    = document.createElement( "span" );
+
 
            var ButtonLink = document.createElement( "a" );
+
if ( !navFrame || !navToggle ) {
            var ButtonText = document.createTextNode( collapseCaption );
+
return false;
+
}
            Button.className = "collapseButton";  //Styles are declared in Common.css
+
 
+
// If shown now
            ButtonLink.style.color = Header.style.color;
+
if ( navToggle.firstChild.data === navigationBarHide ) {
            ButtonLink.setAttribute( "id", "collapseButton" + tableIndex );
+
for ( navChild = navFrame.firstChild; navChild !== null; navChild = navChild.nextSibling ) {
            ButtonLink.setAttribute( "href", "#" );
+
if ( $( navChild ).hasClass( 'NavContent' ) || $( navChild ).hasClass( 'NavPic' ) ) {
            addHandler( ButtonLink,  "click", new Function( "evt", "collapseTable(" + tableIndex + " ); return killEvt( evt );") );
+
navChild.style.display = 'none';
            ButtonLink.appendChild( ButtonText );
+
}
+
}
            Button.appendChild( document.createTextNode( "[" ) );
+
navToggle.firstChild.data = navigationBarShow;
            Button.appendChild( ButtonLink );
+
 
            Button.appendChild( document.createTextNode( "]" ) );
+
// If hidden now
+
} else if ( navToggle.firstChild.data === navigationBarShow ) {
            Header.insertBefore( Button, Header.childNodes[0] );
+
for ( navChild = navFrame.firstChild; navChild !== null; navChild = navChild.nextSibling ) {
            tableIndex++;
+
if ( $( navChild ).hasClass( 'NavContent' ) || $( navChild ).hasClass( 'NavPic' ) ) {
        }
+
navChild.style.display = 'block';
    }
+
}
+
}
    for ( var i = 0; i < tableIndex; i++ ) {
+
navToggle.firstChild.data = navigationBarHide;
        if ( hasClass( NavigationBoxes[i], "collapsed" ) || ( tableIndex >= autoCollapse && hasClass( NavigationBoxes[i], "autocollapse" ) ) ) {
+
}
            collapseTable( i );
+
 
        }  
+
event.preventDefault();
        else if ( hasClass( NavigationBoxes[i], "innercollapse" ) ) {
 
            var element = NavigationBoxes[i];
 
            while (element = element.parentNode) {
 
                if ( hasClass( element, "outercollapse" ) ) {
 
                    collapseTable ( i );
 
                    break;
 
                }
 
            }
 
        }
 
    }
 
 
}
 
}
 
$( createCollapseButtons );
 
  
/* ([[위키백과:관리자 요청/2007년 5월#스크립트 추가 요청]]) */
+
/**
/** Dynamic Navigation Bars (experimental) *************************************
+
* Adds show/hide-button to navigation bars.
 
  *
 
  *
  * Description: See [[:en:Wikipedia:NavFrame]].
+
  * @param {jQuery} $content
*  Maintainers: UNMAINTAINED
 
 
  */
 
  */
+
function createNavigationBarToggleButton( $content ) {
// set up the words in your language
+
var i, j, navChild, navToggle, navToggleText, isCollapsed,
var NavigationBarHide = '[' + collapseCaption + ']';
+
indexNavigationBar = 0;
var NavigationBarShow = '[' + expandCaption + ']';
+
// Iterate over all < div >-elements
+
var $divs = $content.find( 'div.NavFrame:not(.mw-collapsible)' );
// shows and hides content and picture (if available) of navigation bars
+
$divs.each( function ( i, navFrame ) {
// Parameters:
+
indexNavigationBar++;
//    indexNavigationBar: the index of navigation bar to be toggled
+
navToggle = document.createElement( 'a' );
function toggleNavigationBar(indexNavigationBar){
+
navToggle.className = 'NavToggle';
    var NavToggle = document.getElementById("NavToggle" + indexNavigationBar);
+
navToggle.setAttribute( 'id', 'NavToggle' + indexNavigationBar );
    var NavFrame = document.getElementById("NavFrame" + indexNavigationBar);
+
navToggle.setAttribute( 'href', '#' );
+
$( navToggle ).on( 'click', $.proxy( toggleNavigationBar, null, indexNavigationBar ) );
    if (!NavFrame || !NavToggle) {
+
 
        return false;
+
isCollapsed = $( navFrame ).hasClass( 'collapsed' );
    }
+
/**
+
* Check if any children are already hidden.  This loop is here for backwards compatibility:
    // if shown now
+
* the old way of making NavFrames start out collapsed was to manually add style="display:none"
    if (NavToggle.firstChild.data == NavigationBarHide) {
+
* to all the NavPic/NavContent elements.  Since this was bad for accessibility (no way to make
        for (var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) {
+
* the content visible without JavaScript support), the new recommended way is to add the class
            if (hasClass(NavChild, 'NavContent') || hasClass(NavChild, 'NavPic')) {
+
* "collapsed" to the NavFrame itself, just like with collapsible tables.
                NavChild.style.display = 'none';
+
*/
            }
+
for ( navChild = navFrame.firstChild; navChild !== null && !isCollapsed; navChild = navChild.nextSibling ) {
        }
+
if ( $( navChild ).hasClass( 'NavPic' ) || $( navChild ).hasClass( 'NavContent' ) ) {
    NavToggle.firstChild.data = NavigationBarShow;
+
if ( navChild.style.display === 'none' ) {
+
isCollapsed = true;
    // if hidden now
+
}
    } else if (NavToggle.firstChild.data == NavigationBarShow) {
+
}
        for (var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) {
+
}
            if (hasClass(NavChild, 'NavContent') || hasClass(NavChild, 'NavPic')) {
+
if ( isCollapsed ) {
                NavChild.style.display = 'block';
+
for ( navChild = navFrame.firstChild; navChild !== null; navChild = navChild.nextSibling ) {
            }
+
if ( $( navChild ).hasClass( 'NavPic' ) || $( navChild ).hasClass( 'NavContent' ) ) {
        }
+
navChild.style.display = 'none';
        NavToggle.firstChild.data = NavigationBarHide;
+
}
    }
+
}
 +
}
 +
navToggleText = document.createTextNode( isCollapsed ? navigationBarShow : navigationBarHide );
 +
navToggle.appendChild( navToggleText );
 +
 
 +
// Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked)
 +
for ( j = 0; j < navFrame.childNodes.length; j++ ) {
 +
if ( $( navFrame.childNodes[j] ).hasClass( 'NavHead' ) ) {
 +
navToggle.style.color = navFrame.childNodes[j].style.color;
 +
navFrame.childNodes[j].appendChild( navToggle );
 +
}
 +
}
 +
navFrame.setAttribute( 'id', 'NavFrame' + indexNavigationBar );
 +
} );
 
}
 
}
+
 
// adds show/hide-button to navigation bars
+
mw.hook( 'wikipage.content' ).add( createNavigationBarToggleButton );
function createNavigationBarToggleButton(){
+
 
    var indexNavigationBar = 0;
+
/**
    // iterate over all < div >-elements
+
* 편집 안내 ****************************************************
    var divs = document.getElementsByTagName("div");
+
  *
    for (var i = 0; NavFrame = divs[i]; i++) {
+
* 생존 인물에 대한 편집 안내. 영어 위키백과에서 가져옴 - ChongDae
        // if found a navigation bar
+
  * Description: Adds editintros on disambiguation pages and BLP pages.
        if (hasClass(NavFrame, "NavFrame")) {
+
* Maintainers: [[User:RockMFR]]
+
*/
            indexNavigationBar++;
+
function addEditIntro( name ) {
            var NavToggle = document.createElement("a");
+
    $( '.mw-editsection, #ca-edit' ).find( 'a' ).each( function ( i, el ) {
            NavToggle.className = 'NavToggle';
+
        el.href = $( this ).attr( 'href' ) + '&editintro=' + name;
            NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar);
+
     } );
            NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');');
 
 
            var isCollapsed = hasClass( NavFrame, "collapsed" );
 
            /*
 
            * Check if any children are already hidden. This loop is here for backwards compatibility:
 
            * the old way of making NavFrames start out collapsed was to manually add style="display:none"
 
            * to all the NavPic/NavContent elementsSince this was bad for accessibility (no way to make
 
            * the content visible without JavaScript support), the new recommended way is to add the class
 
            * "collapsed" to the NavFrame itself, just like with collapsible tables.
 
            */
 
            for (var NavChild = NavFrame.firstChild; NavChild != null && !isCollapsed; NavChild = NavChild.nextSibling) {
 
                if ( hasClass( NavChild, 'NavPic' ) || hasClass( NavChild, 'NavContent' ) ) {
 
                    if ( NavChild.style.display == 'none' ) {
 
                        isCollapsed = true;
 
                    }
 
                }
 
            }
 
            if (isCollapsed) {
 
                for (var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) {
 
                    if ( hasClass( NavChild, 'NavPic' ) || hasClass( NavChild, 'NavContent' ) ) {
 
                        NavChild.style.display = 'none';
 
                    }
 
                }
 
            }
 
            var NavToggleText = document.createTextNode(isCollapsed ? NavigationBarShow : NavigationBarHide);
 
            NavToggle.appendChild(NavToggleText);
 
 
            // Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked)
 
            for(var j=0; j < NavFrame.childNodes.length; j++) {
 
                if (hasClass(NavFrame.childNodes[j], "NavHead")) {
 
                    NavToggle.style.color = NavFrame.childNodes[j].style.color;
 
                    NavFrame.childNodes[j].appendChild(NavToggle);
 
                }
 
            }
 
            NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar);
 
        }
 
     }
 
 
}
 
}
 
$( createNavigationBarToggleButton );
 
  
 
+
if ( mw.config.get( 'wgNamespaceNumber' ) === 0 ) {
/*
+
     $( function () {
알찬 글과 좋은 글에 별표 붙이는 스크립트
+
         var cats = mw.config.get('wgCategories');
*/
+
         if ( !cats ) {
function LinkFA()  
+
             return;
{
+
        }
     if ( document.getElementById( "p-lang" ) ) {
+
        if ( $.inArray( '살아있는 사람', cats ) !== -1 || $.inArray( '생사 불명', cats ) !== -1 ) {
         var InterwikiLinks = document.getElementById( "p-lang" ).getElementsByTagName( "li" );
+
            addEditIntro( '틀:BLP_편집_안내' );
 
         for ( var i = 0; i < InterwikiLinks.length; i++ ) {
 
             if ( document.getElementById( InterwikiLinks[i].className + "-fa" ) ) {
 
                InterwikiLinks[i].className += " FA"
 
                InterwikiLinks[i].title = "알찬 글로 선정되었습니다.";
 
            } else if ( document.getElementById( InterwikiLinks[i].className + "-ga" ) ) {
 
                InterwikiLinks[i].className += " GA"
 
                InterwikiLinks[i].title = "좋은 글로 선정되었습니다.";
 
            }
 
 
         }
 
         }
     }
+
     } );
 
}
 
}
 
$( LinkFA );
 
  
/* 대문의 "프로젝트" 탭을 "대문"으로 바꿉니다.
+
/* Actions specific to the edit page */
- 영어 위키백과 common.js의 main page 스크립트를 약간 변형 */
+
if ( mw.config.get( 'wgAction' ) === 'edit' || mw.config.get( 'wgAction' ) === 'submit' ) {
 
+
/**
if (wgPageName == "위키백과:대문" || wgPageName == "위키백과토론:대문") {
+
* Fix edit summary prompt for undo
  $(function () {
+
*
        var nstab = document.getElementById('ca-nstab-project');
+
*  Fixes the fact that the undo function combined with the "no edit summary prompter"
        if (nstab) {
+
*  complains about missing editsummary, if leaving the edit summary unchanged.
            while (nstab.firstChild) { nstab = nstab.firstChild; }
+
*  Added by [[User:Deskana]], code by [[User:Tra]].
            nstab.nodeValue = '대문';
+
* See also [[phab:T10912]].
        }
+
*/
    });
+
$(function () {
 +
if (document.location.search.indexOf('undo=') !== -1 && document.getElementsByName('wpAutoSummary')[0]) {
 +
document.getElementsByName('wpAutoSummary')[0].value = '1';
 +
}
 +
});
 
}
 
}
  
270번째 줄: 336번째 줄:
 
  * JSConfig를 사용하지 않도록 수정함. --[[사용자:Klutzy|klutzy]] ([[사용자토론:Klutzy|토론]]) 2009년 9월 27일 (일) 20:33 (KST)
 
  * JSConfig를 사용하지 않도록 수정함. --[[사용자:Klutzy|klutzy]] ([[사용자토론:Klutzy|토론]]) 2009년 9월 27일 (일) 20:33 (KST)
 
  ****/
 
  ****/
if (wgCanonicalSpecialPageName == 'Upload') {
+
if (mw.config.get('wgCanonicalSpecialPageName') == 'Upload') {
 
   importScript('MediaWiki:Upload.js');
 
   importScript('MediaWiki:Upload.js');
 
}
 
}
  
/* 인터랙티브 지도. 영어 위키백과에서 가져옴. -- [[사용자:ChongDae]] 2010년 3월 28일 (일) 02:08 (KST) */
+
/* End of mw.loader.using callback */
/** WikiMiniAtlas *******************************************************
+
} );
  *
+
/* DO NOT ADD CODE BELOW THIS LINE */
  *  Description: WikiMiniAtlas is a popup click and drag world map.
 
  *              This script causes all of our coordinate links to display the WikiMiniAtlas popup button.
 
  *              The script itself is located on meta because it is used by many projects.
 
  *              See [[Meta:WikiMiniAtlas]] for more information.  
 
  *  Maintainers: [[User:Dschwen]]
 
  */
 
 
var metaBase = '//meta.wikimedia.org';
 
 
 
mw.loader.load(metaBase + '/w/index.php?title=MediaWiki:Wikiminiatlas.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400');
 
 
 
/* 보안 서버 링크 스크립트
 
* 보안 서버에 있을 때 일반 링크를 보안 서버 링크로 변경하여 일반 서버 접속으로 전환되는 것을 최소화
 
* [[미디어위키토론:Common.js#보안 서버용 스크립트]]
 
* [[사용자:IRTC1015]] 2011년 1월 9일 (일) 23:06 (KST)
 
*/
 
if (wgServer == "https://secure.wikimedia.org") {
 
    mw.loader.load('https://secure.wikimedia.org/wikipedia/en/w/index.php?title=MediaWiki:Common.js/secure.js&action=raw&ctype=text/javascript');
 
}
 

2018년 12월 16일 (일) 19:26 기준 최신판

/* 이 자바스크립트 설정은 모든 문서, 모든 사용자에게 적용됩니다. */

mw.loader.using( ['mediawiki.user', 'mediawiki.util', 'mediawiki.notify'] ).done( function () {
/* Begin of mw.loader.using callback */

/**
 * Main Page layout fixes
 *
 * Description: Adds an additional link to the complete list of languages available.
 * Maintainers: [[User:AzaToth]], [[User:R. Koot]], [[User:Alex Smotrov]]
 */
if ( mw.config.get( 'wgPageName' ) === '누리위키:대문' || mw.config.get( 'wgPageName' ) === '누리위키토론:대문' ) {
	$( function () {
		mw.util.addPortletLink( 'p-lang', '//meta.wikimedia.org/wiki/List_of_Wikipedias/ko',
			'전체 목록', 'interwiki-completelist', '누리위키 전체 목록' );
	} );
}

/**
 * Redirect User:Name/skin.js and skin.css to the current skin's pages
 * (unless the 'skin' page really exists)
 * @source: http://www.mediawiki.org/wiki/Snippets/Redirect_skin.js
 * @rev: 2
 */
if ( mw.config.get( 'wgArticleId' ) === 0 && mw.config.get( 'wgNamespaceNumber' ) === 2 ) {
	var titleParts = mw.config.get( 'wgPageName' ).split( '/' );
	/* Make sure there was a part before and after the slash
	   and that the latter is 'skin.js' or 'skin.css' */
	if ( titleParts.length == 2 ) {
		var userSkinPage = titleParts.shift() + '/' + mw.config.get( 'skin' );
		if ( titleParts.slice( -1 ) == 'skin.js' ) {
			window.location.href = mw.util.getUrl( userSkinPage + '.js' );
		} else if ( titleParts.slice( -1 ) == 'skin.css' ) {
			window.location.href = mw.util.getUrl( userSkinPage + '.css' );
		}
	}
}

/**
 * Map addPortletLink to mw.util
 * @deprecated: Use mw.util.addPortletLink instead.
 */
mw.log.deprecate( window, 'addPortletLink', mw.util.addPortletLink, 'Use mw.util.addPortletLink instead' );

/**
 * Extract a URL parameter from the current URL
 * @deprecated: Use mw.util.getParamValue with proper escaping
 */
mw.log.deprecate( window, 'getURLParamValue', mw.util.getParamValue, 'Use mw.util.getParamValue instead' );

/**
 * Test if an element has a certain class
 * @deprecated:  Use $(element).hasClass() instead.
 */
mw.log.deprecate( window, 'hasClass', function ( element, className ) {
	return $( element ).hasClass( className );
}, 'jQuery.hasClass()를 대신 사용하십시오' );
 
/**
 * @source www.mediawiki.org/wiki/Snippets/Load_JS_and_CSS_by_URL
 * @rev 6
 */
var extraCSS = mw.util.getParamValue( 'withCSS' ),
	extraJS = mw.util.getParamValue( 'withJS' );

if ( extraCSS ) {
	if ( extraCSS.match( /^(MediaWiki|미디어위키):[^&<>=%#]*\.css$/ ) ) {
		mw.loader.load( '/w/index.php?title=' + extraCSS + '&action=raw&ctype=text/css', 'text/css' );
	} else {
		mw.notify( '미디어위키 이름공간의 문서만 허용됩니다.', { title: '유효하지 않은 withCSS 값' } );
	}
}
 
if ( extraJS ) {
	if ( extraJS.match( /^(MediaWiki|미디어위키):[^&<>=%#]*\.js$/ ) ) {
		mw.loader.load( '/w/index.php?title=' + extraJS + '&action=raw&ctype=text/javascript' );
	} else {
		mw.notify( '미디어위키 이름공간의 문서만 허용됩니다.', { title: '유효하지 않은 withJS 값' } );
	}
}

/* 인터랙티브 지도. 영어 위키백과에서 가져옴. -- [[사용자:ChongDae]] 2010년 3월 28일 (일) 02:08 (KST) */
/**
 * WikiMiniAtlas
 *
 * Description: WikiMiniAtlas is a popup click and drag world map.
 *              This script causes all of our coordinate links to display the WikiMiniAtlas popup button.
 *              The script itself is located on meta because it is used by many projects.
 *              See [[Meta:WikiMiniAtlas]] for more information.
 * Note - use of this service is recommended to be repalced with mw:Help:Extension:Kartographer
 */
( function () {
	var require_wikiminiatlas = false;
	var coord_filter = /geohack/;
	$( function () {
		$( 'a.external.text' ).each( function( key, link ) {
			if ( link.href && coord_filter.exec( link.href ) ) {
				require_wikiminiatlas = true;
				// break from loop
				return false;
			}
		} );
		if ( $( 'div.kmldata' ).length ) {
			require_wikiminiatlas = true;
		}
		if ( require_wikiminiatlas ) {
			mw.loader.load( '//meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js&action=raw&ctype=text/javascript' );
		}
	} );
} )();

/**
 * Collapsible tables; reimplemented with mw-collapsibe
 * Styling is also in place to avoid FOUC
 * 
 * Allows tables to be collapsed, showing only the header. See [[Help:Collapsing]].
 * @version 3.0.0 (2018-05-20)
 * @source https://www.mediawiki.org/wiki/MediaWiki:Gadget-collapsibleTables.js
 * @author [[User:R. Koot]]
 * @author [[User:Krinkle]]
 * @author [[User:TheDJ]]
 * @deprecated Since MediaWiki 1.20: Use class="mw-collapsible" instead which
 * is supported in MediaWiki core. Shimmable since MediaWiki 1.32
 */
function makeCollapsibleMwCollapsible( $content ) {
	var $tables = $content
		.find( 'table.collapsible:not(.mw-collapsible)' )
		.addClass( 'mw-collapsible' );

	$.each( $tables, function( index, table ) {
		// mw.log.warn( '이 문서는 구식 클래스 collapsible을 사용하고 있습니다. mw-collapsible로 변경해 주십시오.');
		if( $( table ).hasClass( 'collapsed') ) {
			$( table ).addClass( 'mw-collapsed' );
			// mw.log.warn( '이 문서는 구식 클래스 collapsed를 사용하고 있습니다. mw-collapsed로 변경해 주십시오.');
		}
	} );
	if( $tables.length > 0 ) {
		mw.loader.using( 'jquery.makeCollapsible' ).then( function() {
			$tables.makeCollapsible();
		} );
	}
}
mw.hook( 'wikipage.content' ).add( makeCollapsibleMwCollapsible );

/**
 * Add support to mw-collapsible for autocollapse, innercollapse and outercollapse
 *
 * Maintainers: TheDJ
 */
function mwCollapsibleSetup( $collapsibleContent ) {
	var $element,
		$toggle,
		autoCollapseThreshold = 2;
	$.each( $collapsibleContent, function (index, element) {
		$element = $( element );
		if ( $element.hasClass( 'collapsible' ) ) {
			$element.find('tr:first > th:first').prepend( $element.find('tr:first > * > .mw-collapsible-toggle'));
		}
		if ( $collapsibleContent.length >= autoCollapseThreshold && $element.hasClass( 'autocollapse' ) ) {
			$element.data( 'mw-collapsible' ).collapse();
		} else if ( $element.hasClass( 'innercollapse' ) ) {
			if ( $element.parents( '.outercollapse' ).length > 0 ) {
				$element.data( 'mw-collapsible' ).collapse();
			}
		}
		// because of colored backgrounds, style the link in the text color
		// to ensure accessible contrast
		$toggle = $element.find( '.mw-collapsible-toggle' );
		if ( $toggle.length ) {
			// Make the toggle inherit text color
			if( $toggle.parent()[0].style.color ) {
				$toggle.find( 'a' ).css( 'color', 'inherit' );
			}
		}
	} );
}

mw.hook( 'wikipage.collapsibleContent' ).add( mwCollapsibleSetup );

/**
 * Dynamic Navigation Bars (experimental)
 *
 * Description: See [[Wikipedia:NavFrame]].
 * Maintainers: UNMAINTAINED
 */
 
var collapseCaption = '숨기기';
var expandCaption = '보이기';

// Set up the words in your language
var navigationBarHide = '[' + collapseCaption + ']';
var navigationBarShow = '[' + expandCaption + ']';

/**
 * Shows and hides content and picture (if available) of navigation bars.
 *
 * @param {number} indexNavigationBar The index of navigation bar to be toggled
 * @param {jQuery.Event} event Event object
 */
function toggleNavigationBar( indexNavigationBar, event ) {
	var navToggle = document.getElementById( 'NavToggle' + indexNavigationBar );
	var navFrame = document.getElementById( 'NavFrame' + indexNavigationBar );
	var navChild;

	if ( !navFrame || !navToggle ) {
		return false;
	}

	// If shown now
	if ( navToggle.firstChild.data === navigationBarHide ) {
		for ( navChild = navFrame.firstChild; navChild !== null; navChild = navChild.nextSibling ) {
			if ( $( navChild ).hasClass( 'NavContent' ) || $( navChild ).hasClass( 'NavPic' ) ) {
				navChild.style.display = 'none';
			}
		}
		navToggle.firstChild.data = navigationBarShow;

	// If hidden now
	} else if ( navToggle.firstChild.data === navigationBarShow ) {
		for ( navChild = navFrame.firstChild; navChild !== null; navChild = navChild.nextSibling ) {
			if ( $( navChild ).hasClass( 'NavContent' ) || $( navChild ).hasClass( 'NavPic' ) ) {
				navChild.style.display = 'block';
			}
		}
		navToggle.firstChild.data = navigationBarHide;
	}

	event.preventDefault();
}

/**
 * Adds show/hide-button to navigation bars.
 *
 * @param {jQuery} $content
 */
function createNavigationBarToggleButton( $content ) {
	var i, j, navChild, navToggle, navToggleText, isCollapsed,
		indexNavigationBar = 0;
	// Iterate over all < div >-elements
	var $divs = $content.find( 'div.NavFrame:not(.mw-collapsible)' );
	$divs.each( function ( i, navFrame ) {
		indexNavigationBar++;
		navToggle = document.createElement( 'a' );
		navToggle.className = 'NavToggle';
		navToggle.setAttribute( 'id', 'NavToggle' + indexNavigationBar );
		navToggle.setAttribute( 'href', '#' );
		$( navToggle ).on( 'click', $.proxy( toggleNavigationBar, null, indexNavigationBar ) );

		isCollapsed = $( navFrame ).hasClass( 'collapsed' );
		/**
		 * Check if any children are already hidden.  This loop is here for backwards compatibility:
		 * the old way of making NavFrames start out collapsed was to manually add style="display:none"
		 * to all the NavPic/NavContent elements.  Since this was bad for accessibility (no way to make
		 * the content visible without JavaScript support), the new recommended way is to add the class
		 * "collapsed" to the NavFrame itself, just like with collapsible tables.
		 */
		for ( navChild = navFrame.firstChild; navChild !== null && !isCollapsed; navChild = navChild.nextSibling ) {
			if ( $( navChild ).hasClass( 'NavPic' ) || $( navChild ).hasClass( 'NavContent' ) ) {
				if ( navChild.style.display === 'none' ) {
					isCollapsed = true;
				}
			}
		}
		if ( isCollapsed ) {
			for ( navChild = navFrame.firstChild; navChild !== null; navChild = navChild.nextSibling ) {
				if ( $( navChild ).hasClass( 'NavPic' ) || $( navChild ).hasClass( 'NavContent' ) ) {
					navChild.style.display = 'none';
				}
			}
		}
		navToggleText = document.createTextNode( isCollapsed ? navigationBarShow : navigationBarHide );
		navToggle.appendChild( navToggleText );

		// Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked)
		for ( j = 0; j < navFrame.childNodes.length; j++ ) {
			if ( $( navFrame.childNodes[j] ).hasClass( 'NavHead' ) ) {
				navToggle.style.color = navFrame.childNodes[j].style.color;
				navFrame.childNodes[j].appendChild( navToggle );
			}
		}
		navFrame.setAttribute( 'id', 'NavFrame' + indexNavigationBar );
	} );
}

mw.hook( 'wikipage.content' ).add( createNavigationBarToggleButton );

/**
 * 편집 안내 ****************************************************
 *
 * 생존 인물에 대한 편집 안내. 영어 위키백과에서 가져옴 - ChongDae
 * Description: Adds editintros on disambiguation pages and BLP pages.
 * Maintainers: [[User:RockMFR]]
 */
function addEditIntro( name ) {
    $( '.mw-editsection, #ca-edit' ).find( 'a' ).each( function ( i, el ) {
        el.href = $( this ).attr( 'href' ) + '&editintro=' + name;
    } );
}

if ( mw.config.get( 'wgNamespaceNumber' ) === 0 ) {
    $( function () {
        var cats = mw.config.get('wgCategories');
        if ( !cats ) {
            return;
        }
        if ( $.inArray( '살아있는 사람', cats ) !== -1 || $.inArray( '생사 불명', cats ) !== -1 ) {
            addEditIntro( '틀:BLP_편집_안내' );
        }
    } );
}

/* Actions specific to the edit page */
if ( mw.config.get( 'wgAction' ) === 'edit' || mw.config.get( 'wgAction' ) === 'submit' ) {
	/**
	 * Fix edit summary prompt for undo
	 *
	 *  Fixes the fact that the undo function combined with the "no edit summary prompter"
	 *  complains about missing editsummary, if leaving the edit summary unchanged.
	 *  Added by [[User:Deskana]], code by [[User:Tra]].
	 *  See also [[phab:T10912]].
	 */
	$(function () {
		if (document.location.search.indexOf('undo=') !== -1 && document.getElementsByName('wpAutoSummary')[0]) {
			document.getElementsByName('wpAutoSummary')[0].value = '1';
		}
	});
}

/***** 그림 정보 틀을 자동으로 불러옴 ********
 * Adds a link to subpages of current page
 * from commons.wikimedia.org
 *  Maintainers: [[User:Yonidebest]], [[User:Dschwen]]
 *  [[사용자:Kwj2772]]가 수정
 *  JSconfig items: bool 'loadAutoInformationTemplate'
 *                       (true=enabled (default), false=disabled)
 * JSConfig를 사용하지 않도록 수정함. --[[사용자:Klutzy|klutzy]] ([[사용자토론:Klutzy|토론]]) 2009년 9월 27일 (일) 20:33 (KST)
 ****/
if (mw.config.get('wgCanonicalSpecialPageName') == 'Upload') {
  importScript('MediaWiki:Upload.js');
}

/* End of mw.loader.using callback */
} );
/* DO NOT ADD CODE BELOW THIS LINE */