User:MetalManeMc/vector.js: Difference between revisions

From Baldur's Gate 3 Wiki
Jump to navigation Jump to search
(Undo revision 130971 by MetalManeMc (talk))
Tag: Undo
No edit summary
Line 24: Line 24:
},
},
api = new mw.Api();
api = new mw.Api();
mw.loader.using(['theme.dark-grey']).then(function() {
$('body').addClass('theme-light')
  $('body').addClass('theme-light')
$('body').removeClass('theme-dark-grey')
  $('body').removeClass('theme-dark-grey')
});
}
}
else {
else {
Line 36: Line 34:
},
},
api = new mw.Api();
api = new mw.Api();
                mw.loader.using(['ext.gadget.theme-light']).then(function() {
                    $('body').addClass('theme-light');
                    $('body').removeClass('theme-dark-grey');
                });
}
}
api.postWithToken( 'csrf', params ).done( function ( data ) {});
api.postWithToken( 'csrf', params ).done( function ( data ) {});
});
});

Revision as of 11:13, 20 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();
					$('body').addClass('theme-light')
					$('body').removeClass('theme-dark-grey')
				}
				else {
					var params = {
						action: 'options',
						change: 'theme=dark-grey',
						format: 'json'
					},
					api = new mw.Api();
                	mw.loader.using(['ext.gadget.theme-light']).then(function() {
                    	$('body').addClass('theme-light');
                    	$('body').removeClass('theme-dark-grey');
                	});
				}
				api.postWithToken( 'csrf', params ).done( function ( data ) {});
				
			});