Difference between revisions of "MediaWiki:Common.js"

From WikiConference North America
Jump to navigation Jump to search
(Update)
(This allows translations. See Template:LangSwitch)
Line 24: Line 24:
 
mw.util.addPortletLink( 'p-tb', '/wiki/Special:RecentChanges', 'Recent changes', 't-recentchanges', 'Recent changes ', 'r', '#t-recentchangeslinked' );
 
mw.util.addPortletLink( 'p-tb', '/wiki/Special:RecentChanges', 'Recent changes', 't-recentchanges', 'Recent changes ', 'r', '#t-recentchangeslinked' );
 
$( '#megaheader img' ).css( 'opacity', 1 ); /* Thank you Jack Phoenix! */
 
$( '#megaheader img' ).css( 'opacity', 1 ); /* Thank you Jack Phoenix! */
  +
});
  +
  +
/* This allows translations. See [[Template:LangSwitch]] */
  +
mw.loader.load('//commons.wikimedia.org/w/index.php?title=MediaWiki:AnonymousI18N.js&action=raw&ctype=text/javascript');
  +
  +
// Update from https://tools.wmflabs.org/intuition/wpAvailableLanguages.js.php - Last update: Fri, 06 Mar 2015 22:58:41 +0000
  +
window.wpAvailableLanguages={"en":"English","fr":"Français"};
  +
  +
/**
  +
* AnonymousI18N
  +
*
  +
* Internationalisation for anonymous users.
  +
*
  +
* @author [[User:Krinkle]]
  +
* @stats [[File:Krinkle_AnonymousI18N.js]]
  +
*/
  +
mw.loader.using( 'mediawiki.user', function () {
  +
if ( mw.user.isAnon() ) {
  +
mw.loader.load( '//commons.wikimedia.org/w/index.php?title=MediaWiki:AnonymousI18N.js&action=raw&ctype=text/javascript' );
  +
}
 
});
 
});

Revision as of 18:01, 3 February 2020

/* Interface modifications for anonymous users */

function removeSidebarSection(section) {
  try {
    var target = "p-" + section;
    var sidebar = document.getElementById("mw-panel");
    var element = document.getElementById(target);
    sidebar.removeChild(element);
  } catch (e) {
    return;
   }
}

function customizeSidebarForAnon() {
  removeSidebarSection("tb");
}

if (wgUserName == null) {
  addOnloadHook(customizeSidebarForAnon);
}

/* Add a few links to the toolbox */
addOnloadHook(function() {
  mw.util.addPortletLink( 'p-tb', '/wiki/Special:RecentChanges', 'Recent changes', 't-recentchanges', 'Recent changes ', 'r', '#t-recentchangeslinked' );
  $( '#megaheader img' ).css( 'opacity', 1 ); /* Thank you Jack Phoenix! */
});

/* This allows translations. See [[Template:LangSwitch]] */
mw.loader.load('//commons.wikimedia.org/w/index.php?title=MediaWiki:AnonymousI18N.js&action=raw&ctype=text/javascript');

// Update from https://tools.wmflabs.org/intuition/wpAvailableLanguages.js.php - Last update: Fri, 06 Mar 2015 22:58:41 +0000
window.wpAvailableLanguages={"en":"English","fr":"Français"};

/**
 * AnonymousI18N
 *
 * Internationalisation for anonymous users.
 *
 * @author [[User:Krinkle]]
 * @stats [[File:Krinkle_AnonymousI18N.js]]
 */
mw.loader.using( 'mediawiki.user', function () {
 if ( mw.user.isAnon() ) {
  mw.loader.load( '//commons.wikimedia.org/w/index.php?title=MediaWiki:AnonymousI18N.js&action=raw&ctype=text/javascript' );
 }
});