User:Monster Domosed/common.js: Difference between revisions

Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
/*mw.loader.load('https://deadlock.wiki/index.php?title=User:Monster_Domosed/Wiki_Redesign.js&action=raw&ctype=text/javascript');*/
/*mw.loader.load('https://deadlock.wiki/index.php?title=User:Monster_Domosed/Wiki_Redesign.js&action=raw&ctype=text/javascript');*/


(function () {
(function () {(function () {
    function applyState(enabled) {
    const enabled = localStorage.getItem('fixedWidth') === 'true';
        const root = document.documentElement;


         root.classList.toggle('fixed-width-mode', enabled);
    if (enabled) {
         document.documentElement.classList.add('fixed-width-mode');
    }


         localStorage.setItem('fixedWidth', enabled);
    function applyState(value) {
        document.documentElement.classList.toggle('fixed-width-mode', value);
         localStorage.setItem('fixedWidth', value);
     }
     }


     mw.hook('wikipage.content').add(function () {
     function init() {
 
        const enabled = localStorage.getItem('fixedWidth') === 'true';
        applyState(enabled);
 
         const link = mw.util.addPortletLink(
         const link = mw.util.addPortletLink(
             'p-personal',
             'p-personal',
Line 32: Line 31:
         a.addEventListener('click', function (e) {
         a.addEventListener('click', function (e) {
             e.preventDefault();
             e.preventDefault();
             const now = !document.documentElement.classList.contains('fixed-width-mode');
             const next = !document.documentElement.classList.contains('fixed-width-mode');
             applyState(now);
             applyState(next);
         });
         });
     });
     }
 
    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', init);
    } else {
        init();
    }
})();
})();