summaryrefslogtreecommitdiff
path: root/live/static/scripts/theme.js
diff options
context:
space:
mode:
authorDavid Luevano Alvarado <david@luevano.xyz>2024-03-07 21:55:16 -0600
committerDavid Luevano Alvarado <david@luevano.xyz>2024-03-07 21:55:16 -0600
commitbd86f4fc950cdc5bb4cb346f48c14a6e356dc4fb (patch)
treec1cebd6a0b48c38e2100d8e4fe9745fd7f585bd5 /live/static/scripts/theme.js
parentca9c5626495c00f6d6cffd4ae517a66db15b0832 (diff)
stop tracking live/main
Diffstat (limited to 'live/static/scripts/theme.js')
-rw-r--r--live/static/scripts/theme.js35
1 files changed, 0 insertions, 35 deletions
diff --git a/live/static/scripts/theme.js b/live/static/scripts/theme.js
deleted file mode 100644
index a107101..0000000
--- a/live/static/scripts/theme.js
+++ /dev/null
@@ -1,35 +0,0 @@
-// refactored code for a better solution found in:
-// https://medium.com/@haxzie/dark-and-light-theme-switcher-using-css-variables-and-pure-javascript-zocada-dd0059d72fa2
-var local_storage = window.localStorage;
-
-// changed window.onload to document.addEventListener, as suggested here:
-// https://stackoverflow.com/a/800010
-document.addEventListener("DOMContentLoaded", function(event) {
- let theme = local_storage.getItem('theme');
-
- if(theme == null){
- local_storage.setItem('theme', 'theme-dark');
- }
- else{
- if(theme == 'theme-dark'){
- setTheme('theme-dark');
- }
- else{
- setTheme('theme-light');
- }
- }
-})
-
-function setTheme(themeName){
- local_storage.setItem('theme', themeName)
- document.documentElement.className = themeName;
-}
-
-function toggleTheme(){
- if (local_storage.getItem('theme') == 'theme-dark') {
- setTheme('theme-light');
- }
- else{
- setTheme('theme-dark');
- }
-}