User:Winny/common.js

From NetHackWiki
Jump to navigation Jump to search

Note: After saving, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
// Via https://en.wikipedia.org/wiki/User:PleaseStand/hide-vector-sidebar.js

( function ( mw, $ ) {
	var sidebarSwitch;

	function sidebarHide() {
		document.getElementById( 'mw-panel' ).style.visibility = 'hidden';
		document.getElementById( 'mw-head-base' ).style.marginLeft = '0';
		document.getElementById( 'content' ).style.marginLeft = '0';
		document.getElementById( 'left-navigation' ).style.marginLeft = '0';
		document.getElementById( 'footer' ).style.marginLeft = '0';
		if ( sidebarSwitch ) {
			sidebarSwitch.parentNode.removeChild(sidebarSwitch);
		}
		sidebarSwitch = mw.util.addPortletLink( 'p-cactions', '#', 'Show sidebar', 'ca-sidebar', 'Show the navigation links', 'a' );
		$( sidebarSwitch ).click( function ( e ) {
			e.preventDefault();
			sidebarShow();
		} );
	}
	
	function sidebarShow() {
		document.getElementById( 'mw-panel' ).style.visibility = '';
		document.getElementById( 'mw-head-base' ).style.marginLeft = '';
		document.getElementById( 'content' ).style.marginLeft = '';
		document.getElementById( 'left-navigation' ).style.marginLeft = '';
		document.getElementById( 'footer' ).style.marginLeft = '';
		if ( sidebarSwitch ) {
			sidebarSwitch.parentNode.removeChild(sidebarSwitch);
		}
		sidebarSwitch = mw.util.addPortletLink( 'p-cactions', '#', 'Hide sidebar', 'ca-sidebar', 'Hide the navigation links', 'a' );
		$( sidebarSwitch ).click( function ( e ) {
			e.preventDefault();
			sidebarHide();
		} );
	}
	
	// Only activate on Vector skin
	if ( mw.config.get( 'skin' ) === 'vector' ) {
		$.when($.ready,mw.loader.using('mediawiki.util')).then(function(){
			// Change this if you want to show the sidebar by default
			sidebarShow();
		} );
	}
	
}( mediaWiki, jQuery ) );