|
|
|
|
|
|
|
|
|
|
|
window.MarineAPI = { |
|
|
baseURL: window.location.origin, |
|
|
currentImage: null, |
|
|
isProcessing: false |
|
|
}; |
|
|
|
|
|
|
|
|
const utils = { |
|
|
|
|
|
setLoading: (element, isLoading) => { |
|
|
if (isLoading) { |
|
|
element.disabled = true; |
|
|
element.innerHTML = '<span class="spinner"></span> Processing...'; |
|
|
} else { |
|
|
element.disabled = false; |
|
|
element.innerHTML = element.dataset.originalText || 'Identify Marine Life'; |
|
|
} |
|
|
}, |
|
|
|
|
|
|
|
|
formatFileSize: (bytes) => { |
|
|
if (bytes === 0) return '0 Bytes'; |
|
|
const k = 1024; |
|
|
const sizes = ['Bytes', 'KB', 'MB', 'GB']; |
|
|
const i = Math.floor(Math.log(bytes) / Math.log(k)); |
|
|
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]; |
|
|
}, |
|
|
|
|
|
|
|
|
showNotification: (message, type = 'info') => { |
|
|
|
|
|
const notification = document.createElement('div'); |
|
|
notification.className = `notification notification-${type}`; |
|
|
notification.textContent = message; |
|
|
|
|
|
|
|
|
Object.assign(notification.style, { |
|
|
position: 'fixed', |
|
|
top: '20px', |
|
|
right: '20px', |
|
|
padding: '12px 20px', |
|
|
borderRadius: '8px', |
|
|
color: 'white', |
|
|
fontWeight: '500', |
|
|
zIndex: '1000', |
|
|
transform: 'translateX(100%)', |
|
|
transition: 'transform 0.3s ease' |
|
|
}); |
|
|
|
|
|
|
|
|
const colors = { |
|
|
success: '#059669', |
|
|
error: '#dc2626', |
|
|
warning: '#d97706', |
|
|
info: '#2563eb' |
|
|
}; |
|
|
notification.style.backgroundColor = colors[type] || colors.info; |
|
|
|
|
|
document.body.appendChild(notification); |
|
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
notification.style.transform = 'translateX(0)'; |
|
|
}, 100); |
|
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
notification.style.transform = 'translateX(100%)'; |
|
|
setTimeout(() => { |
|
|
document.body.removeChild(notification); |
|
|
}, 300); |
|
|
}, 5000); |
|
|
} |
|
|
}; |
|
|
|
|
|
|
|
|
document.addEventListener('DOMContentLoaded', () => { |
|
|
console.log('Seamo Species API Dashboard Loaded'); |
|
|
|
|
|
|
|
|
document.querySelectorAll('.btn').forEach(btn => { |
|
|
btn.dataset.originalText = btn.textContent; |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
window.MarineAPI.utils = utils; |
|
|
|