diff options
Diffstat (limited to 'js/quest-log/quest.js')
-rw-r--r-- | js/quest-log/quest.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/js/quest-log/quest.js b/js/quest-log/quest.js index 0ba5a9d..8acd391 100644 --- a/js/quest-log/quest.js +++ b/js/quest-log/quest.js @@ -1,5 +1,6 @@ document.addEventListener("DOMContentLoaded", () => { loadQuests(); + loadTheme(); document.getElementById("new-quest").addEventListener("keypress", handleEnterKey(addQuest)); }); @@ -149,3 +150,18 @@ const getShowCompletedState = () => const toggleCompletedButtonText = showCompleted => document.querySelector("button[onclick='toggleCompleted()']").innerText = showCompleted ? "Hide Completed Quests" : "View Completed Quests"; + +const loadTheme = () => { + const savedTheme = localStorage.getItem('theme') || 'light'; + applyTheme(savedTheme); + document.getElementById('theme-selector').value = savedTheme; +}; + +const changeTheme = (theme) => { + applyTheme(theme); + localStorage.setItem('theme', theme); +}; + +const applyTheme = (theme) => { + document.documentElement.setAttribute('data-theme', theme); +}; |