update - dark-mode button now changes the text according to the state.

This commit is contained in:
ZanzyTHEbar 2022-05-11 14:58:27 +02:00
parent bb57ec595d
commit cc95ca560d
2 changed files with 17 additions and 11 deletions

View File

@ -2,3 +2,17 @@
<a href="javascript:toggleDetect()" title="Switching Schemes" class="btn btn-mode fs-2 mb-1 mb-md-0 mr-0" <a href="javascript:toggleDetect()" title="Switching Schemes" class="btn btn-mode fs-2 mb-1 mb-md-0 mr-0"
id="switch-mode">Dark Mode</a> id="switch-mode">Dark Mode</a>
</ul> </ul>
<script type="text/javascript">
const switch_scheme = document.getElementById("switch-mode");
var isClicked = false;
async function toggleDetect() {
if (isClicked == false) {
isClicked = true;
switch_scheme.textContent = "Light Mode";
} else {
isClicked = false;
switch_scheme.textContent = "Dark Mode";
}
await switchScheme(isClicked);
}
</script>

View File

@ -1,17 +1,9 @@
var isClicked = false;
async function toggleDetect() {
if (isClicked == false) {
isClicked = true;
} else {
isClicked = false;
}
await switchScheme(isClicked);
}
async function switchScheme(isClicked) { async function switchScheme(isClicked) {
if (isClicked == true) { if (isClicked == true) {
jtd.setTheme("eyetrackvr"); jtd.setTheme("eyetrackvr");
switch_scheme.textContent = "Light Mode";
} else { } else {
jtd.setTheme("light"); jtd.setTheme("light");
switch_scheme.textContent = "Dark Mode";
} }
} }