Update theme switching code

This commit is contained in:
Kognise 2019-04-05 09:21:05 -04:00
parent aabd59c3ea
commit 5ae08050ad
No known key found for this signature in database
GPG key ID: 19AA40F6884A36D6

View file

@ -1,11 +1,11 @@
document.getElementById('switch').addEventListener('click', () => {
const { body } = document
const ph = document.getElementById('ph')
if (body.className) {
body.className = ''
if (body.classList.contains('light')) {
body.classList.remove('light')
ph.src = ph.src.replace('theme=light', 'theme=dark')
} else {
body.className = 'light'
body.classList.add('light')
ph.src = ph.src.replace('theme=dark', 'theme=light')
}
})