diff --git a/.prettierrc b/.prettierrc index 0fc66c4d..87a023cb 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,5 +1,5 @@ { - "semi": false, - "tabWidth": 4, - "printWidth": 120 + "semi": false, + "tabWidth": 4, + "printWidth": 120 } diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..a90daae9 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "liveServer.settings.port": 5501 +} diff --git a/index.html b/index.html index c55fb482..a75f13c4 100644 --- a/index.html +++ b/index.html @@ -4,16 +4,23 @@ Awesome MP3 Player - + + + + + -
- -
-
- -
+
+

Mp3 player(old web)

+
+
+

Songs

+
+
+

Playlists

+
diff --git a/index.new.html b/index.new.html index eba39f17..38e8a50d 100644 --- a/index.new.html +++ b/index.new.html @@ -4,57 +4,39 @@ Awesome MP3 Player - + + -

Awesome Player!!!

-
-

Add a new song

-
- - - - - -
- -
-
-

Songs

-
- -
-
-
-

Playlists

-
- +
diff --git a/scripts/index.js b/scripts/index.js index 6842c794..b04a6d2d 100644 --- a/scripts/index.js +++ b/scripts/index.js @@ -4,26 +4,51 @@ * * @param {String} songId - the ID of the song to play */ + function playSong(songId) { - // Your code here + const divAllSong = document.getElementsByClassName("child") //the div that wrap of the song + for (const divSong of divAllSong) { + //remove the green mark from all songs + divSong.style.borderLeft = "transparent" + } + const currentSong = document.getElementById(songId) + currentSong.style.borderRadius = "10px" //the left green mark when song playing + currentSong.style.borderLeft = "20px solid green" } +const divOfAllSongs = document.getElementById("songs") +divOfAllSongs.addEventListener("click", (e) => { + playSong(e.target.id) +}) + /** * 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 children = [ + createElement("img", [], ["border-Img"], { src: coverArt }), + createElement("span", "Title | " + title, [], {}), + createElement("span", "Album | " + album, [], {}), + createElement("span", "Artist | " + artist, [], {}), + createElement("span", durationFormat(duration), ["duration"], {}), + ] + const classes = ["child"] + const attrs = { id: "song" + id, title: "title" + title } return createElement("div", children, classes, attrs) } /** * Creates a playlist DOM element based on a playlist object. */ + function createPlaylistElement({ id, name, songs }) { - const children = [] - const classes = [] + const children = [ + createElement("span", name, [], {}), + createElement("span", " | " + [songs.length] + " songs ", [], {}), + createElement("span", playlistDuration(id), ["duration"], {}), + ] + const classes = ["child"] const attrs = {} return createElement("div", children, classes, attrs) } @@ -34,14 +59,76 @@ function createPlaylistElement({ id, name, songs }) { * Example usage: * createElement("div", ["just text", createElement(...)], ["nana", "banana"], {id: "bla"}) * - * @param {String} tagName - the type of the element - * @param {Array} children - the child elements for the new element. + * @param {String} tagName - the type of the element: for example- p,h1,div... + * @param {Array} children - the child elements for the new element: for example- assume ew have