Summary Files Commits Branches @commit @diff @stats
path: root / src / scripts / page-width.js
blob: 577c5909e857ee7be182c0bdee6044ec2f0365b0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
const widthBtn = document.getElementById('changeWidthBtn');
const articleElem = document.getElementsByTagName('article')[0];

if (localStorage.getItem('width') === 'wide') {
	widthBtn.src = '/img/viewport-narrow-tabler.svg';
	articleElem.classList.add('noMaxWidth');
}

widthBtn.onclick = function() {
	articleElem.classList.toggle('noMaxWidth');

	if (localStorage.getItem('width') !== 'norm') {
		widthBtn.src = '/img/viewport-wide-tabler.svg';
		localStorage.setItem('width', 'norm');
	}
	else {
		widthBtn.src = '/img/viewport-narrow-tabler.svg';
		localStorage.setItem('width', 'wide');
	}
}