User:Star0/User:Star0/Sandbox/1.js:修订间差异

来自Arcaea中文维基
无编辑摘要
第1行: 第1行:
window["test_global_attr_20200331113399999"] = "exists"
/* Copy of en.wikipedia.org MediaWiki:Commmon.js */


mw.log.deprecate( window, 'JSConfig', {} );
/**
* Keep code in MediaWiki:Common.js to a minimum as it is unconditionally
* loaded for all users on every wiki page. If possible create a gadget that is
* enabled by default instead of adding it here (since gadgets are fully
* optimized ResourceLoader modules with possibility to add dependencies etc.)
*
* Since Common.js isn't a gadget, there is no place to declare its
* dependencies, so we have to lazy load them with mw.loader.using on demand and
* then execute the rest in the callback. In most cases these dependencies will
* be loaded (or loading) already and the callback will not be delayed. In case a
* dependency hasn't arrived yet it'll make sure those are loaded before this.
*/
 
/* global mw, $ */
/* jshint strict:false, browser:true */


mw.loader.using(['mediawiki.util', 'ext.gadget.site-lib'], function () {
mw.loader.using( ['mediawiki.util'] ).done( function () {
  (function ($, mw) {
/* Begin of mw.loader.using callback */


   /*  當需要時載入對應的 scripts */
/**
   var importScriptRL=function(page){
  * Main Page layout fixes
     mw.loader.load(mw.config.get('wgScript')+'?title='+mw.util.wikiUrlencode(page)+'&action=raw&ctype=text/javascript&_='+Math.floor((new Date())/1000/60/60/24/7));
*
   };
* 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' ) === 'Main_Page' || mw.config.get( 'wgPageName' ) === 'Talk:Main_Page' ) {
$( function () {
mw.util.addPortletLink( 'p-lang', '//meta.wikimedia.org/wiki/List_of_Wikipedias',
'Complete list', 'interwiki-completelist', 'Complete list of Wikipedias' );
} );
}


   if (mw.config.get('wgAction') == "edit" || mw.config.get('wgAction') == "submit" || mw.config.get('wgCanonicalSpecialPageName') == 'Search') { // scripts specific to editing pages
/**
     importScriptRL('MediaWiki:Common.js\/edit.js');
* Redirect User:Name/skin.js and skin.css to the current skin's pages
   } else {
* (unless the 'skin' page really exists)
     mw.loader.using('ext.visualEditor.desktopArticleTarget.init', function () {
* @source: http://www.mediawiki.org/wiki/Snippets/Redirect_skin.js
     mw.libs.ve.addPlugin(function () {
* @rev: 2
       importScriptRL('MediaWiki:Common.js\/edit.js');
*/
      });
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' );
}
}
}


   // wiki URL
/**
   window.wgProjectURL = {
* Map addPortletLink to mw.util
    en: '//en.wikipedia.org',
* @deprecated: Use mw.util.addPortletLink instead.
    de: '//de.wikipedia.org',
  */
    fr: '//fr.wikipedia.org',
mw.log.deprecate( window, 'addPortletLink', mw.util.addPortletLink, 'Use mw.util.addPortletLink instead' );
    pl: '//pl.wikipedia.org',
    ja: '//ja.wikipedia.org',
    it: '//it.wikipedia.org',
    nl: '//nl.wikipedia.org',
    pt: '//pt.wikipedia.org',
    es: '//es.wikipedia.org',
    sv: '//sv.wikipedia.org',
    // 僅列前十名其它語言百科
    m: '//meta.wikimedia.org',
    b: '//zh.wikibooks.org',
    q: '//zh.wikiquote.org',
    n: '//zh.wikinews.org',
    wikt: '//zh.wiktionary.org',
    mw: '//www.mediawiki.org',
    commons: '//commons.wikimedia.org'
   };


   /**
/**
   * Helper script for .hlist class in Common.css
* Extract a URL parameter from the current URL
   * Add pseudo-selector class to last-child list items in IE8
* @deprecated: Use mw.util.getParamValue with proper escaping
   * @source mediawiki.org/wiki/Snippets/Horizontal_lists
*/
   * @revision 6 (2014-08-23)
mw.log.deprecate( window, 'getURLParamValue', mw.util.getParamValue, 'Use mw.util.getParamValue instead' );
   * @author [[User:Edokter]]
   */
   var profile = $.client.profile();
   if ( profile.name === 'msie' && profile.versionNumber === 8 ) {
     mw.hook( 'wikipage.content' ).add( function ( $content ) {
       $content.find( '.hlist' ).find( 'dd:last-child, dt:last-child, li:last-child' )
         .addClass( 'hlist-last-child' );
     } );
   }


   /* Fixes for Windows XP font rendering */
/**
   if (navigator.appVersion.search(/windows nt 5/i) != -1) {
* Test if an element has a certain class
     mw.util.addCSS('.IPA {font-family: "Lucida Sans Unicode", "Arial Unicode MS";} ' +
* @deprecated:  Use $(element).hasClass() instead.
            '.Unicode {font-family: "Arial Unicode MS", "Lucida Sans Unicode";}');
*/
   }
mw.log.deprecate( window, 'hasClass', function ( element, className ) {
return $( element ).hasClass( className );
}, 'Use jQuery.hasClass() instead' );


/**
* @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 ) {
   $(function () {
if ( extraCSS.match( /^MediaWiki:[^&<>=%#]*\.css$/ ) ) {
    if (location.hash) {
mw.loader.load( '/w/index.php?title=' + extraCSS + '&action=raw&ctype=text/css', 'text/css' );
     location.href = location.hash;
} else {
    }
mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withCSS value' } );
   });
}
}


   /* 避免在主條目的註腳中出現捲軸框 */
if ( extraJS ) {
   if (!mw.config.get("wgCanonicalNamespace")) $(function () {
if ( extraJS.match( /^MediaWiki:[^&<>=%#]*\.js$/ ) ) {
mw.loader.load( '/w/index.php?title=' + extraJS + '&action=raw&ctype=text/javascript' );
} else {
mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withJS value' } );
}
}


     $("div#mw-content-text ol.references")
/**
     .each(function(){
* WikiMiniAtlas
       var needobjs=[], $curobj=$(this);
*
* 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 replaced with mw:Help:Extension:Kartographer
*/
$( function () {
var require_wikiminiatlas = $( 'a.external.text[href*="geohack"]' ).length || $( 'div.kmldata' ).length;
if ( require_wikiminiatlas ) {
mw.loader.load( '//meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js&action=raw&ctype=text/javascript' );
}
} );


       do{
/**
         $curobj=$curobj.parent();
* Collapsible tables; reimplemented with mw-collapsible
         if( !$curobj ) break;
* Styling is also in place to avoid FOUC
         if( $curobj.attr("id")=="mw-content-text" || $curobj.prop("tagName").toLowerCase()=="body") break;
*
* 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(
$.each( $tables, function( index, table ) {
           $curobj.css("overflow").match(/(?:auto|scroll)/i)
// mw.log.warn( 'This page is using the deprecated class collapsible. Please replace it with mw-collapsible.');
           || $curobj.css("overflow-x").match(/(?:auto|scroll)/i)
if( $( table ).hasClass( 'collapsed') ) {
           || $curobj.css("overflow-y").match(/(?:auto|scroll)/i)
$( table ).addClass( 'mw-collapsed' );
         ){}else continue;
// mw.log.warn( 'This page is using the deprecated class collapsed. Please replace it with mw-collapsed.');
}
} );
if( $tables.length > 0 ) {
mw.loader.using( 'jquery.makeCollapsible' ).then( function() {
$tables.makeCollapsible();
} );
}
}
mw.hook( 'wikipage.content' ).add( makeCollapsibleMwCollapsible );


         if( (""+$curobj.attr("class")).split(" ").indexOf("noprint")>=0 ) return;
/**
* 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' );
}
}
} );
}


         needobjs.push($curobj.get(0));
mw.hook( 'wikipage.collapsibleContent' ).add( mwCollapsibleSetup );


       }while(true);
/**
* Dynamic Navigation Bars (experimental)
*
* Description: See [[Wikipedia:NavFrame]].
* Maintainers: UNMAINTAINED
*/
var collapseCaption = 'hide';
var expandCaption = 'show';


       $(needobjs)
// Set up the words in your language
       .css("overflow","visible")
var navigationBarHide = '[' + collapseCaption + ']';
       .css("overflow-x","visible")
var navigationBarShow = '[' + expandCaption + ']';
       .css("overflow-y","visible")
       .css("height","")
       .css("max-height","")
       .css("border","")
       ;
     });
   });


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


   /** metaBox
if ( !navFrame || !navToggle ) {
   *
return false;
   * Funcionament de la Plantilla:Metacaixa
}
   * Implementat per: Usuari:Peleguer.
   * Actualitzat per Joanjoc seguint les indicacions d'en Martorell
   */
   function MetaCaixaInit() {
    // S'executa al carregar-se la pàgina, si hi ha metacaixes,
    // s'assignen els esdeveniments als botons
    //alert("MetaCaixaInit");
    var i = 0; // Inicialitzem comptador de caixes
    for (i = 0; i <= 9; i++) {
     var vMc = document.getElementById("mc" + i);
     if (!vMc) break;
     //alert("MetaCaixaInit, trobada Metacaixa mc"+i);
     var j = 1; // Inicialitzem comptador de botons dins de la caixa
     var vPsIni = 0; // Pestanya visible inicial
     for (j = 1; j <= 9; j++) {
      var vBt = document.getElementById("mc" + i + "bt" + j);
      if (!vBt) break;
      //alert("MetaCaixaInit, trobat botó mc"+i+"bt"+j);
      vBt.onclick = MetaCaixaMostraPestanya; // A cada botó assignem l'esdeveniment onclick
      //alert (vBt.className);
      if (vBt.className == "mcBotoSel") vPsIni = j; // Si tenim un botó seleccionat, en guardem l'index
     }
     //alert ("mc="+i+", ps="+j+", psini="+vPsIni );
     if (vPsIni === 0) { // Si no tenim cap botó seleccionat, n'agafem un aleatòriament
      vPsIni = 1 + Math.floor((j - 1) * Math.random());
      //alert ("Activant Pestanya a l'atzar; _mc"+i+"bt"+vPsIni +"_");
      document.getElementById("mc" + i + "ps" + vPsIni).style.display = "block";
      document.getElementById("mc" + i + "ps" + vPsIni).style.visibility = "visible";
      document.getElementById("mc" + i + "bt" + vPsIni).className = "mcBotoSel";
     }
    }
   }


   function MetaCaixaMostraPestanya() {
// If shown now
    // S'executa al clicar una pestanya,
if ( navToggle.firstChild.data === navigationBarHide ) {
    // aquella es fa visible i les altres s'oculten
for ( navChild = navFrame.firstChild; navChild !== null; navChild = navChild.nextSibling ) {
    var vMcNom = this.id.substr(0, 3); // A partir del nom del botó, deduïm el nom de la caixa
if ( $( navChild ).hasClass( 'NavContent' ) ) {
    var vIndex = this.id.substr(5, 1); // I l'index
navChild.style.display = 'none';
    var i = 1;
}
    for (i = 1; i <= 9; i++) { // busquem totes les pestanyes d'aquella caixa
}
     //alert(vMcNom+"ps"+i);
navToggle.firstChild.data = navigationBarShow;
     var vPsElem = document.getElementById(vMcNom + "ps" + i);
     if (!vPsElem) break;
// If hidden now
     if (vIndex == i) { // Si és la pestanya bona la mostrem i canviem la classe de botó
} else if ( navToggle.firstChild.data === navigationBarShow ) {
      vPsElem.style.display = "block";
for ( navChild = navFrame.firstChild; navChild !== null; navChild = navChild.nextSibling ) {
      vPsElem.style.visibility = "visible";
if ( $( navChild ).hasClass( 'NavContent' ) ) {
      document.getElementById(vMcNom + "bt" + i).className = "mcBotoSel";
navChild.style.display = 'block';
     } else { // Sinó, l'ocultem i canviem la classe de botó
}
      vPsElem.style.display = "none";
}
      vPsElem.style.visibility = "hidden";
navToggle.firstChild.data = navigationBarHide;
      document.getElementById(vMcNom + "bt" + i).className = "mcBoto";
}
     }
    }
    return false; // evitem la recàrrega de la pàgina
   }
   $(MetaCaixaInit);


   /* 智能讨论页编辑(新建) */
event.preventDefault();
   $(function () {
}
    var catalk = $('#ca-talk');
    if (catalk.hasClass('new') && mw.config.get('wgNamespaceNumber') != 2) {
     var a = $('a:first', catalk);
     a.attr('href', a.attr('href') + '&section=new');
    }
   });


/**
/**
  * Magic editintros ****************************************************
  * Adds show/hide-button to navigation bars.
  *
  *
  * Description: Adds editintros on disambiguation pages, BLP pages, policy pages and guidlines.
  * @param {jQuery} $content
* Maintainers: [[User:RockMFR]]
  */
  */
function addEditIntro( name ) {
function createNavigationBarToggleButton( $content ) {
   $( '.mw-editsection, #ca-edit' ).find( 'a' ).each( function ( i, el ) {
var i, j, navChild, navToggle, navToggleText, isCollapsed,
     el.href = $( this ).attr( 'href' ) + '&editintro=' + name;
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 ) );


if ( mw.config.get( 'wgNamespaceNumber' ) === 0 ) {
isCollapsed = $( navFrame ).hasClass( 'collapsed' );
   $( function () {
/**
     if ( document.getElementById( 'disambigbox' ) ) {
* Check if any children are already hidden.  This loop is here for backwards compatibility:
       addEditIntro( 'Template:Disambig_editintro' );
* 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 );


   $( function () {
// Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked)
     var cats = mw.config.get('wgCategories');
for ( j = 0; j < navFrame.childNodes.length; j++ ) {
     if ( !cats ) {
if ( $( navFrame.childNodes[j] ).hasClass( 'NavHead' ) ) {
       return;
navToggle.style.color = navFrame.childNodes[j].style.color;
     }
navFrame.childNodes[j].appendChild( navToggle );
     if ( $.inArray( ' 在世人物', cats ) !== -1 ) {
}
       addEditIntro( 'Template:BLP_editintro' );
}
     }
navFrame.setAttribute( 'id', 'NavFrame' + indexNavigationBar );
   } );
} );
} else if ( mw.config.get( 'wgNamespaceNumber' ) === 4 ) {
   $( function () {
     var cats = mw.config.get('wgCategories');
     if ( !cats ) {
       return;
     }
     if ( $.inArray( '维基百科方针', cats ) !== -1 ||
       $.inArray( '维基百科指引', cats ) !== -1 ||
       $.inArray( ' 维基百科方针与指引', cats ) !== -1) {
         addEditIntro( 'Template:Policy editintro' );
       }
   } );
}
}


   /* 引用錯誤標籤名字解碼 */
mw.hook( 'wikipage.content' ).add( createNavigationBarToggleButton );
   $(function () {
    $('.anchordecodeme').each(function () {
     $(this).text(decodeURIComponent($(this).text().replace(/\.([0-9A-F]{2})/g, '%$1')));
    });
   });


   /** &withCSS= and &withJS= URL parameters
   * Allow to try custom scripts from MediaWiki space
   * without editing personal .css or .js files
   */
/**
/**
  * @source www.mediawiki.org/wiki/Snippets/Load_JS_and_CSS_by_URL
  * Magic editintros ****************************************************
  * @rev 6
*
* Description: Adds editintros on disambiguation pages and BLP pages.
  * Maintainers: [[User:RockMFR]]
  */
  */
var extraCSS = mw.util.getParamValue( 'withCSS' ),
function addEditIntro( name ) {
   extraJS = mw.util.getParamValue( 'withJS' );
$( '.mw-editsection, #ca-edit, #ca-ve-edit' ).find( 'a' ).each( function ( i, el ) {
el.href = $( this ).attr( 'href' ) + '&editintro=' + name;
} );
}
 
if ( mw.config.get( 'wgNamespaceNumber' ) === 0 ) {
$( function () {
if ( document.getElementById( 'disambigbox' ) ) {
addEditIntro( 'Template:Disambig_editintro' );
}
} );


if ( extraCSS ) {
$( function () {
   if ( extraCSS.match( /^MediaWiki:[^&<>=%#]*\.css$/ ) ) {
var cats = mw.config.get('wgCategories');
     importStylesheet( extraCSS );
if ( !cats ) {
   } else {
return;
     mw.notify( ' 只允许从MediaWiki名字空间加载。', { title: ' 无效的withCSS值' } );
}
   }
if ( $.inArray( 'Living people', cats ) !== -1 || $.inArray( 'Possibly living people', cats ) !== -1 ) {
addEditIntro( 'Template:BLP_editintro' );
}
} );
}
}


if ( extraJS ) {
/* Actions specific to the edit page */
   if ( extraJS.match( /^MediaWiki:[^&<>=%#]*\.js$/ ) ) {
if ( mw.config.get( 'wgAction' ) === 'edit' || mw.config.get( 'wgAction' ) === 'submit' ) {
     importScript( extraJS );
/**
   } else {
* Fix edit summary prompt for undo
     mw.notify( ' 只允许从MediaWiki名字空间加载。', { title: ' 无效的withJS值' } );
*
   }
*  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';
}
});
}
}


 
/* End of mw.loader.using callback */
   /* 页面历史加&hilight=高亮 */
} );
   {
/* DO NOT ADD CODE BELOW THIS LINE */
    var hilight = mw.util.getParamValue('hilight');
    if (mw.config.get('wgAction') === 'history' && hilight) {
      $.each(hilight.split(','), function (_, v) {
       $('input[name=oldid][value=' + v + ']').parent().addClass('not-patrolled');
      });
    }
   }
 
   /* Main page hacks */
   if ( mw.config.get( 'wgIsMainPage' ) && mw.config.get( 'wgAction' ) == 'view' ) {
     /* 维基百科语言列表 */
     $( function () {
       mw.util.addPortletLink(
         'p-lang',
         mw.util.getUrl( 'Wikipedia:维基百科语言列表' ),
         wgULS( '维基百科语言列表', '維基百科語言列表' ),
         'interwiki-completelist',
         wgULS( '维基百科的完整各语言列表', '維基百科的完整各語言列表' )
       );
     } );
     /* Remove red links */
     $( '#mw-content-text a.new' ).contents().unwrap();
   }
  })(jQuery, mediaWiki);
});
 
/* Check for any client-side simplified/traditional Chinese conversion */
/* This routine must be placed here to make sure the field is inserted in time */
$('#antispam-container').append(
   $('<input type="text" />').attr({
     id: 'wpAntiConv',
     value: '\u6c49\u6f22'
   })
);
 
//临时修复!侧边栏的“打印页面”移动到“打印/导出”章节
$('div#p-electronpdfservice-sidebar-portlet-heading.portal div.body ul').append($('li#t-print'));

2021年1月3日 (日) 23:00的版本

/* Copy of en.wikipedia.org MediaWiki:Commmon.js */

/**
 * Keep code in MediaWiki:Common.js to a minimum as it is unconditionally
 * loaded for all users on every wiki page. If possible create a gadget that is
 * enabled by default instead of adding it here (since gadgets are fully
 * optimized ResourceLoader modules with possibility to add dependencies etc.)
 *
 * Since Common.js isn't a gadget, there is no place to declare its
 * dependencies, so we have to lazy load them with mw.loader.using on demand and
 * then execute the rest in the callback. In most cases these dependencies will
 * be loaded (or loading) already and the callback will not be delayed. In case a
 * dependency hasn't arrived yet it'll make sure those are loaded before this.
 */

/* global mw, $ */
/* jshint strict:false, browser:true */

mw.loader.using( ['mediawiki.util'] ).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' ) === 'Main_Page' || mw.config.get( 'wgPageName' ) === 'Talk:Main_Page' ) {
	$( function () {
		mw.util.addPortletLink( 'p-lang', '//meta.wikimedia.org/wiki/List_of_Wikipedias',
			'Complete list', 'interwiki-completelist', 'Complete list of Wikipedias' );
	} );
}

/**
 * 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 );
}, 'Use jQuery.hasClass() instead' );

/**
 * @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( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withCSS value' } );
	}
}

if ( extraJS ) {
	if ( extraJS.match( /^MediaWiki:[^&<>=%#]*\.js$/ ) ) {
		mw.loader.load( '/w/index.php?title=' + extraJS + '&action=raw&ctype=text/javascript' );
	} else {
		mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withJS value' } );
	}
}

/**
 * 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 replaced with mw:Help:Extension:Kartographer
 */
$( function () {
	var require_wikiminiatlas = $( 'a.external.text[href*="geohack"]' ).length || $( 'div.kmldata' ).length;
	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-collapsible
 * 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( 'This page is using the deprecated class collapsible. Please replace it with mw-collapsible.');
		if( $( table ).hasClass( 'collapsed') ) {
			$( table ).addClass( 'mw-collapsed' );
			// mw.log.warn( 'This page is using the deprecated class collapsed. Please replace it with 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 = 'hide';
var expandCaption = 'show';

// 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.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.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 );

/**
 * Magic editintros ****************************************************
 *
 * Description: Adds editintros on disambiguation pages and BLP pages.
 * Maintainers: [[User:RockMFR]]
 */
function addEditIntro( name ) {
	$( '.mw-editsection, #ca-edit, #ca-ve-edit' ).find( 'a' ).each( function ( i, el ) {
		el.href = $( this ).attr( 'href' ) + '&editintro=' + name;
	} );
}

if ( mw.config.get( 'wgNamespaceNumber' ) === 0 ) {
	$( function () {
		if ( document.getElementById( 'disambigbox' ) ) {
			addEditIntro( 'Template:Disambig_editintro' );
		}
	} );

	$( function () {
		var cats = mw.config.get('wgCategories');
		if ( !cats ) {
			return;
		}
		if ( $.inArray( 'Living people', cats ) !== -1 || $.inArray( 'Possibly living people', cats ) !== -1 ) {
			addEditIntro( 'Template:BLP_editintro' );
		}
	} );
}

/* 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';
		}
	});
}

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