MediaWiki:Vector.js: Difference between revisions

MediaWiki interface page
(attempting to fix toggles not appearing after being used by making the portlet addition method last in the condition)
(Blanked the page)
Tag: Blanking
 
(One intermediate revision 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' ) === null ) {
    mw.storage.set('client-dark-mode-toggle', '1');
    location.reload();
    var node = mw.util.addPortletLink( 'p-personal', '#', 'Light mode', 'pt-lightmode', '', 'np', '#pt-watchlist' );
  }
  else if ( mw.storage.get( 'client-dark-mode-toggle' ) === '1' ) {
    $(node).on( 'click', function( e ) {
      e.preventDefault();
      mw.storage.set('client-dark-mode-toggle', '0');
      location.reload();
    } );
    var node = mw.util.addPortletLink( 'p-personal', '#', 'Light mode', 'pt-lightmode', '', 'np', '#pt-watchlist' );
  } else {
    $(node).on( 'click', function( e ) {
      e.preventDefault();
      mw.storage.set('client-dark-mode-toggle', '1');
      location.reload();
    } );
    var node = mw.util.addPortletLink( 'p-personal', '#', 'Dark mode', 'pt-darkmode', '', 'np', '#pt-watchlist' );
  }
 
  if (mw.storage.get('client-monochrome-toggle') === '1') {
    $(node).on('click', function(e) {
      e.preventDefault();
      mw.storage.set('client-monochrome-toggle', '0');
      location.reload();
    });
    var node = mw.util.addPortletLink('p-personal', '#', 'Colorful mode', 'pt-colorful', 'Enable Colorful Text', 'c', '#pt-preferences');
  } else {
    $(node).on('click', function(e) {
      e.preventDefault();
      mw.storage.set('client-monochrome-toggle', '1');
      location.reload();
    });
    var node = mw.util.addPortletLink('p-personal', '#', 'Monochrome mode', 'pt-monochrome', 'Disable Colorful Text', 'c', '#pt-preferences');
  }
} );

Latest revision as of 00:52, 2 January 2023