Summary Files Commits Branches @commit @diff @stats
path: root / src / scripts
diff options
context:
space:
mode:
1 files changed, 20 insertions, 0 deletions
-rw-r--r--src/scripts/page-width.js20
diff --git a/src/scripts/page-width.js b/src/scripts/page-width.js
new file mode 100644
index 0000000..577c590
--- /dev/null
+++ b/src/scripts/page-width.js
@@ -0,0 +1,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');
+ }
+}