document.addEventListener('DOMContentLoaded', function () { const urlParams = new URLSearchParams(window.location.search); const status = urlParams.get('status'); if (status) { let message = ''; let type = 'success'; let title = 'Success!'; if (status === 'success') { message = 'Your message has been sent successfully. We will get back to you shortly.'; } else if (status === 'error') { message = 'There was an error sending your message. Please try again.'; type = 'danger'; title = 'Error!'; } else if (status === 'validation_error') { message = 'Please fill out all fields correctly.'; type = 'warning'; title = 'Validation Error'; } if (message) { showToast(title, message, type); // Clean the URL window.history.replaceState({}, document.title, window.location.pathname); } } }); function showToast(title, message, type = 'success') { const toastContainer = document.getElementById('toast-container'); if (!toastContainer) return; const toastId = 'toast-' + Date.now(); const toastHTML = ` `; toastContainer.insertAdjacentHTML('beforeend', toastHTML); const toastElement = document.getElementById(toastId); const toast = new bootstrap.Toast(toastElement, { delay: 5000 }); toast.show(); toastElement.addEventListener('hidden.bs.toast', () => { toastElement.remove(); }); }