Summary Files Commits Branches @commit @diff @stats
path: root / src / scripts
diff options
context:
space:
mode:
Commitc36d66558c7ddcff03397c07c89f0b819aa2f446 (patch)
Author
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-03-26 22:33:49 +0200
Committer
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-03-26 22:33:49 +0200
Filesffc3d3bd6411e43080f08459b925381812c35a5d /src/scripts
syndamia.com-c36d66558c7ddcff03397c07c89f0b819aa2f446.tar
syndamia.com-c36d66558c7ddcff03397c07c89f0b819aa2f446.tar.gz
syndamia.com-c36d66558c7ddcff03397c07c89f0b819aa2f446.zip
Parent4d8a85193efc355beaf7c175c9b0e4d8128cb84b (diff)
Added changing page width setting
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');
+ }
+}