MediaWiki:Vector.js

MediaWiki interface page
Revision as of 19:01, 23 May 2022 by PrivateTarkus (talk | contribs) (Undo revision 278296 by PrivateTarkus (talk))

Note: After publishing, 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 / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/* All JavaScript here will be loaded for users of the Vector skin */
mw.loader.using( 'mediawiki.storage' ).then( function () {
    if ( mw.storage.get( 'client-dark-mode-toggle' ) === '1' ) {
    	mw.util.addPortletLink( 'p-personal', '#', 'Light mode', 'pt-lightmode', '', 'np', '#pt-watchlist' );
	} else {
    mw.util.addPortletLink( 'p-personal', '#', 'Dark mode', 'pt-darkmode', '', 'np', '#pt-watchlist' );
	}
	$( function () {
	    $( '#pt-darkmode' ).on( 'click', function( e ) {
	    	var $html = $( 'html' );
	        e.preventDefault();
	        mw.storage.set('client-dark-mode-toggle', '1');
	        location.reload();
	    } );
 
	    $( '#pt-lightmode' ).on( 'click', function( e ) {
	    	var $html = $( 'html' );
	        e.preventDefault();
	        mw.storage.set('client-dark-mode-toggle', '0');
	        location.reload();
	    } );
	} );
} );