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

누리위키, 온 누리의 백과사전
잔글
잔글
 
1번째 줄: 1번째 줄:
 
/* 이 자바스크립트 설정은 모든 문서, 모든 사용자에게 적용됩니다. */
 
/* 이 자바스크립트 설정은 모든 문서, 모든 사용자에게 적용됩니다. */
  
mw.loader.using( ['mediawiki.util', 'mediawiki.notify', 'jquery.client'], function () {
+
mw.loader.using( ['mediawiki.user', 'mediawiki.util', 'mediawiki.notify'] ).done( function () {
 
/* Begin of mw.loader.using callback */
 
/* Begin of mw.loader.using callback */
  
 
/**
 
/**
  * Map addPortletLink to mw.util
+
  * 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.
 
  * @deprecated: Use mw.util.addPortletLink instead.
 
  */
 
  */
mw.log.deprecate( window, 'addPortletLink', mw.util.addPortletLink,
+
mw.log.deprecate( window, 'addPortletLink', mw.util.addPortletLink, 'Use mw.util.addPortletLink instead' );
'Use mw.util.addPortletLink instead' );
+
 
 
 
/**
 
/**
 
  * Extract a URL parameter from the current URL
 
  * Extract a URL parameter from the current URL
*
 
 
  * @deprecated: Use mw.util.getParamValue with proper escaping
 
  * @deprecated: Use mw.util.getParamValue with proper escaping
 
  */
 
  */
 
mw.log.deprecate( window, 'getURLParamValue', mw.util.getParamValue, 'Use mw.util.getParamValue instead' );
 
mw.log.deprecate( window, 'getURLParamValue', mw.util.getParamValue, 'Use mw.util.getParamValue instead' );
+
 
/**  
+
/**
 
  * Test if an element has a certain class
 
  * Test if an element has a certain class
*
 
 
  * @deprecated:  Use $(element).hasClass() instead.
 
  * @deprecated:  Use $(element).hasClass() instead.
 
  */
 
  */
 
mw.log.deprecate( window, 'hasClass', function ( element, className ) {
 
mw.log.deprecate( window, 'hasClass', function ( element, className ) {
    return $( element ).hasClass( className );
+
return $( element ).hasClass( className );
}, 'Use jQuery.hasClass() instead' );
+
}, 'jQuery.hasClass()를 대신 사용하십시오' );
 
   
 
   
 
/**
 
/**
 
  * @source www.mediawiki.org/wiki/Snippets/Load_JS_and_CSS_by_URL
 
  * @source www.mediawiki.org/wiki/Snippets/Load_JS_and_CSS_by_URL
  * @rev 5
+
  * @rev 6
 
  */
 
  */
// CSS
+
var extraCSS = mw.util.getParamValue( 'withCSS' ),
var extraCSS = mw.util.getParamValue( 'withCSS' );
+
extraJS = mw.util.getParamValue( 'withJS' );
 +
 
 
if ( extraCSS ) {
 
if ( extraCSS ) {
if ( extraCSS.match( /^MediaWiki:[^&<>=%#]*\.css$/ ) ) {
+
if ( extraCSS.match( /^(MediaWiki|미디어위키):[^&<>=%#]*\.css$/ ) ) {
importStylesheet( extraCSS );
+
mw.loader.load( '/w/index.php?title=' + extraCSS + '&action=raw&ctype=text/css', 'text/css' );
 
} else {
 
} else {
mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withCSS value' } );
+
mw.notify( '미디어위키 이름공간의 문서만 허용됩니다.', { title: '유효하지 않은 withCSS ' } );
 
}
 
}
 
}
 
}
 
   
 
   
// JS
 
var extraJS = mw.util.getParamValue( 'withJS' );
 
 
if ( extraJS ) {
 
if ( extraJS ) {
if ( extraJS.match( /^MediaWiki:[^&<>=%#]*\.js$/ ) ) {
+
if ( extraJS.match( /^(MediaWiki|미디어위키):[^&<>=%#]*\.js$/ ) ) {
importScript( extraJS );
+
mw.loader.load( '/w/index.php?title=' + extraJS + '&action=raw&ctype=text/javascript' );
 
} else {
 
} else {
mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withJS value' } );
+
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' );
 +
}
 +
} );
 +
} )();
  
 
/**
 
/**
  * Import more specific scripts if necessary
+
  * 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' );
  
if ( mw.config.get( 'wgNamespaceNumber' ) === 6 ) {
+
$.each( $tables, function( index, table ) {
    /* file description page scripts */
+
// mw.log.warn( '이 문서는 구식 클래스 collapsible을 사용하고 있습니다. mw-collapsible로 변경해 주십시오.');
    importScript( 'MediaWiki:Common.js/file.js' );
+
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 $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 autoCollapse = 2;
 
 
var collapseCaption = '숨기기';
 
var collapseCaption = '숨기기';
 
var expandCaption = '보이기';
 
var expandCaption = '보이기';
  
window.collapseTable = function ( tableIndex ) {
+
// Set up the words in your language
    var Button = document.getElementById( 'collapseButton' + tableIndex );
+
var navigationBarHide = '[' + collapseCaption + ']';
    var Table = document.getElementById( 'collapsibleTable' + tableIndex );
+
var navigationBarShow = '[' + expandCaption + ']';
  
    if ( !Table || !Button ) {
+
/**
        return false;
+
* 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;
  
    var Rows = Table.rows;
+
if ( !navFrame || !navToggle ) {
    var i;
+
return false;
 +
}
  
    if ( Button.firstChild.data === collapseCaption ) {
+
// If shown now
        for ( i = 1; i < Rows.length; i++ ) {
+
if ( navToggle.firstChild.data === navigationBarHide ) {
            Rows[i].style.display = 'none';
+
for ( navChild = navFrame.firstChild; navChild !== null; navChild = navChild.nextSibling ) {
        }
+
if ( $( navChild ).hasClass( 'NavContent' ) || $( navChild ).hasClass( 'NavPic' ) ) {
        Button.firstChild.data = expandCaption;
+
navChild.style.display = 'none';
    } else {
+
}
        for ( i = 1; i < Rows.length; i++ ) {
+
}
            Rows[i].style.display = Rows[0].style.display;
+
navToggle.firstChild.data = navigationBarShow;
        }
 
        Button.firstChild.data = collapseCaption;
 
    }
 
};
 
  
function createCollapseButtons() {
+
// If hidden now
    var tableIndex = 0;
+
} else if ( navToggle.firstChild.data === navigationBarShow ) {
    var NavigationBoxes = {};
+
for ( navChild = navFrame.firstChild; navChild !== null; navChild = navChild.nextSibling ) {
    var Tables = document.getElementsByTagName( 'table' );
+
if ( $( navChild ).hasClass( 'NavContent' ) || $( navChild ).hasClass( 'NavPic' ) ) {
    var i;
+
navChild.style.display = 'block';
 +
}
 +
}
 +
navToggle.firstChild.data = navigationBarHide;
 +
}
  
    function handleButtonLink( index, e ) {
+
event.preventDefault();
        window.collapseTable( index );
+
}
        e.preventDefault();
 
    }
 
  
    for ( i = 0; i < Tables.length; i++ ) {
+
/**
        if ( $( Tables[i] ).hasClass( 'collapsible' ) ) {
+
* 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 ) );
  
            /* only add button and increment count if there is a header row to work with */
+
isCollapsed = $( navFrame ).hasClass( 'collapsed' );
            var HeaderRow = Tables[i].getElementsByTagName( 'tr' )[0];
+
/**
            if ( !HeaderRow ) continue;
+
* Check if any children are already hidden.  This loop is here for backwards compatibility:
            var Header = HeaderRow.getElementsByTagName( 'th' )[0];
+
* the old way of making NavFrames start out collapsed was to manually add style="display:none"
            if ( !Header ) continue;
+
* 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 );
  
            NavigationBoxes[ tableIndex ] = Tables[i];
+
// Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked)
            Tables[i].setAttribute( 'id', 'collapsibleTable' + tableIndex );
+
for ( j = 0; j < navFrame.childNodes.length; j++ ) {
 
+
if ( $( navFrame.childNodes[j] ).hasClass( 'NavHead' ) ) {
            var Button    = document.createElement( 'span' );
+
navToggle.style.color = navFrame.childNodes[j].style.color;
            var ButtonLink = document.createElement( 'a' );
+
navFrame.childNodes[j].appendChild( navToggle );
            var ButtonText = document.createTextNode( collapseCaption );
+
}
 
+
}
            Button.className = 'collapseButton';  /* Styles are declared in Common.css */
+
navFrame.setAttribute( 'id', 'NavFrame' + indexNavigationBar );
 
+
} );
            ButtonLink.style.color = Header.style.color;
 
            ButtonLink.setAttribute( 'id', 'collapseButton' + tableIndex );
 
            ButtonLink.setAttribute( 'href', '#' );
 
            $( ButtonLink ).on( 'click', $.proxy( handleButtonLink, ButtonLink, tableIndex ) );
 
            ButtonLink.appendChild( ButtonText );
 
 
 
            Button.appendChild( document.createTextNode( '[' ) );
 
            Button.appendChild( ButtonLink );
 
            Button.appendChild( document.createTextNode( ']' ) );
 
 
 
            Header.insertBefore( Button, Header.firstChild );
 
            tableIndex++;
 
        }
 
    }
 
 
 
    for ( i = 0; i < tableIndex; i++ ) {
 
        if ( $( NavigationBoxes[i] ).hasClass( 'collapsed' ) || ( tableIndex >= autoCollapse && $( NavigationBoxes[i] ).hasClass( 'autocollapse' ) ) ) {
 
            window.collapseTable( i );
 
        }
 
        else if ( $( NavigationBoxes[i] ).hasClass ( 'innercollapse' ) ) {
 
            var element = NavigationBoxes[i];
 
            while ((element = element.parentNode)) {
 
                if ( $( element ).hasClass( 'outercollapse' ) ) {
 
                    window.collapseTable ( i );
 
                    break;
 
                }
 
            }
 
        }
 
    }
 
 
}
 
}
  
mw.hook( 'wikipage.content' ).add( createCollapseButtons );
+
mw.hook( 'wikipage.content' ).add( createNavigationBarToggleButton );
  
/* ([[위키백과:관리자 요청/2007년 5월#스크립트 추가 요청]]) */
+
/**
/** Dynamic Navigation Bars (experimental) *************************************
+
* 편집 안내 ****************************************************
 
  *
 
  *
  *  Description: See [[:en:Wikipedia:NavFrame]].
+
  * 생존 인물에 대한 편집 안내. 영어 위키백과에서 가져옴 - ChongDae
  * Maintainers: UNMAINTAINED
+
  * Description: Adds editintros on disambiguation pages and BLP pages.
 +
  * Maintainers: [[User:RockMFR]]
 
  */
 
  */
+
function addEditIntro( name ) {
// set up the words in your language
+
    $( '.mw-editsection, #ca-edit' ).find( 'a' ).each( function ( i, el ) {
/* set up the words in your language */
+
        el.href = $( this ).attr( 'href' ) + '&editintro=' + name;
var NavigationBarHide = '[' + collapseCaption + ']';
+
    } );
var NavigationBarShow = '[' + expandCaption + ']';
+
}
  
/**
+
if ( mw.config.get( 'wgNamespaceNumber' ) === 0 ) {
* Shows and hides content and picture (if available) of navigation bars
+
     $( function () {
* Parameters:
+
         var cats = mw.config.get('wgCategories');
*    indexNavigationBar: the index of navigation bar to be toggled
+
        if ( !cats ) {
**/
+
            return;
window.toggleNavigationBar = function ( 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 ( $.inArray( '살아있는 사람', cats ) !== -1 || $.inArray( '생사 불명', cats ) !== -1 ) {
 
+
            addEditIntro( '틀:BLP_편집_안내' );
    /* 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 */
 
function createNavigationBarToggleButton() {
 
    var indexNavigationBar = 0;
 
    var NavFrame;
 
    var NavChild;
 
     /* iterate over all < div >-elements */
 
    var divs = document.getElementsByTagName( 'div' );
 
    for ( var i = 0; (NavFrame = divs[i]); i++ ) {
 
        /* if found a navigation bar */
 
        if ( $( NavFrame ).hasClass( 'NavFrame' ) ) {
 
 
 
            indexNavigationBar++;
 
            var NavToggle = document.createElement( 'a' );
 
            NavToggle.className = 'NavToggle';
 
            NavToggle.setAttribute( 'id', 'NavToggle' + indexNavigationBar );
 
            NavToggle.setAttribute( 'href', '#' );
 
            $( NavToggle ).on( 'click', $.proxy( window.toggleNavigationBar, window, indexNavigationBar ) );
 
 
 
            var 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';
 
                    }
 
                }
 
            }
 
            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 ( $( 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 );
+
/* Actions specific to the edit page */
 
+
if ( mw.config.get( 'wgAction' ) === 'edit' || mw.config.get( 'wgAction' ) === 'submit' ) {
/* 대문의 "프로젝트" 탭을 "대문"으로 바꿉니다.
+
/**
- 영어 위키백과 common.js의 main page 스크립트를 약간 변형 */
+
* Fix edit summary prompt for undo
 
+
*
if (wgPageName == "누리위키:대문" || wgPageName == "누리위키토론:대문") {
+
* Fixes the fact that the undo function combined with the "no edit summary prompter"
  $(function () {
+
*  complains about missing editsummary, if leaving the edit summary unchanged.
        var nstab = document.getElementById('ca-nstab-project');
+
* Added by [[User:Deskana]], code by [[User:Tra]].
        if (nstab) {
+
* See also [[phab:T10912]].
            while (nstab.firstChild) { nstab = nstab.firstChild; }
+
*/
            nstab.nodeValue = '대문';
+
$(function () {
        }
+
if (document.location.search.indexOf('undo=') !== -1 && document.getElementsByName('wpAutoSummary')[0]) {
    });
+
document.getElementsByName('wpAutoSummary')[0].value = '1';
 +
}
 +
});
 
}
 
}
  
287번째 줄: 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) */
 
/**
 
* 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.
 
* Maintainers: [[User:Dschwen]]
 
*/
 
( 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' );
 
        }
 
    } );
 
} )();
 
 
/* 보안 서버 링크 스크립트
 
* 보안 서버에 있을 때 일반 링크를 보안 서버 링크로 변경하여 일반 서버 접속으로 전환되는 것을 최소화
 
* [[미디어위키토론:Common.js#보안 서버용 스크립트]]
 
* [[사용자:IRTC1015]] 2011년 1월 9일 (일) 23:06 (KST)
 
*/
 
if ( document.location && document.location.protocol === 'https:' ) {
 
    /* New secure servers */
 
    mw.loader.load('//en.wikipedia.org/w/index.php?title=MediaWiki:Common.js/secure new.js&action=raw&ctype=text/javascript');
 
}
 
 
/**
 
* Fix for Windows XP Unicode font rendering
 
*/
 
if ( navigator.appVersion.search(/windows nt 5/i) !== -1 ) {
 
    mw.util.addCSS( '.IPA { font-family: "Lucida Sans Unicode", "Arial Unicode MS"; } ' +
 
                '.Unicode { font-family: "Arial Unicode MS", "Lucida Sans Unicode"; } ' );
 
 
}
 
}
  

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 */