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="{{ site.baseurl }}" class="wk">Weekly</a>
|
||||||
<a href="/periodicals/" class="pd">Periodical</a>
|
<a href="/periodicals/" class="pd">Periodical</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</header>
|
</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');
|
const currentTheme = localStorage.getItem('theme');
|
||||||
|
|
||||||
if (currentTheme) {
|
if (currentTheme) {
|
||||||
document.documentElement.setAttribute('data-theme', currentTheme);
|
document.documentElement.setAttribute('data-theme', currentTheme);
|
||||||
|
|
||||||
if (currentTheme === 'dark') {
|
if (currentTheme === 'dark') {
|
||||||
toggleSwitch.checked = true;
|
toggleSwitch.checked = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function switchTheme(e) {
|
function switchTheme(e) {
|
||||||
if (e.target.checked) {
|
if (e.target.checked) {
|
||||||
document.documentElement.setAttribute('data-theme', 'dark');
|
document.documentElement.setAttribute('data-theme', 'dark');
|
||||||
localStorage.setItem('theme', 'dark');
|
localStorage.setItem('theme', 'dark');
|
||||||
} else {
|
} else {
|
||||||
document.documentElement.setAttribute('data-theme', 'light');
|
document.documentElement.setAttribute('data-theme', 'light');
|
||||||
localStorage.setItem('theme', 'light');
|
localStorage.setItem('theme', 'light');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleSwitch.addEventListener('change', switchTheme, false);
|
toggleSwitch.addEventListener('change', switchTheme, false);
|
||||||
|
|
Loading…
Reference in a new issue