Summary Files Commits Branches @commit @diff @stats
path: root / src / scripts
diff options
context:
space:
mode:
Commit7fdcdc6557d29678aedf936829f3169e006987b7 (patch)
Author
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-03-09 14:07:44 +0200
Committer
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-03-09 14:07:44 +0200
Files6be50bb1b2c405a7e0a3dab1fd3abd6a20ed9a75 /src/scripts
syndamia.com-7fdcdc6557d29678aedf936829f3169e006987b7.tar
syndamia.com-7fdcdc6557d29678aedf936829f3169e006987b7.tar.gz
syndamia.com-7fdcdc6557d29678aedf936829f3169e006987b7.zip
Parent0838de8e6861f2031160d39f7dfb7fe937a16b79 (diff)
Added simple functionality
3 files changed, 33 insertions, 1 deletions
-rw-r--r--src/scripts/image-show.js2
-rw-r--r--src/scripts/theme-changer-preload.js4
-rw-r--r--src/scripts/theme-changer.js28
diff --git a/src/scripts/image-show.js b/src/scripts/image-show.js
index 961242e..8664ef4 100644
--- a/src/scripts/image-show.js
+++ b/src/scripts/image-show.js
@@ -18,7 +18,7 @@ function clickToView() {
const images = document.getElementsByTagName('img');
for (const image of images) {
- if (image.alt !== '🔗' && image.id !== 'scrollBtn') {
+ if (image.alt !== '🔗' && !image.classList.contains('unzoomable')) {
image.onclick = clickToView;
}
}
diff --git a/src/scripts/theme-changer-preload.js b/src/scripts/theme-changer-preload.js
new file mode 100644
index 0000000..bb53b6c
--- /dev/null
+++ b/src/scripts/theme-changer-preload.js
@@ -0,0 +1,4 @@
+const darkThemeStyle = document.styleSheets[1];
+
+if (localStorage.getItem('theme') === 'light')
+ darkThemeStyle.disabled = true;
diff --git a/src/scripts/theme-changer.js b/src/scripts/theme-changer.js
new file mode 100644
index 0000000..5fd5f7c
--- /dev/null
+++ b/src/scripts/theme-changer.js
@@ -0,0 +1,28 @@
+const themeBtn = document.getElementById('changeThemeBtn');
+
+if (darkThemeStyle.disabled)
+ themeBtn.src = '/img/moon-tabler.svg';
+
+themeBtn.style.display = 'initial';
+
+function changeTheme(theme) {
+ if (theme === 'light') {
+ darkThemeStyle.disabled = true;
+ themeBtn.src = '/img/moon-tabler.svg';
+ }
+ else {
+ darkThemeStyle.disabled = false;
+ themeBtn.src = '/img/sun-tabler.svg';
+ }
+}
+
+themeBtn.onclick = function() {
+ if (localStorage.getItem('theme') !== 'light') {
+ changeTheme('light');
+ localStorage.setItem('theme', 'light');
+ }
+ else {
+ changeTheme('dark');
+ localStorage.setItem('theme', 'dark');
+ }
+}