Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
store darkmode in local storage
Browse files Browse the repository at this point in the history
  • Loading branch information
the-codeboy committed Feb 26, 2024
1 parent fd2ad31 commit 22def96
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,21 @@
</div>
<script>

if(window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches){
document.body.classList.add('dark-mode');
document.getElementById("darkModeSwitch").checked = true;
if (localStorage.getItem('darkMode') === 'true') {
document.body.classList.add('dark-mode');
document.getElementById('darkModeSwitch').checked = true;
} else {
document.getElementById('darkModeSwitch').checked = false;
}
else{
document.getElementById("darkModeSwitch").checked = false;

function toggleDarkMode() {
document.body.classList.toggle('dark-mode');
if (document.body.classList.contains('dark-mode')) {
localStorage.setItem('darkMode', 'true');
} else {
localStorage.setItem('darkMode', 'false');
}
}
function toggleDarkMode() {
document.body.classList.toggle('dark-mode');
}
</script>
<div class="container">
<h1 class="text-center mt-5 mb-4">Studyscraper: A Studydrive Downloader</h1>
Expand Down

0 comments on commit 22def96

Please sign in to comment.