-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
65 lines (54 loc) · 2.2 KB
/
Copy pathscript.js
File metadata and controls
65 lines (54 loc) · 2.2 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Initialize Lucide icons
lucide.createIcons();
const playlistForm = document.getElementById('playlist-form');
const container = document.querySelector('.container');
const loadingOverlay = document.querySelector('.loading-overlay');
const successMessage = document.getElementById('success-message');
playlistForm.addEventListener('submit', async (e) => {
e.preventDefault();
const playlistUrl = document.getElementById('playlist-url').value;
if (!playlistUrl.includes('spotify.com/playlist/')) {
alert('Please enter a valid Spotify playlist URL');
return;
}
// Add submitting class to container for color wave effect
container.classList.add('submitting');
// Show loading overlay with animations
loadingOverlay.classList.add('active');
try {
// Simulate processing time (replace with actual API call)
await new Promise(resolve => setTimeout(resolve, 5000));
// Show success message
successMessage.classList.remove('hidden');
playlistForm.classList.add('hidden');
// Optional: Add confetti effect on success
createConfetti();
} catch (error) {
console.error('Error:', error);
} finally {
loadingOverlay.classList.remove('active');
// Remove color wave effect after delay
setTimeout(() => {
container.classList.remove('submitting');
}, 2000);
}
});
// Optional: Add confetti effect
function createConfetti() {
for (let i = 0; i < 100; i++) {
const confetti = document.createElement('div');
confetti.className = 'confetti';
confetti.style.left = Math.random() * 100 + 'vw';
confetti.style.animationDelay = Math.random() * 3 + 's';
confetti.style.backgroundColor = `hsl(${Math.random() * 360}, 100%, 50%)`;
document.body.appendChild(confetti);
// Remove confetti after animation
setTimeout(() => confetti.remove(), 3000);
}
}
// Reset form
document.getElementById('add-another').addEventListener('click', () => {
successMessage.classList.add('hidden');
playlistForm.classList.remove('hidden');
document.getElementById('playlist-url').value = '';
});