-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.js
More file actions
42 lines (35 loc) · 1.27 KB
/
utils.js
File metadata and controls
42 lines (35 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Utility functions
// Format time as MM:SS
function formatTime(sec) {
var m = Math.floor(sec / 60);
var s = sec % 60;
return (m < 10 ? '0' + m : m) + ':' + (s < 10 ? '0' + s : s);
}
// Get color for avatar based on name
function getColor(name) {
var colors = ['#00e0ff', '#24c7d9', '#ffc107', '#ff6b9d', '#9c27b0', '#4caf50', '#ff9800', '#2196f3'];
var num = 0;
for (var i = 0; i < name.length; i++) {
num += name.charCodeAt(i);
}
return colors[num % colors.length];
}
// Show toast notification
function showNotification(message, type = 'success') {
const container = document.getElementById('notification-container');
const notification = document.createElement('div');
notification.className = `notification ${type}`;
const icon = type === 'success' ? '✓' : '✕';
notification.innerHTML = `
<span class="notification-icon">${icon}</span>
<span class="notification-message">${message}</span>
`;
container.appendChild(notification);
// Remove after 3 seconds
setTimeout(() => {
notification.classList.add('fade-out');
notification.addEventListener('animationend', () => {
notification.remove();
});
}, 3000);
}