Use localStorage for the selected theme in the docs

This commit is contained in:
Lonami Exo
2018-06-27 10:36:56 +02:00
parent 4be248932d
commit a1799ee74b
2 changed files with 3 additions and 5 deletions

View File

@@ -11,7 +11,7 @@
// setTheme(<link />, 'light' / 'dark')
function setTheme(theme) {
document.cookie = 'css=' + theme + '; path=/';
localStorage.setItem('theme', theme);
return style.href = 'css/docs.' + theme + '.css';
}
@@ -24,9 +24,7 @@
});
}
setTheme(document.cookie
.split(';')[0]
.split('=')[1] || 'light');
setTheme(localStorage.getItem('theme') || 'light');
document.addEventListener('DOMContentLoaded', function () {
setThemeOnClick('light', document.getElementById('themeLight'));