Skip to content

Commit

Permalink
Skript ausgebessert
Browse files Browse the repository at this point in the history
  • Loading branch information
KTuff committed Oct 24, 2023
1 parent 7b8ee26 commit 9507b81
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,24 +172,29 @@
<script src="https://cdn.jsdelivr.net/npm/vue-router/dist/vue-router.js"></script>
<script src="app.js"></script>
<script>
function setTheme(theme) {
const html = document.documentElement;
html.setAttribute('class', theme);
localStorage.setItem('theme', theme);
}

function switchTheme() {
const themeName = localStorage.getItem('theme') || 'light';
const themeName = localStorage.getItem('theme');
if (themeName === 'dark') {
theme = 'light';
} else if (themeName === 'light') {
theme = 'dark';
} else {
theme = 'dark';
}

const html = document.documentElement;
html.setAttribute('class', theme);
localStorage.setItem('theme', theme);
setTheme(theme);
}

const button = document.getElementById('theme-button');
window.onload = () => {
button.addEventListener('click', switchTheme);

const theme = localStorage.getItem('theme') || 'light';
setTheme(theme);
}
</script>
</body>
Expand Down

0 comments on commit 9507b81

Please sign in to comment.