User:MetalManeMc/vector.js: Difference between revisions
Jump to navigation
Jump to search
MetalManeMc (talk | contribs) No edit summary |
MetalManeMc (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
/** | /** | ||
* Toggle for dark mode testing | * Toggle for dark mode testing | ||
* | * Inspired from https://minecraft.wiki/w/MediaWiki:Gadget-darkmode.js | ||
*/ | */ | ||
Revision as of 19:37, 19 December 2023
/**
* Toggle for dark mode testing
* Inspired from https://minecraft.wiki/w/MediaWiki:Gadget-darkmode.js
*/
portletLink = mw.util.addPortletLink(
'p-personal',
'',
'',
'pt-dm-toggle',
'Preview in light mode',
null,
$('#pt-userpage, #pt-anonuserpage, #pt-createaccount')[0]
);
$(portletLink).find('a').click(function(e) {
e.preventDefault();
console.error(mw.user.options.get('theme'));
if (mw.user.options.get('theme')==='dark-grey') {
var params = {
action: 'options',
change: 'theme=light',
format: 'json'
},
api = new mw.Api();
mw.loader.using(['dark-grey']).then(function() {
$('body').addClass('light')
$('body').removeClass('dark-grey')
});
}
else {
var params = {
action: 'options',
change: 'theme=dark-grey',
format: 'json'
},
api = new mw.Api();
}
api.postWithToken( 'csrf', params ).done( function ( data ) {});
});