mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
Prettified Code!
This commit is contained in:
parent
c280ab0a54
commit
91bebcd6a8
|
@ -162,13 +162,15 @@ window.addEventListener("DOMContentLoaded", () => {
|
|||
document.getElementById("bootstrap_theme").href = escape(theme_path);
|
||||
document.querySelector("html").setAttribute("data-bs-theme", "dark");
|
||||
} else if (config.theme == "default_auto") {
|
||||
|
||||
var theme_path = "../node_modules/bootstrap/dist/css/bootstrap.min.css";
|
||||
document.getElementById("bootstrap_theme").href = escape(theme_path);
|
||||
|
||||
// https://stackoverflow.com/a/57795495
|
||||
// check if dark mode or light mode used in OS
|
||||
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
||||
if (
|
||||
window.matchMedia &&
|
||||
window.matchMedia("(prefers-color-scheme: dark)").matches
|
||||
) {
|
||||
// dark mode
|
||||
document.documentElement.setAttribute("data-bs-theme", "dark");
|
||||
} else {
|
||||
|
@ -176,18 +178,16 @@ window.addEventListener("DOMContentLoaded", () => {
|
|||
}
|
||||
|
||||
// also register event listener for automatic change
|
||||
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
|
||||
window
|
||||
.matchMedia("(prefers-color-scheme: dark)")
|
||||
.addEventListener("change", (event) => {
|
||||
let newColorScheme = event.matches ? "dark" : "light";
|
||||
if (newColorScheme == "dark") {
|
||||
document.documentElement.setAttribute("data-bs-theme", "dark");
|
||||
} else {
|
||||
document.documentElement.setAttribute("data-bs-theme", "light");
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
var theme_path = "../node_modules/bootstrap/dist/css/bootstrap.min.css";
|
||||
document.getElementById("bootstrap_theme").href = escape(theme_path);
|
||||
|
|
|
@ -367,7 +367,10 @@ window.addEventListener("DOMContentLoaded", () => {
|
|||
|
||||
// https://stackoverflow.com/a/57795495
|
||||
// check if dark mode or light mode used in OS
|
||||
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
||||
if (
|
||||
window.matchMedia &&
|
||||
window.matchMedia("(prefers-color-scheme: dark)").matches
|
||||
) {
|
||||
// dark mode
|
||||
document.documentElement.setAttribute("data-bs-theme", "dark");
|
||||
} else {
|
||||
|
@ -375,7 +378,9 @@ window.addEventListener("DOMContentLoaded", () => {
|
|||
}
|
||||
|
||||
// also register event listener for automatic change
|
||||
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
|
||||
window
|
||||
.matchMedia("(prefers-color-scheme: dark)")
|
||||
.addEventListener("change", (event) => {
|
||||
let newColorScheme = event.matches ? "dark" : "light";
|
||||
if (newColorScheme == "dark") {
|
||||
document.documentElement.setAttribute("data-bs-theme", "dark");
|
||||
|
@ -383,8 +388,6 @@ window.addEventListener("DOMContentLoaded", () => {
|
|||
document.documentElement.setAttribute("data-bs-theme", "light");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
} else {
|
||||
var theme_path = "../node_modules/bootstrap/dist/css/bootstrap.min.css";
|
||||
document.getElementById("theme_selector").value = "default_light";
|
||||
|
@ -1237,7 +1240,10 @@ window.addEventListener("DOMContentLoaded", () => {
|
|||
var theme_path = "../node_modules/bootstrap/dist/css/bootstrap.min.css";
|
||||
// https://stackoverflow.com/a/57795495
|
||||
// check if dark mode or light mode used in OS
|
||||
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
||||
if (
|
||||
window.matchMedia &&
|
||||
window.matchMedia("(prefers-color-scheme: dark)").matches
|
||||
) {
|
||||
// dark mode
|
||||
document.documentElement.setAttribute("data-bs-theme", "dark");
|
||||
} else {
|
||||
|
@ -1245,7 +1251,9 @@ window.addEventListener("DOMContentLoaded", () => {
|
|||
}
|
||||
|
||||
// also register event listener for automatic change
|
||||
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
|
||||
window
|
||||
.matchMedia("(prefers-color-scheme: dark)")
|
||||
.addEventListener("change", (event) => {
|
||||
let newColorScheme = event.matches ? "dark" : "light";
|
||||
if (newColorScheme == "dark") {
|
||||
document.documentElement.setAttribute("data-bs-theme", "dark");
|
||||
|
@ -1253,9 +1261,6 @@ window.addEventListener("DOMContentLoaded", () => {
|
|||
document.documentElement.setAttribute("data-bs-theme", "light");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
var theme_path = "../node_modules/bootstrap/dist/css/bootstrap.min.css";
|
||||
|
||||
|
|
Loading…
Reference in a new issue