Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

Fix bug where we can't go back to default when changing pages after theme changed

Just a for loop on load to select the right option
Cette révision appartient à :
akuma06 2017-05-26 17:02:19 +02:00
Parent 71d757bf4c
révision 21a06f7a0d

Voir le fichier

@ -41,13 +41,19 @@
}
}
function setTheme() {
document.getElementById('theme').href = "/css/" + localStorage.getItem('theme');
var themeFromStorage = localStorage.getItem('theme');
document.getElementById('theme').href = "/css/" + themeFromStorage;
window.addEventListener("load", () => {
var selectOptions = document.getElementById("theme_select").children
for (var option of selectOptions) {
option.selected = option.value == themeFromStorage;
}
});
}
</script>
<!-- Fix theme switching for google chrome where onload doesn't work -->
<script type="text/javascript">
var theme = localStorage.getItem("theme");
if (theme != "") document.getElementById("theme").href = "/css/" + theme;
setTheme();
</script>
{{ block "additional_header" .}}{{end}}
</head>
@ -99,7 +105,7 @@
<div class="container footer center">
<div class="footer-opt">
<select onchange="changeTheme(this.options[this.selectedIndex])" name="Theme" id="" class="form-input">
<select onchange="changeTheme(this.options[this.selectedIndex])" name="Theme" id="theme_select" class="form-input">
<option value="">Default</option>
<option value="g.css">/g/ Anon</option>
<option value="tomorrow.css">Tomorrow</option>