PantunGen / static /js /main.js
Mascode01's picture
Upload 21 files
28b723d verified
Raw
History Blame Contribute Delete
1.29 kB
/**
* Main application scripts
*/
document.addEventListener('DOMContentLoaded', () => {
// Other initializations can go here if needed in the future
});
/**
* Show a toast notification
* @param {string} message - The message to display
* @param {string} type - 'success', 'error', 'info'
*/
window.showToast = function(message, type = 'error') {
const container = document.getElementById('toast-container');
if (!container) return;
const toast = document.createElement('div');
toast.className = 'toast';
// Set color based on type
if (type === 'success') {
toast.style.backgroundColor = 'var(--color-success)';
} else if (type === 'info') {
toast.style.backgroundColor = 'var(--color-primary)';
}
// Set icon based on type
let iconClass = 'fa-circle-exclamation';
if (type === 'success') iconClass = 'fa-circle-check';
else if (type === 'info') iconClass = 'fa-circle-info';
toast.innerHTML = `
<i class="fa-solid ${iconClass}"></i>
<span>${message}</span>
`;
container.appendChild(toast);
// Remove after 3 seconds
setTimeout(() => {
toast.style.animation = 'fadeIn 0.3s ease-in reverse forwards';
setTimeout(() => toast.remove(), 300);
}, 3000);
};