From c938660fde60680edf1d614ed6b02c485c49a6cc Mon Sep 17 00:00:00 2001 From: danielkravtsov5 Date: Sun, 19 Sep 2021 00:06:58 +0300 Subject: [PATCH] seconds mission --- scripts/index.js | 110 +++++++++++++++++++++++++++++++++++++++++++---- style.css | 45 ++++++++++++++++++- 2 files changed, 146 insertions(+), 9 deletions(-) diff --git a/scripts/index.js b/scripts/index.js index 6842c794..bd755bd6 100644 --- a/scripts/index.js +++ b/scripts/index.js @@ -3,27 +3,71 @@ * Playing a song means changing the visual indication of the currently playing song. * * @param {String} songId - the ID of the song to play + * + * */ -function playSong(songId) { - // Your code here + titleCreation('Songs', 'songs'); + + function timeConvert (seconds){ + let date = new Date(null); + date.setSeconds(seconds); + let result = date.toISOString().substr(11, 8); + return result; + } + + function playSong(songId) { + const chosenSong = document.getElementById(songId) + chosenSong.classList.add("chosenSong"); + } /** * Creates a song DOM element based on a song object. */ function createSongElement({ id, title, album, artist, duration, coverArt }) { - const children = [] - const classes = [] - const attrs = { onclick: `playSong(${id})` } + const coverImg = createElement('img', [],["songPhoto"],{src: coverArt}); + const children = [coverImg, "Song Name:"+ title + " ,","Album:"+ album+ " ,","Artist:"+ artist+ " ,","Duration:" +timeConvert(duration)+ " "] + const classes = ['songElement'] + const attrs = { onclick: `playSong(${id})`, id: id} + return createElement("div", children, classes, attrs) } /** * Creates a playlist DOM element based on a playlist object. */ + + titleCreation('Playlists', 'playlists'); + +function numberOfSongs(playlistId){ + let totalSongsNum = 0; + for (let i = 0; i