MediaWiki:Vector.js

From Dustloop Wiki
Revision as of 18:25, 28 September 2022 by PrivateTarkus (talk | contribs) (Undo revision 332489 by PrivateTarkus (talk))
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 / Edge: 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.
/* 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' ) {
    var node = mw.util.addPortletLink( 'p-personal', '#', 'Light mode', 'pt-lightmode', '', 'np', '#pt-watchlist' );
    $(node).on( 'click', function( e ) {
      e.preventDefault();
      mw.storage.set('client-dark-mode-toggle', '0');
      location.reload();
    } );
  } else {
    var node = mw.util.addPortletLink( 'p-personal', '#', 'Dark mode', 'pt-darkmode', '', 'np', '#pt-watchlist' );
    $(node).on( 'click', function( e ) {
      e.preventDefault();
      mw.storage.set('client-dark-mode-toggle', '1');
      location.reload();
    } );
  }
  
  if (mw.storage.get('client-monochrome-toggle') === '1') {
    var node = mw.util.addPortletLink('p-personal', '#', 'Colorful mode', 'pt-colorful', 'Enable Colorful Text', 'c', '#pt-preferences');
    $(node).on('click', function(e) {
      e.preventDefault();
      mw.storage.set('client-monochrome-toggle', '0');
      location.reload();
    });
  } else {
    var node = mw.util.addPortletLink('p-personal', '#', 'Monochrome mode', 'pt-monochrome', 'Disable Colorful Text', 'c', '#pt-preferences');
    $(node).on('click', function(e) {
      e.preventDefault();
      mw.storage.set('client-monochrome-toggle', '1');
      location.reload();
    });
  }
} );