diff --git a/scipaperloader/static/js/common.js b/scipaperloader/static/js/common.js index 9647292..2b9c8af 100644 --- a/scipaperloader/static/js/common.js +++ b/scipaperloader/static/js/common.js @@ -3,36 +3,65 @@ */ /** - * Display a flash message to the user + * Display a flash message to the user as an overlay * @param {string} message - The message to display * @param {string} type - The type of message (success, error, warning, info) + * @param {number} duration - Duration in milliseconds (default: 5000) */ -function showFlashMessage(message, type) { - const flashContainer = document.createElement("div"); - flashContainer.className = `alert alert-${ - type === "error" ? "danger" : type - } alert-dismissible fade show`; - flashContainer.innerHTML = ` - ${message} - - `; +function showFlashMessage(message, type = "success", duration = 5000) { + const flashMsg = document.createElement("div"); + const normalizedType = type === "error" ? "danger" : type; + flashMsg.className = `flash-overlay flash-${normalizedType}`; + + // Get the appropriate icon based on type + const getIcon = (messageType) => { + switch (messageType) { + case "success": + return ''; + case "danger": + return ''; + case "warning": + return ''; + case "info": + return ''; + default: + return ''; + } + }; - // Use the existing client flash container at the top of the page - const clientFlashContainer = document.getElementById("clientFlashContainer"); - if (clientFlashContainer) { - clientFlashContainer.appendChild(flashContainer); - } else { - // Fallback to body if container not found - document.body.appendChild(flashContainer); - } + flashMsg.innerHTML = ` +