summaryrefslogtreecommitdiff
path: root/public/js/theme.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/js/theme.js')
-rw-r--r--public/js/theme.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/public/js/theme.js b/public/js/theme.js
new file mode 100644
index 0000000..be2a9d1
--- /dev/null
+++ b/public/js/theme.js
@@ -0,0 +1,22 @@
+const key = 'current_emily_zola_style';
+
+function getTheme() {
+ let theme = document.getElementById('stylesheet');
+ let current_style = localStorage.getItem(key);
+ if (current_style === null) {
+ localStorage.setItem(key, theme.href);
+ }
+ theme.href = localStorage.getItem(key);
+}
+
+function changeTheme() {
+ let current_style = localStorage.getItem(key);
+ if (current_style.includes('dark')) {
+ localStorage.setItem(key, '/light.css');
+ }
+ else {
+ localStorage.setItem(key, '/dark.css');
+ }
+ let theme = document.getElementById('stylesheet');
+ theme.href = localStorage.getItem(key);
+} \ No newline at end of file