User:Willowisp/vector.js: Difference between revisions
Jump to navigation
Jump to search
(Created page with "→* * Toggle for dark mode testing * Inspired from https://minecraft.wiki/w/MediaWiki:Gadget-darkmode.js * Borrowed from https://bg3.wiki/wiki/User:MetalManeMc/vector.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('th...") |
No edit summary |
||
Line 1: | Line 1: | ||
/** | /** | ||
* Toggle for dark mode | * Toggle for dark mode | ||
* | * Originally from https://bg3.wiki/wiki/User:MetalManeMc/vector.js | ||
* | * which was based on https://minecraft.wiki/w/MediaWiki:Gadget-darkmode.js | ||
* which was itself based on https://minecraft.wiki/w/MediaWiki:Gadget-darkmode.js | |||
* @author [[User:Jayden]] | |||
* @see Based on https://runescape.wiki/w/MediaWiki:Gadget-skinTogglesNew.js | |||
*/ | */ | ||
Revision as of 20:29, 18 January 2024
/**
* Toggle for dark mode
* Originally from https://bg3.wiki/wiki/User:MetalManeMc/vector.js
* which was based on https://minecraft.wiki/w/MediaWiki:Gadget-darkmode.js
* which was itself based on https://minecraft.wiki/w/MediaWiki:Gadget-darkmode.js
* @author [[User:Jayden]]
* @see Based on https://runescape.wiki/w/MediaWiki:Gadget-skinTogglesNew.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 ) {});
});