MeshCentral/public/scripts/themes/theme-switcher.js
si458 def62075c7 fix theme switch to default bug and include google fonts in csp #6665
Signed-off-by: si458 <simonsmith5521@gmail.com>
2025-01-06 16:02:10 +00:00

22 lines
766 B
JavaScript

document.addEventListener("DOMContentLoaded", function () {
const themeStylesheet = document.getElementById("theme-stylesheet");
// Load saved theme from local storage
const savedTheme = localStorage.getItem("theme");
if (savedTheme) {
const safeTheme = ((savedTheme != 'default') ? encodeURIComponent(savedTheme) : encodeURIComponent('..'));
themeStylesheet.href = `styles/themes/${safeTheme}/bootstrap-min.css`;
}
// Initialize Select2 on all select elements with the 'select2' class
$(".select2").select2({
theme: "bootstrap-5",
width: $(this).data("width")
? $(this).data("width")
: $(this).hasClass("w-100")
? "100%"
: "style",
placeholder: $(this).data("placeholder"),
});
});