34788-vm/assets/js/main.js
2025-10-08 11:45:34 +00:00

39 lines
1.5 KiB
JavaScript

document.addEventListener('DOMContentLoaded', function () {
const urlParams = new URLSearchParams(window.location.search);
const status = urlParams.get('status');
if (status) {
let message = '';
let type = 'success';
if (status === 'success') {
message = 'Thank you for your message! We will get back to you shortly.';
} else if (status === 'error') {
message = 'Something went wrong. Please try again.';
type = 'danger';
}
if (message) {
const toastContainer = document.getElementById('toast-container');
const toastHTML = `
<div class="toast align-items-center text-white bg-${type} border-0 show" role="alert" aria-live="assertive" aria-atomic="true">
<div class="d-flex">
<div class="toast-body">
${message}
</div>
<button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
</div>
`;
toastContainer.innerHTML = toastHTML;
const toastElement = toastContainer.querySelector('.toast');
const toast = new bootstrap.Toast(toastElement, { delay: 5000 });
toast.show();
}
// Clean the URL
window.history.replaceState({}, document.title, window.location.pathname);
}
});