User:MetalManeMc/vector.js: Difference between revisions

From bg3.wiki
Jump to navigation Jump to search
No edit summary
Tag: Reverted
(Undo revision 147274 by MetalManeMc (talk))
Tag: Undo
 
Line 1: Line 1:
/**
* Spoiler test
*/
function spoilerToggle() {
  var element = document.getElementById("spoiler");
  element.classList.toggle("no-spoilers");
}
function ispoilerToggle() {
  var element = document.getElementById("ispoiler");
  element.classList.toggle("no-spoilers");
}
function iispoilerToggle() {
  var element = document.getElementById("iispoiler");
  element.classList.toggle("no-spoilers");
}
function iiispoilerToggle() {
  var element = document.getElementById("iiispoiler");
  element.classList.toggle("no-spoilers");
}
/**
/**
  * Toggle for dark mode testing
  * Toggle for dark mode testing

Latest revision as of 16:16, 27 January 2024

/**
 * 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();
	if (mw.user.options.get('theme')==='dark-grey') {
		var params = {
			action: 'options',
			change: 'theme=light',
			format: 'json'
		};
		$('body').addClass('theme-light')
		$('body').removeClass('theme-dark-grey')
	}
	else {
		var params = {
			action: 'options',
			change: 'theme=dark-grey',
			format: 'json'
		};
        mw.loader.using(['ext.darkvector']).then(function() {
        	$('body').addClass('theme-dark-grey');
        	$('body').removeClass('theme-light');
        });
	}
	new mw.Api().postWithToken( 'csrf', params ).done( function ( data ) {});
});