(attempting to fix toggles not appearing after being used by making the portlet addition method last in the condition) |
(Undo revision 332809 by PrivateTarkus (talk)) Tag: Undo |
||
Line 2: | Line 2: | ||
mw.loader.using( 'mediawiki.storage' ).then( function () { | mw.loader.using( 'mediawiki.storage' ).then( function () { | ||
if ( mw.storage.get( 'client-dark-mode-toggle' ) === null ) { | if ( mw.storage.get( 'client-dark-mode-toggle' ) === null ) { | ||
var node = mw.util.addPortletLink( 'p-personal', '#', 'Light mode', 'pt-lightmode', '', 'np', '#pt-watchlist' ); | |||
mw.storage.set('client-dark-mode-toggle', '1'); | mw.storage.set('client-dark-mode-toggle', '1'); | ||
location.reload(); | location.reload(); | ||
} | } | ||
else if ( mw.storage.get( 'client-dark-mode-toggle' ) === '1' ) { | else 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 ) { | $(node).on( 'click', function( e ) { | ||
e.preventDefault(); | e.preventDefault(); | ||
Line 12: | Line 13: | ||
location.reload(); | location.reload(); | ||
} ); | } ); | ||
} else { | } else { | ||
var node = mw.util.addPortletLink( 'p-personal', '#', 'Dark mode', 'pt-darkmode', '', 'np', '#pt-watchlist' ); | |||
$(node).on( 'click', function( e ) { | $(node).on( 'click', function( e ) { | ||
e.preventDefault(); | e.preventDefault(); | ||
Line 19: | Line 20: | ||
location.reload(); | location.reload(); | ||
} ); | } ); | ||
} | } | ||
if (mw.storage.get('client-monochrome-toggle') === '1') { | 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) { | $(node).on('click', function(e) { | ||
e.preventDefault(); | e.preventDefault(); | ||
Line 28: | Line 29: | ||
location.reload(); | location.reload(); | ||
}); | }); | ||
} else { | } else { | ||
var node = mw.util.addPortletLink('p-personal', '#', 'Monochrome mode', 'pt-monochrome', 'Disable Colorful Text', 'c', '#pt-preferences'); | |||
$(node).on('click', function(e) { | $(node).on('click', function(e) { | ||
e.preventDefault(); | e.preventDefault(); | ||
Line 35: | Line 36: | ||
location.reload(); | location.reload(); | ||
}); | }); | ||
} | } | ||
} ); | } ); |
Revision as of 18:09, 29 September 2022
/* 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 ) {
var node = mw.util.addPortletLink( 'p-personal', '#', 'Light mode', 'pt-lightmode', '', 'np', '#pt-watchlist' );
mw.storage.set('client-dark-mode-toggle', '1');
location.reload();
}
else 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();
});
}
} );