-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
758 lines (654 loc) · 34.2 KB
/
index.html
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Primary Meta Tags -->
<meta name="description" content="Stream diverse music genres, curated playlists, and explore lyrics. Save and like songs with personalized analytics to enhance your listening experience.">
<meta name="keywords" content="music streaming, playlists, song lyrics, music player, song analytics, Spotify API, save songs, liked songs, artist stats">
<meta name="author" content="SM.studio">
<!-- Open Graph for Social Media Sharing -->
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://medelbou3.github.io/SM4song/">
<meta property="og:title" content="SM4music - Advanced Music Streaming WebApp">
<meta property="og:description" content="Explore and stream music across genres, create playlists, view lyrics, and enjoy advanced analytics for personalized music experience.">
<meta property="og:site_name" content="SM4music">
<meta property="og:title" content="SM4music Advanced Music Streaming WebApp">
<meta property="og:description" content="Explore and stream music across genres, create playlists, view lyrics, and enjoy advanced analytics for personalized music experience.">
<meta property="og:type" content="website">
<meta property="og:url" content="https://github.com/MEDELBOU3/SM4song/">
<meta property="og:image" content="https://github.com/MEDELBOU3/SM4song/blob/main/brandmark.png?raw=true">
<!-- Twitter Card for Twitter Sharing -->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="Advanced Music Streaming App">
<meta name="twitter:description" content="Stream and organize your favorite music with advanced analytics and lyrics.">
<meta name="twitter:image" content="https://raw.githubusercontent.com/MEDELBOU3/SM4song/brandmark.png">
<meta name="twitter:site" content="@Simo_Elbou3"> <!-- Replace with your Twitter handle -->
<!-- Favicon -->
<link rel="icon" href="https://raw.githubusercontent.com/MEDELBOU3/SM4song/main/brandmark.png" type="image/png">
<link rel="icon" type="image/png" sizes="32x32" href="https://raw.githubusercontent.com/MEDELBOU3/SM4song/main/brandmark.png">
<link rel="icon" type="image/png" sizes="16x16" href="https://raw.githubusercontent.com/MEDELBOU3/SM4song/main/brandmark.png">
<link rel="apple-touch-icon" sizes="180x180" href="https://raw.githubusercontent.com/MEDELBOU3/SM4song/main/brandmark.png">
<!-- Theme Color for Mobile Browsers -->
<meta name="theme-color" content="#1DB954">
<!-- Canonical Link -->
<link rel="canonical" href="https://github.com/MEDELBOU3/SM4song/">
<!-- Additional Meta Tags for Enhancing SEO -->
<meta name="language" content="en">
<meta name="revisit-after" content="7 days">
<meta name="robots" content="index, follow">
<meta name="distribution" content="global">
<title>Enhanced Spotify-like Music App</title>
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<link href='https://unpkg.com/boxicons@2.1.4/css/boxicons.min.css' rel='stylesheet'>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script src="https://kit.fontawesome.com/a076d05399.js" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="playlist.css">
<link rel="stylesheet" href="movies.css">
<link rel="stylesheet" href="Clr-Extraction & Call Page/theme&layout.css">
<link rel="stylesheet" href="conditions/conditions.css">
<link rel="stylesheet" href="speed-test/net-meter.css">
<link rel="stylesheet" href="user/login.css">
<link rel="stylesheet" href="user/data.css">
</head>
<body>
<div id="promo-modal" class="promo-overlay">
<div class="promo-content">
<img src="brandmark.png" alt="Brandmark" class="promo-logo">
<h1>Welcome to SM4music</h1>
<p>Enjoy an unparalleled music experience, wherever you are</p>
<button id="close-window">Get Started</button>
</div>
<div class="image-cont">
<img src="https://cdn.pixabay.com/photo/2024/05/30/19/37/girl-8799169_1280.jpg" >
<img src="https://media.istockphoto.com/id/1827161388/vector/girl-listens-to-music-with-headphones-concept-of-audio-listening-musical-entertainment.jpg?s=612x612&w=0&k=20&c=oEPTN4TLr5SHCgiYqseQ-jCO1sq5mEex3F-Qk1mmMfE=">
<img src="https://media.istockphoto.com/id/1340206832/vector/modern-dj-playing-music-records-with-electronic-audio-controller-happy-man-in-headphones-at.jpg?s=612x612&w=0&k=20&c=gv43-_L2uJnUnVRn4QQrCShWC5BGziqtY02a3Ks3IXQ=">
<img src="https://media.istockphoto.com/id/2149497634/vector/flat-vector-illustration-of-business-people-operating-work-scene.jpg?s=612x612&w=0&k=20&c=zS4QL6SAL5CeD4kHgLbK-o09oDvcDuFT47FeIb62YBI=">
<img src="https://media.istockphoto.com/id/475672182/vector/skate-scenes-with-riders-and-grunge-backgrounds.jpg?s=612x612&w=0&k=20&c=vXB9q9DZ9DKpOWhZNV56ocRuLlSJCSItDfFh07FZUcY=">
<img src="https://media.istockphoto.com/id/1384181816/vector/a-young-man-stands-leaning-on-a-tape-recorder.jpg?s=612x612&w=0&k=20&c=Mi9qafpkemWL3SMpfiy533ksgw63WgqlAxQGqSPVq1I=">
<img src="https://media.istockphoto.com/id/1125682367/vector/modern-abstract-art-geometric-background-with-flat-minimalistic-style-vector-poster.jpg?s=612x612&w=0&k=20&c=L0KM46dhBe31LdzgOCx18ooR1LNE8G64pnA0BRhXcu0=">
</div>
</div>
<div class="modal fade" id="rulingModal" tabindex="-1" aria-labelledby="rulingModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-lg">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="rulingModalLabel">
<i class="fas fa-music me-2"></i>
<span class="title-text">Music in Islam</span>
</h5>
<button type="button" class="close-btn" data-bs-dismiss="modal" aria-label="Close">
<i class="fas fa-times"></i>
</button>
</div>
<div class="modal-body">
<div class="language-buttons text-center mb-4">
<button class="btn language-btn" onclick="changeLanguage('ar')">
<i class="fas fa-globe-asia me-1"></i> العربية
</button>
<button class="btn language-btn active" onclick="changeLanguage('en')">
<i class="fas fa-globe-americas me-1"></i> English
</button>
<button class="btn language-btn" onclick="changeLanguage('fr')">
<i class="fas fa-globe-europe me-1"></i> Français
</button>
<button class="btn language-btn" onclick="changeLanguage('ja')">
<i class="fas fa-globe-asia me-1"></i> 日本語
</button>
</div>
<a class="attention">
<i class="fas fa-triangle-exclamation"></i>
</a>
<div id="modalText" class="modal-text"></div>
</div>
</div>
</div>
</div>
<div class="container">
<div class="sidebar">
<div class="logo">
<img src="brandmark.png" class="brandmark">
</div>
<div class="account-btn" onclick="handleAccountClick()">
<i class="fas fa-user"></i>
<span>Account</span>
</div>
<div class="menu-item" data-page="home">
<i class="fas fa-home"></i>
Home
</div>
<div class="menu-item" data-page="search">
<i class="fas fa-search"></i>
Search
</div>
<div class="menu-item" data-page="featured-playlists">
<i class="fas fa-list"></i>
Featured Playlists
</div>
<div class="menu-item" data-page="various-music">
<i class="bx bx-speaker"></i>
Various Music
</div>
<div class="menu-item" data-page="new-releases">
<i class="fas fa-compact-disc"></i>
New Releases
</div>
<div class="menu-item" data-page="categories">
<i class="fas fa-th-large"></i>
Categories
</div>
<div class="menu-item" data-page="recommended">
<i class="fas fa-headphones"></i>
Recommended
</div>
<div class="menu-item" data-page="News">
<a href="src/news.html" style="text-decoration: none; color: var(--text-color);">
<i class="fas fa-newspaper" style="color: var(--text-color);"></i>News
</a>
</div>
<div class="menu-item" data-page="settings">
<i class="fas fa-cog"></i>
Settings
</div>
<div class="menu-item" data-page="playlist" onclick="openPlaylistModal()">
<i class='bx bxs-playlist'></i>
My list
</div>
<!-- Discover menu item -->
<div class="menu-item" data-page="discover" onclick="toggleDiscoverButtons()">
<i class="fas fa-compass"></i>
Discover
</div>
<!-- Container for buttons -->
<div id="discover-buttons" style="display: none; padding-left: 20px;">
<!-- Buttons will be added here dynamically -->
</div>
</div>
<div class="main-content">
<button class="mode-toggle" id="mode-toggle" >
<i class="fas fa-moon"></i>
</button>
<div class="search-container">
<input type="text" id="searchInput" placeholder="Search for tracks...">
<button id="searchButton"><i class="fas fa-search"></i></button>
</div>
<div id="content"></div>
</div>
</div>
<div class="player-controls">
<div class="now-playing">
<div class="playing-msc">
<img id="nowPlayingImg" src="https://via.placeholder.com/56" alt="Now Playing">
<div class="now-playing-info">
<h3 id="nowPlayingTitle">Track Title</h3>
<p id="nowPlayingArtist">Artist Name</p>
</div>
</div>
<div class="equalizer">
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
</div>
</div>
<div class="player-center">
<div class="player-buttons">
<button id="shuffleBtn"><i class="fas fa-random"></i></button>
<button id="prevBtn"><i class="fas fa-step-backward"></i></button>
<button id="playPauseBtn"><i class="fas fa-play-circle"></i></button>
<button id="nextBtn"><i class="fas fa-step-forward"></i></button>
<button id="repeatBtn"><i class="fas fa-redo"></i></button>
</div>
<div class="progress-container">
<span id="currentTime">0:00</span>
<div id="progressBar"><div id="progress"></div></div>
<span id="totalTime">0:30</span>
</div>
</div>
<div class="player-right">
<button id="toggleLyrics">Lyrics</button>
<button id="colorToggle" class="toggle-button"><i class="fa fa-palette" style="font-size: 24px;"></i><span id="toggleText">On</span></button>
<i id="volumeIcon" class="fas fa-volume-up"></i>
<input type="range" id="volumeControl" min="0" max="100" value="100">
</div>
</div>
<div id="lyricsContainer" class="lyrics-container">
<h2>Lyrics</h2>
<div id="lyricsContent">
</div>
</div>
<div id="playlistModal" class="modal">
<div class="modal-content">
<div class="modal-content-inner">
<header class="header">
<span class="close" onclick="closePlaylistModal()">×</span>
<button id="expandBtn"><i class="fa-solid fa-expand"></i></button>
<button id="maximizeBtn"><i class="fa-solid fa-window-maximize"></i></button>
<button id="minimizeBtn"><i class="fa-solid fa-window-minimize"></i></button>
</header>
<h2>My Playlist</h2>
<!-- Tab buttons -->
<div class="tab-buttons">
<button class="tab-button active" data-tab="playlistItems">Playlist Items</button>
<button class="tab-button" data-tab="playlistStats">Statistics</button>
<button class="tab-button" data-tab="recentAdditions">Recent Additions</button>
</div>
<div class="tab-content">
<div id="playlistItems" class="tab-pane active">
<!-- Content for Playlist Items -->
<h3>Playlist Items</h3>
<!-- Add your playlist items content here -->
</div>
<div id="playlistStats" class="tab-pane">
<h3>Statistics of my Playlist</h3>
<div class="charts-container">
<div class="chart-wrapper">
<h4>Distribution of musical genres</h4>
<div class="chart-container">
<canvas id="genreChart"></canvas>
</div>
</div>
<div class="chart-wrapper">
<h4>Favorite songs vs not Favorite</h4>
<div class="chart-container">
<canvas id="likedChart"></canvas>
</div>
</div>
</div>
<div class="stats-container">
<div class="stat-section" id="topArtists">
<h4>The Most 8 Repeated Artists</h4>
<ul class="stat-list" id="topArtistsList"></ul>
</div>
<div class="stat-section" id="playlistDuration">
<h4>Duration Information</h4>
<div class="duration-info"></div>
</div>
</div>
</div>
<div id="recentAdditions" class="tab-pane">
<h3>Latest Additions</h3>
<!-- Content for Recent Additions -->
</div>
</div>
</div>
<div class="resize-handle top-left"></div>
<div class="resize-handle top-right"></div>
<div class="resize-handle bottom-left"></div>
<div class="resize-handle bottom-right"></div>
</div>
</div>
<div class="speed-test-modal">
<div class="speed-test-content">
<div class="speed-test-header">
<h2>Internet Speed Test</h2>
<button class="close-speed-test">×</button>
</div>
<div class="speed-gauges">
<div class="speed-gauge download">
<div class="speed-value">0.00</div>
<span class="speed-unit">Mbps</span>
<div class="speed-label">Download</div>
</div>
<div class="speed-gauge upload">
<div class="speed-value">0.00</div>
<span class="speed-unit">Mbps</span>
<div class="speed-label">Upload</div>
</div>
</div>
<div class="progress-bar">
<div class="progress-bar-fill"></div>
</div>
<div class="test-status">Ready to test</div>
<button class="test-button">Start Speed Test</button>
<div class="charts-container">
<div class="chart-wrapper">
<canvas id="speedHistoryChart"></canvas>
</div>
<div class="chart-wrapper">
<canvas id="dailyAverageChart"></canvas>
</div>
</div>
</div>
</div>
<!--Creat Account Modal-->
<div class="modl" id="createAccountModal">
<div class="modal-cnt">
<h2>Create Account</h2>
<form id="createAccountForm">
<div class="form-group">
<input class="account-input" type="text" id="name" placeholder="Name" required>
</div>
<div class="form-group">
<input class="account-input" type="text" id="surname" placeholder="Surname" required>
</div>
<div class="form-group">
<input type="number" class="account-input" id="age" placeholder="Age" required min="13">
</div>
<div class="form-group">
<input type="email" class="account-input" id="email" placeholder="E-mail" required>
</div>
<div class="form-group password-toggle">
<input type="password" class="account-input" id="password" placeholder="Password" required onkeyup="checkPasswordStrength(this.value)">
<i class="far fa-eye" onclick="togglePasswordVisibility('password')"></i>
<div class="strength-meter">
<div id="strength-bar"></div>
</div>
</div>
<div class="form-group">
<input type="file" class="account-input" id="image" placeholder="Profile Picture" accept="image/*">
</div>
<button type="button" class="butn" onclick="createAccount()">Create Account</button>
<div class="hove-an-account">
I am already registered
<a href="#loginModal">Login</a>
</div>
</form>
</div>
</div>
<!-- Login Modal -->
<div class="modl" id="loginModal">
<div class="modal-cnt">
<h2>Login</h2>
<form id="loginForm">
<div class="form-group">
<input type="email" class="account-input" id="loginEmail" placeholder="E-mail" required>
</div>
<div class="form-group password-toggle">
<input type="password" class="account-input" id="loginPassword" placeholder="Password" required>
<i class="far fa-eye" onclick="togglePasswordVisibility('loginPassword')"></i>
</div>
<button type="button" class="butn" onclick="login()">Login</button>
<div class="havent-account">
I dont have an account
<a href="#createAccountModal">create Account</a>
</div>
</form>
</div>
</div>
<!-- User Panel -->
<div class="user-panel" id="userPanel">
<div class="resizer" id="resizer"></div>
<button class="close-panel" onclick="closeUserPanel()">
<i class="fas fa-times"></i>
</button>
<div class="user-info">
<img id="userImage" alt="Profile Picture">
<h3 id="userName"></h3>
<p id="userEmail"></p>
<p id="userAge"></p>
<button class="butn" onclick="logout()">Logout</button>
</div>
<div class="playlist-creation">
<h3>Create a Playlist</h3>
<input class="account-input" type="text" id="playlistName" placeholder="Enter Playlist Name">
<input class="account-input" type="text" id="playlistGenre" placeholder="Enter Playlist Genre">
<input class="account-input" type="file" id="playlistImage" accept="image/*">
<button class="creat-butn" onclick="createPlaylist()">Create</button>
</div>
<div class="playlists-section">
<h3>Your Playlists</h3>
<div id="playUrList"></div>
</div>
</div>
<div id="modl" class="modl">
<div class="modal-cnt">
<span class="close-modal" onclick="closeModal()">×</span>
<h3 id="modalPlaylistName"></h3>
<input class="account-input" type="file" id="songFile" accept="audio/*">
<input class="account-input" type="text" id="songName" placeholder="Song Name">
<input type="file" id="songImage" accept="image/*">
<button class="butn" onclick="addSong()">Add Song</button>
<div class="songs-list" id="songsList"></div>
</div>
</div>
<div class="notifications" id="notifications">
<i class="fas fa-check-circle"></i>
<span id="notification-message"></span>
</div>
<script>
function toggleDiscoverButtons() {
const buttonsContainer = document.getElementById('discover-buttons');
if (buttonsContainer.style.display === 'none') {
// Show buttons container
buttonsContainer.style.display = 'block';
// Clear existing buttons
buttonsContainer.innerHTML = '';
// Movies button
const moviesBtn = document.createElement('div');
moviesBtn.className = 'submenu-item';
moviesBtn.innerHTML = '<i class="fas fa-film"></i> Movies';
moviesBtn.onclick = () => {
const existingBtn = document.getElementById('movies-btn');
if (!existingBtn) {
addMoviesButton();
}
toggleMoviesModal();
};
buttonsContainer.appendChild(moviesBtn);
// Stats button
const statsBtn = document.createElement('div');
statsBtn.className = 'submenu-item';
statsBtn.innerHTML = '<i class="fas fa-chart-bar"></i> Usage Statistics';
statsBtn.onclick = () => {
const existingBtn = document.getElementById('statsButton');
if (!existingBtn) {
createStatsButton();
}
// Trigger click on the actual stats button
document.getElementById('statsButton').click();
};
buttonsContainer.appendChild(statsBtn);
//test Speed Button
const testSpeedBtn = document.createElement('div');
testSpeedBtn.className = 'submenu-item';
testSpeedBtn.innerHTML = '<i class="fas fa-tachometer-alt"></i> Speed Test';
testSpeedBtn.onclick = () => {
const existingBtn = document.getElementById('speedTestButton');
if (!existingBtn) {
createSpeedTestButton();
}
// Trigger click on the actual stats button
document.getElementById('speedTestButton').click();
};
buttonsContainer.appendChild(testSpeedBtn);
} else {
// Hide buttons container
buttonsContainer.style.display = 'none';
}
}
//this functio to add sidebar Toggel
function setupSidebarToggle() {
const toggleBtn = document.createElement('button');
toggleBtn.id = 'sidebarToggle';
toggleBtn.innerHTML = '<i class="fas fa-bars"></i>';
toggleBtn.className = 'sidebar-toggle';
// Insert the button at the start of main-content
const mainContent = document.querySelector('.main-content');
mainContent.insertBefore(toggleBtn, mainContent.firstChild);
toggleBtn.addEventListener('click', () => {
document.querySelector('.container').classList.toggle('sidebar-collapsed');
});
}
// Call this function when the page loads
document.addEventListener('DOMContentLoaded', setupSidebarToggle);
//BRAND SCREEN
// Confetti effect
function createConfetti() {
const colors = ['#7C3AED', '#EC4899', '#3B82F6', '#10B981'];
for (let i = 0; i < 50; i++) {
const confetti = document.createElement('div');
confetti.className = 'confetti';
confetti.style.left = Math.random() * 100 + 'vw';
confetti.style.animationDuration = (Math.random() * 3 + 2) + 's';
confetti.style.opacity = Math.random();
confetti.style.background = colors[Math.floor(Math.random() * colors.length)];
document.body.appendChild(confetti);
setTimeout(() => confetti.remove(), 5000);
}
}
// Close modal
document.getElementById('close-window').addEventListener('click', function() {
document.getElementById('promo-modal').style.display = 'none';
});
// Show modal if not seen before
if (!localStorage.getItem('promoSeen')) {
document.getElementById('promo-modal').style.display = 'flex';
localStorage.setItem('promoSeen', 'true');
createConfetti();
}
let isDynamicColorEnabled = true;
function getDominantColor(imgEl) {
return new Promise((resolve) => {
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
canvas.width = 50;
canvas.height = 50;
ctx.drawImage(imgEl, 0, 0, canvas.width, canvas.height);
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height).data;
const colorMap = {};
for (let i = 0; i < imageData.length; i += 4) {
const r = imageData[i];
const g = imageData[i + 1];
const b = imageData[i + 2];
if (imageData[i + 3] === 0) continue;
const rgb = `${r},${g},${b}`;
colorMap[rgb] = (colorMap[rgb] || 0) + 1;
}
let dominantColor = null;
let maxFrequency = 0;
for (const [color, frequency] of Object.entries(colorMap)) {
if (frequency > maxFrequency) {
maxFrequency = frequency;
dominantColor = color;
}
}
const [r, g, b] = dominantColor.split(',').map(Number);
resolve({ r, g, b });
});
}
function resetColors() {
const playerControls = document.querySelector('.player-controls');
const playerCenter = document.querySelector('.player-center');
const lyricsContainer = document.querySelector('.lyrics-container');
const sidebar = document.querySelector('.sidebar');
const mainContainer = document.querySelector('.main-content');
// Reset to default colors
playerControls.style.backgroundColor = '';
playerCenter.style.backgroundColor = '';
lyricsContainer.style.backgroundColor = '';
sidebar.style.backgroundColor = '';
mainContainer.style.backgroundColor = '';
playerControls.style.backgroundImage = '';
playerCenter.style.backgroundImage = '';
lyricsContainer.style.backgroundImage = '';
sidebar.style.backgroundImage = '';
mainContainer.style.backgroundImage = '';
}
function updatePlayerControlsBackground(imageUrl) {
if (!isDynamicColorEnabled) {
resetColors();
return;
}
const img = new Image();
img.crossOrigin = "Anonymous";
img.onload = async () => {
try {
const color = await getDominantColor(img);
const playerControls = document.querySelector('.player-controls');
const playerCenter = document.querySelector('.player-center');
const lyricsContainer = document.querySelector('.lyrics-container');
const sidebar = document.querySelector('.sidebar');
const mainContainer = document.querySelector('.main-content');
playerControls.style.backgroundColor = `rgba(${color.r}, ${color.g}, ${color.b}, 0.3)`;
playerCenter.style.backgroundColor = `rgba(${color.r}, ${color.g}, ${color.b}, 0.6)`;
lyricsContainer.style.backgroundColor = `rgba(${color.r}, ${color.g}, ${color.b}, 0.98)`;
sidebar.style.backgroundColor = `rgba(${color.r}, ${color.g}, ${color.b}, 0.98)`;
mainContainer.style.backgroundColor = `rgba(${color.r}, ${color.g}, ${color.b}, 0.98)`;
lyricsContainer.style.backgroundImage =
sidebar.style.backgroundImage =
mainContainer.style.backgroundImage = `
linear-gradient(
rgba(0, 0, 0, 0.8),
rgba(${color.r}, ${color.g}, ${color.b}, 0.98)
)
`;
playerCenter.style.backgroundImage = `
linear-gradient(
rgba(${color.r}, ${color.g}, ${color.b}, 0.98),
rgba(0, 0, 0, 0.8)
)
`;
playerControls.style.backgroundImage = `
linear-gradient(
rgba(0, 0, 0, 0.4),
rgba(${color.r}, ${color.g}, ${color.b}, 0.3)
)
`;
} catch (error) {
console.error('Error getting dominant color:', error);
}
};
img.onerror = () => {
console.error('Error loading image');
};
img.src = imageUrl;
}
function updateNowPlaying(imageUrl, title, artist) {
const nowPlayingImg = document.getElementById('nowPlayingImg');
const nowPlayingTitle = document.getElementById('nowPlayingTitle');
const nowPlayingArtist = document.getElementById('nowPlayingArtist');
nowPlayingImg.src = imageUrl;
nowPlayingTitle.textContent = title;
nowPlayingArtist.textContent = artist;
updatePlayerControlsBackground(imageUrl);
}
// Toggle button functionality
const colorToggle = document.getElementById('colorToggle');
const toggleText = document.getElementById('toggleText');
colorToggle.addEventListener('click', () => {
isDynamicColorEnabled = !isDynamicColorEnabled;
toggleText.textContent = isDynamicColorEnabled ? 'ON' : 'OFF';
// Change icon based on state
const icon = colorToggle.querySelector('i');
if (isDynamicColorEnabled) {
icon.className = 'fas fa-palette';
const nowPlayingImg = document.getElementById('nowPlayingImg');
updatePlayerControlsBackground(nowPlayingImg.src);
} else {
icon.className = 'fas fa-palette-slash';
resetColors();
}
});
document.getElementById('nowPlayingImg').addEventListener('load', function() {
updatePlayerControlsBackground(this.src);
});
</script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script src="main.js"></script>
<script src="movies.js"></script>
<script src="src/usage-data.js"></script>
<script src="src/NewsModal/News-modal.js"></script>
<script src="src/weather/weather.js"></script>
<script src="conditions/conditions.js"></script>
<script src="speed-test/net-meter.js"></script>
<script src="user/login.js"></script>
<script src="user/data.js"></script>
<script src="https://www.youtube.com/iframe_api"></script>
<script src="vars-music.js"></script>
</body>
</html>