mirror of
https://github.com/rottenwheel/revuo-weekly.git
synced 2024-12-22 15:47:46 +00:00
clean up
This commit is contained in:
parent
91ba1bb533
commit
2c39dffbeb
2 changed files with 11 additions and 12 deletions
|
@ -14,5 +14,4 @@
|
|||
<a href="{{ site.baseurl }}" class="wk">Weekly</a>
|
||||
<a href="/periodicals/" class="pd">Periodical</a>
|
||||
</div>
|
||||
|
||||
</header>
|
||||
|
|
22
js/main.js
22
js/main.js
|
@ -8,21 +8,21 @@ const toggleSwitch = document.querySelector('.switch input[type="checkbox"]');
|
|||
const currentTheme = localStorage.getItem('theme');
|
||||
|
||||
if (currentTheme) {
|
||||
document.documentElement.setAttribute('data-theme', currentTheme);
|
||||
|
||||
if (currentTheme === 'dark') {
|
||||
toggleSwitch.checked = true;
|
||||
}
|
||||
document.documentElement.setAttribute('data-theme', currentTheme);
|
||||
|
||||
if (currentTheme === 'dark') {
|
||||
toggleSwitch.checked = true;
|
||||
}
|
||||
}
|
||||
|
||||
function switchTheme(e) {
|
||||
if (e.target.checked) {
|
||||
document.documentElement.setAttribute('data-theme', 'dark');
|
||||
localStorage.setItem('theme', 'dark');
|
||||
} else {
|
||||
if (e.target.checked) {
|
||||
document.documentElement.setAttribute('data-theme', 'dark');
|
||||
localStorage.setItem('theme', 'dark');
|
||||
} else {
|
||||
document.documentElement.setAttribute('data-theme', 'light');
|
||||
localStorage.setItem('theme', 'light');
|
||||
}
|
||||
localStorage.setItem('theme', 'light');
|
||||
}
|
||||
}
|
||||
|
||||
toggleSwitch.addEventListener('change', switchTheme, false);
|
||||
|
|
Loading…
Reference in a new issue