47 lines
1.7 KiB
JavaScript
47 lines
1.7 KiB
JavaScript
// Bootstrap form validation
|
|
(() => {
|
|
'use strict'
|
|
|
|
const forms = document.querySelectorAll('.needs-validation')
|
|
|
|
Array.from(forms).forEach(form => {
|
|
form.addEventListener('submit', event => {
|
|
if (!form.checkValidity()) {
|
|
event.preventDefault()
|
|
event.stopPropagation()
|
|
}
|
|
|
|
form.classList.add('was-validated')
|
|
}, false)
|
|
})
|
|
})();
|
|
|
|
// Show toast notification for form submission status
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
const urlParams = new URLSearchParams(window.location.search);
|
|
const status = urlParams.get('status');
|
|
const message = urlParams.get('message');
|
|
|
|
if (status) {
|
|
const toastContainer = document.getElementById('toast-container');
|
|
const toastHTML = `
|
|
<div class="toast align-items-center text-white ${status === 'success' ? 'bg-success' : 'bg-danger'} border-0" role="alert" aria-live="assertive" aria-atomic="true">
|
|
<div class="d-flex">
|
|
<div class="toast-body">
|
|
${message || (status === 'success' ? 'Your message has been sent successfully!' : 'An error occurred. Please try again.')}
|
|
</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 toastEl = toastContainer.querySelector('.toast');
|
|
const toast = new bootstrap.Toast(toastEl, { delay: 5000 });
|
|
toast.show();
|
|
}
|
|
});
|
|
|
|
// Initialize Particles.js
|
|
particlesJS.load('particles-js', 'assets/particles.json', function() {
|
|
console.log('particles.js config loaded');
|
|
}); |