Anonymous

Difference between revisions of "MediaWiki:Common.js"

From Clicklaw Wikibooks
338 bytes added ,  09:18, 4 September 2018
no edit summary
 
Line 6: Line 6:
  * Maintainer: Cacycle
  * Maintainer: Cacycle
  */
  */
if (wgArticleId == 0 && wgUserName) {
 
if (mw.config.get('wgArticleId') == 0 && wgUserName) {
   var slash = wgPageName.indexOf('/');
   var slash = wgPageName.indexOf('/');
   var norm = wgPageName.substr(0, slash) + wgPageName.substr(slash).toLowerCase();
   var norm = wgPageName.substr(0, slash) + wgPageName.substr(slash).toLowerCase();
Line 41: Line 42:
/* Import more specific scripts if necessary */
/* Import more specific scripts if necessary */


if (wgAction == "edit" || wgAction == "submit" || wgPageName == "Special:Upload") //scripts specific to editing pages
if (mw.config.get('wgAction') == "edit" || mw.config.get('wgAction') == "submit" || mw.config.get('wgPageName') == "Special:Upload") //scripts specific to editing pages
{
{
     importScript("MediaWiki:Common.js/edit.js")
     importScript("MediaWiki:Common.js/edit.js")
}
}
else if (wgPageName == "Special:Watchlist") //watchlist scripts
else if (mw.config.get('wgPageName') == "Special:Watchlist") //watchlist scripts
{
{
     importScript("MediaWiki:Common.js/watchlist.js")
     importScript("MediaWiki:Common.js/watchlist.js")
}
}
if( wgNamespaceNumber == 6 ) {
if( mw.config.get('wgNamespaceNumber') == 6 ) {
     importScript('MediaWiki:Common.js/file.js');
     importScript('MediaWiki:Common.js/file.js');
}
}
Line 58: Line 59:
  *              and accountcreator-specific CSS at [[MediaWiki:Accountcreator.css]].
  *              and accountcreator-specific CSS at [[MediaWiki:Accountcreator.css]].
  */
  */
if ( wgUserGroups ) {
if ( mw.config.get('wgUserGroups') ) {
   for ( var g = 0; g < wgUserGroups.length; ++g ) {
   for ( var g = 0; g < mw.config.get('wgUserGroups').length; ++g ) {
     if ( wgUserGroups[g] == "sysop" ) {
     if ( mw.config.get('wgUserGroups')[g] == "sysop" ) {
       importStylesheet("MediaWiki:Sysop.css");
       importStylesheet("MediaWiki:Sysop.css");
       addOnloadHook( function() {
       addOnloadHook( function() {
Line 68: Line 69:
       } );
       } );
     }  
     }  
     else if ( wgUserGroups[g] == "accountcreator" ) {
     else if ( mw.config.get('wgUserGroups')[g] == "accountcreator" ) {
       importStylesheet("MediaWiki:Accountcreator.css");
       importStylesheet("MediaWiki:Accountcreator.css");
     }
     }
Line 84: Line 85:
   */
   */


// if (wgServer == "https://secure.wikimedia.org") {
if (mw.config.get('wgServer') == "https://secure.wikimedia.org") {
if (location.protocol == 'https:') {
     var metaBase = "https://secure.wikimedia.org/wikipedia/meta";
     var metaBase = "https://secure.wikimedia.org/wikipedia/meta";
} else {
} else {
Line 421: Line 421:
// CLWB-214: wrap ensuring mediawiki.util is loaded.
// CLWB-214: wrap ensuring mediawiki.util is loaded.
mw.loader.using(['mediawiki.util'] ).then( function () {
mw.loader.using(['mediawiki.util'] ).then( function () {
    /* This callback is invoked as soon as the modules are available. */
     if (wgPageName == 'Main_Page' || wgPageName == 'Talk:Main_Page')  
     if (wgPageName == 'Main_Page' || wgPageName == 'Talk:Main_Page')  
         addOnloadHook(function () {
         addOnloadHook(function () {
Line 426: Line 427:
                     'Complete list', 'interwiki-completelist', 'Complete list of Wikipedias')
                     'Complete list', 'interwiki-completelist', 'Complete list of Wikipedias')
             var nstab = document.getElementById('ca-nstab-main')
             var nstab = document.getElementById('ca-nstab-main')
             if (nstab && wgUserLanguage=='en') {
             if (nstab && mw.config.get('wgUserLanguage')=='en') {
                 while (nstab.firstChild) nstab = nstab.firstChild
                 while (nstab.firstChild) nstab = nstab.firstChild
                 nstab.nodeValue = 'Main Page'
                 nstab.nodeValue = 'Main Page'
Line 433: Line 434:
     )
     )
} );
} );
/** Table sorting fixes ************************************************
/** Table sorting fixes ************************************************
   *
   *
Line 450: Line 449:
  ****/
  ****/
function uploadwizard_newusers() {
function uploadwizard_newusers() {
   if (wgNamespaceNumber == 4 && wgTitle == "Upload" && wgAction == "view") {
   if (mw.config.get('wgNamespaceNumber') == 4 && mw.config.get('wgTitle') == "Upload" && mw.config.get('wgAction') == "view") {
     var oldDiv = document.getElementById("autoconfirmedusers"),
     var oldDiv = document.getElementById("autoconfirmedusers"),
         newDiv = document.getElementById("newusers");
         newDiv = document.getElementById("newusers");
Line 476: Line 475:
var __ipv6wwwtest_factor = 100;
var __ipv6wwwtest_factor = 100;
var __ipv6wwwtest_done = 0;
var __ipv6wwwtest_done = 0;
if ((wgServer != "https://secure.wikimedia.org") && (Math.floor(Math.random()*__ipv6wwwtest_factor)==42)) {
if ((mw.config.get('wgServer') != "https://secure.wikimedia.org") && (Math.floor(Math.random()*__ipv6wwwtest_factor)==42)) {
     importScript("MediaWiki:Common.js/IPv6.js");
     importScript("MediaWiki:Common.js/IPv6.js");
}
}
Line 497: Line 496:




if (wgNamespaceNumber == 0) {
if (mw.config.get('wgNamespaceNumber') == 0) {
   addOnloadHook(function(){
   addOnloadHook(function(){
     if (document.getElementById('disambigbox'))
     if (document.getElementById('disambigbox'))
Line 521: Line 520:
  * Maintainers: [[User:TheDJ]]
  * Maintainers: [[User:TheDJ]]
  */
  */
if(wgServer == 'https://secure.wikimedia.org') {
if(mw.config.get('wgServer') == 'https://secure.wikimedia.org') {
     importScript( 'MediaWiki:Common.js/secure.js');
     importScript( 'MediaWiki:Common.js/secure.js');
}
}


//</source>
//</source>