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: | ||
/** | /** | ||
* | * @author MarkusRost | ||
* | **/ | ||
portletLink = mw.util.addPortletLink( | 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.isAnon()) { | |||
if (mw.cookie.get('theme',null,'dark-grey')==='dark-grey') { | |||
mw.cookie.set('theme','light'); | |||
mw.loader.using(['ext.gadget.theme-light']).then(function() { | |||
$('body').addClass('theme-light'); | |||
$('body').removeClass('theme-dark-grey'); | |||
}); | |||
} | |||
else { | |||
mw.cookie.set('theme','dark-grey'); | |||
$('body').addClass('theme-dark-grey'); | |||
$('body').removeClass('theme-light'); | |||
} | |||
} | |||
else { | |||
if (mw.user.options.get('userjs-theme','dark-grey')==='dark-grey') { | |||
new mw.Api().saveOption('userjs-theme','light').then(function() { | |||
mw.user.options.set('userjs-theme','light'); | |||
mw.loader.using(['ext.gadget.theme-light']).then(function() { | |||
$('body').addClass('theme-light'); | |||
$('body').removeClass('theme-dark-grey'); | |||
}); | |||
}); | |||
} | |||
else { | |||
new mw.Api().saveOption('userjs-theme','dark-grey').then(function() { | |||
mw.user.options.set('userjs-theme','dark-grey'); | |||
$('body').addClass('theme-dark-grey'); | |||
$('body').removeClass('theme-light'); | |||
}); | |||
} | |||
} | |||
}); |
Revision as of 22:43, 19 December 2023
/**
* @author MarkusRost
**/
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.isAnon()) {
if (mw.cookie.get('theme',null,'dark-grey')==='dark-grey') {
mw.cookie.set('theme','light');
mw.loader.using(['ext.gadget.theme-light']).then(function() {
$('body').addClass('theme-light');
$('body').removeClass('theme-dark-grey');
});
}
else {
mw.cookie.set('theme','dark-grey');
$('body').addClass('theme-dark-grey');
$('body').removeClass('theme-light');
}
}
else {
if (mw.user.options.get('userjs-theme','dark-grey')==='dark-grey') {
new mw.Api().saveOption('userjs-theme','light').then(function() {
mw.user.options.set('userjs-theme','light');
mw.loader.using(['ext.gadget.theme-light']).then(function() {
$('body').addClass('theme-light');
$('body').removeClass('theme-dark-grey');
});
});
}
else {
new mw.Api().saveOption('userjs-theme','dark-grey').then(function() {
mw.user.options.set('userjs-theme','dark-grey');
$('body').addClass('theme-dark-grey');
$('body').removeClass('theme-light');
});
}
}
});