Corban-Lee Jones 1d5117614e
All checks were successful
Build and Push Docker Image / build (push) Successful in 16s
notifications test using notifyjs
2024-09-13 15:09:57 +01:00

78 lines
2.1 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}`;
}
// Sanitise a given string to remove HTML, making it DOM safe.
function sanitise(string) {
if (typeof string !== "string") {
return string;
}
const map = {
'&': '&',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#x27;',
"/": '&#x2F;',
};
const reg = /[&<>"'/]/ig;
return string.replace(reg, (match) => map[match]);
}
$(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
});
});
$.notify.addStyle("bootstrap", {
html:
'<div class="toast mt-3 overflow-hidden" role="alert">' +
'<div class="toast-body">' +
'<span data-notify-text></span>' +
'</div>' +
"</div>"
});
$.notify.defaults({
globalPosition: "bottom right",
animationType: "fade",
className: "success"
});
// Activate datepickers
// $(".input-group.date").datepicker({format: "yyyy-mm-dd"});
// Load theme
var theme = localStorage.getItem("theme");
if (theme === null)
theme = "light";
updateTheme(theme);
});