39 lines
1.1 KiB
JavaScript
39 lines
1.1 KiB
JavaScript
|
async function initHandler() {
|
||
|
let body = $('body');
|
||
|
$('.playlist.menu-icon').addEventListener('click', e => {
|
||
|
player.playlist.renderPagination(player.playlist.page);
|
||
|
});
|
||
|
|
||
|
body.addDelegatedEventListener('click', '.playlist-item', (e, el) => {
|
||
|
let number = el.dataset.index;
|
||
|
player.playByID(parseInt(number));
|
||
|
togglePlayButton('pause');
|
||
|
});
|
||
|
|
||
|
body.addDelegatedEventListener('click', '.controls button', (e, el) => {
|
||
|
switch (el.id) {
|
||
|
case 'previous':
|
||
|
player.prevSong();
|
||
|
break;
|
||
|
case 'next':
|
||
|
player.nextSong()
|
||
|
break;
|
||
|
case 'play':
|
||
|
player.playStop();
|
||
|
break;
|
||
|
}
|
||
|
togglePlayButton(audioHandler.audioFile.paused ? 'play' : 'pause');
|
||
|
});
|
||
|
}
|
||
|
|
||
|
|
||
|
function togglePlayButton(status) {
|
||
|
let icons = $$('#play .icon');
|
||
|
icons.forEach(el => {
|
||
|
if(el.dataset.name === status) {
|
||
|
el.removeClass('hide');
|
||
|
} else {
|
||
|
el.addClass('hide');
|
||
|
}
|
||
|
})
|
||
|
}
|