User:Monster Domosed/common.js: Difference between revisionsGive feedback
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 () { | ||
const enabled = localStorage.getItem('fixedWidth') === 'true'; | |||
if (enabled) { | |||
document.documentElement.classList.add('fixed-width-mode'); | |||
} | |||
localStorage.setItem('fixedWidth', | function applyState(value) { | ||
document.documentElement.classList.toggle('fixed-width-mode', value); | |||
localStorage.setItem('fixedWidth', value); | |||
} | } | ||
function init() { | |||
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 | const next = !document.documentElement.classList.contains('fixed-width-mode'); | ||
applyState( | applyState(next); | ||
}); | }); | ||
}); | } | ||
if (document.readyState === 'loading') { | |||
document.addEventListener('DOMContentLoaded', init); | |||
} else { | |||
init(); | |||
} | |||
})(); | })(); | ||