@@ -328,6 +328,7 @@ <h2>Trần Hữu Đạt</h2>
328328 < div class ="profile-details ">
329329 < p > < i class ="fas fa-map-marker-alt "> </ i > Ho Chi Minh City, Vietnam</ p >
330330 < p > < i class ="fas fa-calendar-alt "> </ i > Joined 2022</ p >
331+ < p > < i class ="fas fa-birthday-cake "> </ i > < span id ="age "> </ span > years old</ p >
331332 < p > < i class ="fas fa-briefcase "> </ i > Ton Duc Thang University</ p >
332333 </ div >
333334 </ div >
@@ -416,7 +417,7 @@ <h2 class="section-title">About Me</h2>
416417 </ section >
417418 </ main >
418419
419- < audio id ="audio-source "> </ audio >
420+ < audio id ="audio-source " src =" assets/music/happy-birthday.mp3 " > </ audio >
420421 < script >
421422 // Improved script to make confetti
422423 const partyContainer = document . querySelector ( '.party-container' ) ;
@@ -463,6 +464,44 @@ <h2 class="section-title">About Me</h2>
463464 document . querySelectorAll ( '.animate-on-scroll' ) . forEach ( el => {
464465 animateOnScroll . observe ( el ) ;
465466 } ) ;
467+
468+ // Music Player Logic
469+ const audio = document . getElementById ( 'audio-source' ) ;
470+ const playPauseBtn = document . getElementById ( 'play-pause-btn' ) ;
471+ let isPlaying = false ;
472+
473+ function playSong ( ) {
474+ isPlaying = true ;
475+ playPauseBtn . classList . replace ( 'fa-play' , 'fa-pause' ) ;
476+ audio . play ( ) ;
477+ }
478+
479+ function pauseSong ( ) {
480+ isPlaying = false ;
481+ playPauseBtn . classList . replace ( 'fa-pause' , 'fa-play' ) ;
482+ audio . pause ( ) ;
483+ }
484+
485+ if ( playPauseBtn ) {
486+ playPauseBtn . addEventListener ( 'click' , ( ) => ( isPlaying ? pauseSong ( ) : playSong ( ) ) ) ;
487+ }
488+
489+ // For simplicity, prev/next buttons do nothing on this page
490+ const prevBtn = document . getElementById ( 'prev-btn' ) ;
491+ const nextBtn = document . getElementById ( 'next-btn' ) ;
492+ if ( prevBtn ) prevBtn . style . display = 'none' ;
493+ if ( nextBtn ) nextBtn . style . display = 'none' ;
494+
495+ // Age Calculation
496+ const birthDate = new Date ( 2004 , 10 , 10 ) ; // Month is 0-indexed (November is 10)
497+ const today = new Date ( ) ;
498+ let age = today . getFullYear ( ) - birthDate . getFullYear ( ) ;
499+ const m = today . getMonth ( ) - birthDate . getMonth ( ) ;
500+ if ( m < 0 || ( m === 0 && today . getDate ( ) < birthDate . getDate ( ) ) ) {
501+ age -- ;
502+ }
503+ document . getElementById ( 'age' ) . textContent = age ;
504+
466505 </ script >
467506</ body >
468507</ html >
0 commit comments