summaryrefslogtreecommitdiffstats
path: root/assets/js/theme-switch.js
diff options
context:
space:
mode:
authorSimone <26844016+simonebortolin@users.noreply.github.com>2022-12-30 17:54:00 +0100
committerGitHub <noreply@github.com>2022-12-30 17:54:00 +0100
commit9b16504485a14b477aa00ae33a43d91e7e4ce9e6 (patch)
tree5e1d9aba2b5e70055ed96daba87786d80cc6085e /assets/js/theme-switch.js
parentHot fix pages.yml (#74) (diff)
downloadhack-gpon.github.io-9b16504485a14b477aa00ae33a43d91e7e4ce9e6.tar
hack-gpon.github.io-9b16504485a14b477aa00ae33a43d91e7e4ce9e6.tar.gz
hack-gpon.github.io-9b16504485a14b477aa00ae33a43d91e7e4ce9e6.tar.bz2
hack-gpon.github.io-9b16504485a14b477aa00ae33a43d91e7e4ce9e6.tar.lz
hack-gpon.github.io-9b16504485a14b477aa00ae33a43d91e7e4ce9e6.tar.xz
hack-gpon.github.io-9b16504485a14b477aa00ae33a43d91e7e4ce9e6.tar.zst
hack-gpon.github.io-9b16504485a14b477aa00ae33a43d91e7e4ce9e6.zip
Diffstat (limited to '')
-rw-r--r--assets/js/theme-switch.js37
1 files changed, 0 insertions, 37 deletions
diff --git a/assets/js/theme-switch.js b/assets/js/theme-switch.js
deleted file mode 100644
index caffe6e..0000000
--- a/assets/js/theme-switch.js
+++ /dev/null
@@ -1,37 +0,0 @@
-if(localStorage.getItem("color-scheme") === null) {
- const newColorScheme = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ? "dark" : "light";
- const newTextScheme = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ? "Light mode" : "Dark mode";
- jtd.setTheme(newColorScheme);
- localStorage.setItem("color-scheme",newColorScheme);
- localStorage.setItem("text-scheme",newTextScheme);
- window.addEventListener('load', function () {
- toggleDarkMode.textContent = newTextScheme;
- });
-} else {
- jtd.setTheme(localStorage.getItem("color-scheme"));
- window.addEventListener('load', function () {
- toggleDarkMode.textContent = localStorage.getItem("text-scheme");
- });
-}
-
-window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
- if(localStorage.getItem("color-scheme") === null) {
- const newColorScheme = event.matches ? "dark" : "light";
- const newTextScheme = event.matches ? "Light mode" : "Dark mode";
- jtd.setTheme(newColorScheme);
- toggleDarkMode.textContent = newTextScheme;
- localStorage.setItem("color-scheme",newColorScheme);
- localStorage.setItem("text-scheme",newTextScheme);
- }
-});
-
-
-const toggleDarkMode = document.querySelector('.js-toggle-dark-mode');
-jtd.addEvent(toggleDarkMode, 'click', function(){
- const newColorScheme = jtd.getTheme() !== 'dark' ? "dark" : "light";
- const newTextScheme = jtd.getTheme() !== 'dark' ? "Light mode" : "Dark mode";
- jtd.setTheme(newColorScheme);
- toggleDarkMode.textContent = newTextScheme;
- localStorage.setItem("color-scheme",newColorScheme);
- localStorage.setItem("text-scheme",newTextScheme);
-}); \ No newline at end of file