45 lines
1.3 KiB
JavaScript
45 lines
1.3 KiB
JavaScript
$("#themeToggle").on("click", function() {
|
|
const currentTheme = $("body").attr("data-bs-theme");
|
|
const newTheme = currentTheme === "light" ? "dark" : "light";
|
|
updateTheme(newTheme);
|
|
});
|
|
|
|
function updateTheme(theme) {
|
|
$("body").attr("data-bs-theme", theme);
|
|
localStorage.setItem("theme", theme);
|
|
}
|
|
|
|
function getCurrentDateTime() {
|
|
var now = new Date();
|
|
var year = now.getFullYear();
|
|
var month = String(now.getMonth() + 1).padStart(2, '0');
|
|
var day = String(now.getDate()).padStart(2, '0');
|
|
var hours = String(now.getHours()).padStart(2, '0');
|
|
var minutes = String(now.getMinutes()).padStart(2, '0');
|
|
return `${year}-${month}-${day}T${hours}:${minutes}`;
|
|
}
|
|
|
|
$(document).ready(function() {
|
|
// Activate all tooltips
|
|
$('[data-bs-toggle="tooltip"]').tooltip();
|
|
|
|
// Activate select2s
|
|
$(".select-2").each(function() {
|
|
var dropdownParent = $(this).attr("data-dropdownparent");
|
|
$(this).select2({
|
|
theme: "bootstrap",
|
|
minimumResultsForSearch: 10,
|
|
dropdownParent: dropdownParent
|
|
});
|
|
});
|
|
|
|
// Activate datepickers
|
|
// $(".input-group.date").datepicker({format: "yyyy-mm-dd"});
|
|
|
|
// Load theme
|
|
var theme = localStorage.getItem("theme");
|
|
if (theme === null)
|
|
theme = "light";
|
|
|
|
updateTheme(theme);
|
|
}); |