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

if (localStorage.getItem('width') === 'wide') {
	widthLabel.innerText = 'Narrow';
	articleElem.classList.add('wide');
	sidebarHeaderElem.classList.toggle('wide');
}

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

	if (localStorage.getItem('width') !== 'norm') {
		widthLabel.innerText = 'Wide';
		localStorage.setItem('width', 'norm');
	}
	else {
		widthLabel.innerText = 'Narrow';
		localStorage.setItem('width', 'wide');
	}

	fixAbsoluteSlideScale(); // From presentation.js
}