User:MetalManeMc/vector.js: Difference between revisions

From Baldur's Gate 3 Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 25: Line 25:
},
},
api = new mw.Api();
api = new mw.Api();
}
}
else {
var params = {
action: 'options',
change: 'theme=dark-grey',
format: 'json'
},
api = new mw.Api();
}
api.postWithToken( 'csrf', params ).done( function ( data ) {
api.postWithToken( 'csrf', params ).done( function ( data ) {
console.log( data );
console.log( data );

Revision as of 19:23, 19 December 2023

/**
 * Toggle for dark mode testing
 * 
 * @author [[User:MetalManeMc]] for use on the Baldur's Gate 3 Wiki
 */

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();
				}
				else {
					var params = {
						action: 'options',
						change: 'theme=dark-grey',
						format: 'json'
					},
					api = new mw.Api();
				}
				api.postWithToken( 'csrf', params ).done( function ( data ) {
					console.log( data );
				});
				
			});