This commit is contained in:
MeiK
2021-12-07 16:08:11 +08:00
parent 66a79971fd
commit 6408815d38

View File

@@ -1,18 +1,22 @@
function switchTheme() { function switchTheme() {
const currentStyle = currentTheme(); const currentStyle = currentTheme();
var iconElement = document.getElementById('github-icon'); const iconElement = document.getElementById('github-icon');
if (currentStyle == 'light') { if (currentStyle === 'light') {
setTheme('dark'); setTheme('dark');
if (iconElement) {
iconElement.setAttribute('class', 'octicon'); iconElement.setAttribute('class', 'octicon');
iconElement.setAttribute('color', '#f0f6fc'); iconElement.setAttribute('color', '#f0f6fc');
} }
}
else { else {
setTheme('light'); setTheme('light');
if (iconElement) {
iconElement.removeAttribute('color'); iconElement.removeAttribute('color');
iconElement.removeAttribute('class'); iconElement.removeAttribute('class');
} }
} }
}
function setTheme(style) { function setTheme(style) {
document.querySelectorAll('.isInitialToggle').forEach(elem => { document.querySelectorAll('.isInitialToggle').forEach(elem => {