Fix theme saving

This commit is contained in:
Someone-dQw4w9WgXcQ 2023-07-27 22:04:10 +01:00
parent e3ec320949
commit e101e90054
2 changed files with 8 additions and 8 deletions

View file

@ -43,16 +43,16 @@
<link rel="stylesheet alternate" href="{{ '/assets/css/theme2.css' | relative_url }}" id="theme_source_2">
<script>
let theme = sessionStorage.getItem('theme');
let theme = localStorage.getItem('theme');
if (theme === "dark") {
sessionStorage.setItem('theme', 'dark');
localStorage.setItem('theme', 'dark');
node1 = document.getElementById('theme_source');
node2 = document.getElementById('theme_source_2');
node1.setAttribute('rel', 'stylesheet alternate');
node2.setAttribute('rel', 'stylesheet');
}
else {
sessionStorage.setItem('theme', 'light');
localStorage.setItem('theme', 'light');
}
function toggleTheme() {
@ -61,13 +61,13 @@
if (node1.getAttribute("rel") == "stylesheet") {
node1.setAttribute("rel", "stylesheet alternate");
node2.setAttribute("rel", "stylesheet");
editor.setOption("theme", "dark");
sessionStorage.setItem("theme", "dark");
try {editor?.setOption("theme", "dark")} catch {};
localStorage.setItem("theme", "dark");
} else {
node2.setAttribute("rel", "stylesheet alternate");
node1.setAttribute("rel", "stylesheet");
editor.setOption("theme", "light");
sessionStorage.setItem("theme", "light");
try {editor.setOption("theme", "light")} catch {};
localStorage.setItem("theme", "light");
}
return false;
}

View file

@ -89,7 +89,7 @@
<!-- CodeMirror Luau Editor (MUST BE LOADED AFTER CODEMIRROR!) -->
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("script"), {
theme: sessionStorage.getItem('theme'),
theme: localStorage.getItem('theme'),
mode: "luau",
matchBrackets: true,
lineNumbers: true,