From fcafc83bf4f23ee5d7b39f6f47f0030d8f6a722a Mon Sep 17 00:00:00 2001 From: ache Date: Sun, 9 Apr 2023 05:09:57 +0200 Subject: Make a real Darkmode --- src/js/theme.js | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'src/js/theme.js') diff --git a/src/js/theme.js b/src/js/theme.js index fd0b755..4ac40ea 100644 --- a/src/js/theme.js +++ b/src/js/theme.js @@ -8,7 +8,11 @@ window.addEventListener('DOMContentLoaded', () => { const html = document.querySelector('html'); const aside = document.querySelector('#side-bar'); const sidenotes = document.querySelector('.sidenotes'); + const footnotes = document.querySelector('.footnotes'); const harr = document.querySelector('#harr'); + const links = document.querySelectorAll('a'); + const likes = document.querySelectorAll('.likes'); + const tables = document.querySelectorAll('table'); if (storageTheme === 'dark' || storageTheme === 'light') { const theme = storageTheme; @@ -19,6 +23,24 @@ window.addEventListener('DOMContentLoaded', () => { sidenotes.classList.add(theme); harr.classList.add(theme); + if(footnotes) { + footnotes.classList.add(theme); + } + + for (let link of links) { + link.classList.add(theme); + } + for (let likeBox of likes) { + likeBox.classList.add(theme); + } + for (let table of tables) { + table.classList.add(theme); + } + + for (const article of document.querySelectorAll('article')) { + article.classList.add(theme); + } + for (const article of document.querySelectorAll('article')) { article.classList.add(theme); } @@ -43,11 +65,32 @@ window.addEventListener('DOMContentLoaded', () => { if (!sidenotes.classList.replace(...arg)) { sidenotes.classList.add(theme); } + if (footnotes && !footnotes.classList.replace(...arg)) { + footnotes.classList.add(theme); + } + + if (!harr.classList.replace(...arg)) { harr.classList.add(theme); } + for (let link of links) { + if (!link.classList.replace(...arg)) { + link.classList.add(theme); + } + } + for (let table of tables) { + if (!table.classList.replace(...arg)) { + table.classList.add(theme); + } + } + for (let like of likes) { + if (!like.classList.replace(...arg)) { + like.classList.add(theme); + } + } + for (const article of document.querySelectorAll('article')) { if (!article.classList.replace(...arg)) { article.classList.add(theme); -- cgit v1.2.3-70-g09d2