/** * Shows a Bootstrap toast notification. * @param {string} message The message to display. * @param {string} type The type of toast (e.g., 'success', 'danger', 'warning'). */ function showToast(message, type = 'info') { const toastElement = document.getElementById('notificationToast'); if (!toastElement) return; const toastBody = toastElement.querySelector('.toast-body'); const toastHeader = toastElement.querySelector('.toast-header'); toastBody.textContent = message; // Reset classes toastElement.classList.remove('bg-success', 'bg-danger', 'bg-warning', 'bg-info'); // Add new class if (type) { toastElement.classList.add(`bg-${type}`); // Make text readable on dark backgrounds if (type === 'success' || type === 'danger') { toastHeader.classList.add('text-white'); toastBody.classList.add('text-white'); } else { toastHeader.classList.remove('text-white'); toastBody.classList.remove('text-white'); } } const toast = new bootstrap.Toast(toastElement); toast.show(); } // Basic form validation script document.addEventListener('DOMContentLoaded', function () { 'use strict' var forms = document.querySelectorAll('.needs-validation') Array.prototype.slice.call(forms) .forEach(function (form) { form.addEventListener('submit', function (event) { if (!form.checkValidity()) { event.preventDefault() event.stopPropagation() } form.classList.add('was-validated') }, false) }) });