Fixed theme chooser not displayed upon first connection and some cleanup

This commit is contained in:
Julien Dessaux 2023-01-28 23:21:42 +01:00
parent 9ab3804aec
commit 7ab6159c7f
Signed by: adyxax
GPG key ID: F92E51B86E07177E
3 changed files with 5 additions and 8 deletions

View file

@ -1,15 +1,15 @@
<script>
function setTheme() {
const themeName = document.getElementById('themes').value;
localStorage.setItem('theme', themeName);
document.documentElement.className = themeName;
localStorage.setItem('theme', themeName);
}
(function () { // Set the theme on page load
const elt = document.getElementById('themes');
elt.style.display = 'block';
const themeName = localStorage.getItem('theme');
if (themeName) {
document.documentElement.className = themeName;
const elt = document.getElementById('themes');
elt.style.display = "block";
elt.value = themeName;
}
})();