MediaWiki:Vector.js: Difference between revisions

MediaWiki interface page
m (experimental commit, revert after seeing output)
(Blanked the page)
Tag: Blanking
 
(32 intermediate revisions by the same user not shown)
Line 1: Line 1:
/* 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' );
    mw.util.addPortletLink( 'p-personal', '#', 'Colorful mode', 'pt-colorful', '', 'np', '#pt-watchlist' );
  }
  else {
    mw.util.addPortletLink( 'p-personal', '#', 'Dark mode', 'pt-darkmode', '', 'np', '#pt-watchlist' );
    mw.util.addPortletLink( 'p-personal', '#', 'Monochrome mode', 'pt-monochrome', '', '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();
    } );
    $( '#pt-monochrome' ).on( 'click', function( e ) {
      var $html = $( 'html' );
      e.preventDefault();
      mw.storage.set('client-monochrome-toggle', '1');
      location.reload();
    } );
    $( '#pt-colorful' ).on( 'click', function( e ) {
      var $html = $( 'html' );
      e.preventDefault();
      mw.storage.set('client-monochrome-toggle', '0');
      location.reload();
    } );
  } );
} );

Latest revision as of 00:52, 2 January 2023