webinterface/client/js/shared_functions.js

19 lines
816 B
JavaScript
Raw Normal View History

2024-11-14 17:43:37 +01:00
// Alert Box
// Function to show the custom alert with a message and type
export function showAlert(message, type = 'error') {
const alertBox = document.getElementById('custom-alert');
const alertMessage = document.getElementById('alert-message');
const closeButton = document.getElementById('close-alert');
alertMessage.textContent = message; // Set the message to display
alertBox.style.display = 'block'; // Show the alert box
// Reset previous styles
alertBox.classList.remove('success', 'error');
alertBox.classList.add(type); // Add the appropriate class (success/error)
// Add event listener to close the alert box
closeButton.addEventListener('click', () => {
alertBox.style.display = 'none'; // Hide the alert box when the button is clicked
});
}