5656 < div >
5757 < button type ="button " title ="English / Srpsko-Hrvatski " id ="switch_version " style ="width: 120px; float: right; margin-right: 1%; "> Srpsko-Hrvatski</ button >
5858 < button type ="button " title ="Latinica / Ћирилица " id ="switch_alphabet " style ="display: none; width: 120px; float: right; margin-right: 1%; "> Ћирилица</ button >
59- </ div > < br />
59+ </ div > < br /> < br />
60+ < div class ="audio_eng " style ="text-align: center; min-height: 30px; font-style: italic; color: #ccc; margin-top: 10px; ">
61+ Audio available in English only< br /> < br />
62+ < audio id ="audio_element " style ="width: 300px; vertical-align: middle; " controls >
63+ < source src ="../../audio/Poem.mp3 " type ="audio/mpeg ">
64+ Your browser does not support the audio element.
65+ </ audio >
66+ < button type ="button " title ="Narrate Poem / Narrate Appendicies " id ="switch_audio " style ="width: 140px; vertical-align: middle; "> Narrate Appendicies</ button >
67+ < div id ="track_name " style ="font-style: italic; color: #ccc; margin-top: 10px; ">
68+ Selected: Poem Narration
69+ </ div >
70+ </ div > < br /> < br />
6071 </ p >
6172
6273 < div class ="eng ">
@@ -1736,6 +1747,11 @@ <h3>Завршна Ријеч</h3>
17361747 < script >
17371748 $ ( document ) . ready ( function ( ) {
17381749 $ ( '#switch_version' ) . click ( function ( ) {
1750+ const audio = document . getElementById ( 'audio_element' ) ;
1751+
1752+ audio . pause ( ) ;
1753+ audio . currentTime = 0 ;
1754+
17391755 $ ( 'div' ) . each ( function ( index ) {
17401756 if ( $ ( this ) . attr ( 'class' ) === 'sh_l' ) {
17411757 if ( $ ( '#switch_version' ) [ 0 ] . innerHTML === 'Srpsko-Hrvatski' ) {
@@ -1750,8 +1766,10 @@ <h3>Завршна Ријеч</h3>
17501766 } else if ( $ ( this ) . attr ( 'class' ) === 'eng' ) {
17511767 if ( $ ( '#switch_version' ) [ 0 ] . innerHTML === 'English' ) {
17521768 $ ( this ) . show ( ) ;
1769+ $ ( '.audio_eng' ) . show ( ) ;
17531770 } else {
17541771 $ ( this ) . hide ( ) ;
1772+ $ ( '.audio_eng' ) . hide ( ) ;
17551773 }
17561774 }
17571775 } ) ;
@@ -1787,6 +1805,30 @@ <h3>Завршна Ријеч</h3>
17871805 $ ( '#switch_alphabet' ) [ 0 ] . innerHTML = 'Ћирилица' ;
17881806 }
17891807 } ) ;
1808+
1809+ $ ( '#switch_audio' ) . click ( function ( ) {
1810+ const audio = document . getElementById ( 'audio_element' ) ;
1811+ const source = audio . querySelector ( 'source' ) ;
1812+
1813+ audio . pause ( ) ;
1814+ audio . currentTime = 0 ;
1815+
1816+ if ( $ ( '#switch_audio' ) [ 0 ] . innerHTML === 'Narrate Appendicies' ) {
1817+ $ ( '#switch_audio' ) [ 0 ] . innerHTML = 'Narrate Poem' ;
1818+ $ ( '#track_name' ) [ 0 ] . innerHTML = 'Selected: Appendicies Narration' ;
1819+
1820+ source . setAttribute ( 'src' , '../../audio/Appendicies.mp3' ) ;
1821+ } else {
1822+ $ ( '#switch_audio' ) [ 0 ] . innerHTML = 'Narrate Appendicies' ;
1823+ $ ( '#track_name' ) [ 0 ] . innerHTML = 'Selected: Poem Narration' ;
1824+
1825+ source . setAttribute ( 'src' , '../../audio/Poem.mp3' ) ;
1826+ }
1827+
1828+ source . setAttribute ( 'type' , 'audio/mpeg' ) ;
1829+
1830+ audio . load ( ) ;
1831+ } ) ;
17901832 } ) ;
17911833 </ script >
17921834 </ body >
0 commit comments