function sendToast(type, title, message, persistent, important) { var toastId = 'toast-' + new Date().getTime(); var toastTitle = title ? title : capitalizeFirstLetter(type); var toastIcons = { success: 'fa-check-circle', error: 'fa-times-circle', warning: 'fa-exclamation-triangle', info: 'fa-info-circle', default: 'fa-bell' }; var iconClass = toastIcons[type] || toastIcons['default']; // Get the icon class based on the toast type, fallback to 'default' if type doesn't exist var $toast = $(`
${toastTitle}
${message}
`); $('#toast-container').append($toast); setTimeout(function () { $toast.addClass('show'); }, 10); $toast.find('.close-btn').click(function () { closeToast($toast); }); if (!persistent) { setTimeout(function () { closeToast($toast); }, 5000); } } function closeToast($toast) { $toast.removeClass('show'); setTimeout(function () { $toast.remove(); }, 300); } function capitalizeFirstLetter(string) { return string.charAt(0).toUpperCase() + string.slice(1); }