mirror of
https://github.com/luau-lang/luau.git
synced 2025-05-04 10:33:46 +01:00
Fix theme saving
This commit is contained in:
parent
e3ec320949
commit
e101e90054
2 changed files with 8 additions and 8 deletions
|
@ -43,16 +43,16 @@
|
||||||
<link rel="stylesheet alternate" href="{{ '/assets/css/theme2.css' | relative_url }}" id="theme_source_2">
|
<link rel="stylesheet alternate" href="{{ '/assets/css/theme2.css' | relative_url }}" id="theme_source_2">
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
let theme = sessionStorage.getItem('theme');
|
let theme = localStorage.getItem('theme');
|
||||||
if (theme === "dark") {
|
if (theme === "dark") {
|
||||||
sessionStorage.setItem('theme', 'dark');
|
localStorage.setItem('theme', 'dark');
|
||||||
node1 = document.getElementById('theme_source');
|
node1 = document.getElementById('theme_source');
|
||||||
node2 = document.getElementById('theme_source_2');
|
node2 = document.getElementById('theme_source_2');
|
||||||
node1.setAttribute('rel', 'stylesheet alternate');
|
node1.setAttribute('rel', 'stylesheet alternate');
|
||||||
node2.setAttribute('rel', 'stylesheet');
|
node2.setAttribute('rel', 'stylesheet');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sessionStorage.setItem('theme', 'light');
|
localStorage.setItem('theme', 'light');
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleTheme() {
|
function toggleTheme() {
|
||||||
|
@ -61,13 +61,13 @@
|
||||||
if (node1.getAttribute("rel") == "stylesheet") {
|
if (node1.getAttribute("rel") == "stylesheet") {
|
||||||
node1.setAttribute("rel", "stylesheet alternate");
|
node1.setAttribute("rel", "stylesheet alternate");
|
||||||
node2.setAttribute("rel", "stylesheet");
|
node2.setAttribute("rel", "stylesheet");
|
||||||
editor.setOption("theme", "dark");
|
try {editor?.setOption("theme", "dark")} catch {};
|
||||||
sessionStorage.setItem("theme", "dark");
|
localStorage.setItem("theme", "dark");
|
||||||
} else {
|
} else {
|
||||||
node2.setAttribute("rel", "stylesheet alternate");
|
node2.setAttribute("rel", "stylesheet alternate");
|
||||||
node1.setAttribute("rel", "stylesheet");
|
node1.setAttribute("rel", "stylesheet");
|
||||||
editor.setOption("theme", "light");
|
try {editor.setOption("theme", "light")} catch {};
|
||||||
sessionStorage.setItem("theme", "light");
|
localStorage.setItem("theme", "light");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,7 @@
|
||||||
<!-- CodeMirror Luau Editor (MUST BE LOADED AFTER CODEMIRROR!) -->
|
<!-- CodeMirror Luau Editor (MUST BE LOADED AFTER CODEMIRROR!) -->
|
||||||
<script>
|
<script>
|
||||||
var editor = CodeMirror.fromTextArea(document.getElementById("script"), {
|
var editor = CodeMirror.fromTextArea(document.getElementById("script"), {
|
||||||
theme: sessionStorage.getItem('theme'),
|
theme: localStorage.getItem('theme'),
|
||||||
mode: "luau",
|
mode: "luau",
|
||||||
matchBrackets: true,
|
matchBrackets: true,
|
||||||
lineNumbers: true,
|
lineNumbers: true,
|
||||||
|
|
Loading…
Add table
Reference in a new issue