diff --git a/README.md b/README.md index d12d8eb8..97efb55c 100644 --- a/README.md +++ b/README.md @@ -28,14 +28,13 @@ Each song list item shall display the following details: - `album` name - `artist` name - an image with the album's cover art (`coverArt`) -- song `duration` (in `mm:ss` format, of course) +- ********* song `duration` (in `mm:ss` format, of course)**************** One song can be played at a time. There should be some indication of the currently playing song (the specific indication is up to you). Clicking on a song will change the indication of the currently playing song. We have already provided code that handles the click event for you. ### Playlists Every playlist list item should display the following information: - - playlist `name` - the number of songs in the playlist - the total duration of the playlist diff --git a/scripts/index.js b/scripts/index.js index 6842c794..2c122556 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