mirror of
https://github.com/rottenwheel/revuo-weekly.git
synced 2024-11-22 19:13:29 +01:00
clean up
This commit is contained in:
parent
91ba1bb533
commit
2c39dffbeb
@ -14,5 +14,4 @@
|
||||
<a href="{{ site.baseurl }}" class="wk">Weekly</a>
|
||||
<a href="/periodicals/" class="pd">Periodical</a>
|
||||
</div>
|
||||
|
||||
</header>
|
||||
|
20
js/main.js
20
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);
|
||||
document.documentElement.setAttribute('data-theme', currentTheme);
|
||||
|
||||
if (currentTheme === 'dark') {
|
||||
toggleSwitch.checked = true;
|
||||
}
|
||||
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 New Issue
Block a user