Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Commit

Permalink
Add simple playlist app
Browse files Browse the repository at this point in the history
  • Loading branch information
sicktastic committed Jun 1, 2016
1 parent 123f762 commit c12a558
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
20 changes: 20 additions & 0 deletions object_oriented_javascript/playlist/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,23 @@ var walkingOnSunshine = new Song("Walking on Sunshine", "Katrina and the Wave",

playlist.add(hereComesTheSun);
playlist.add(walkingOnSunshine);

var playlistElement = document.getElementById("playlist");

playlist.renderInElement(playlistElement);

var playButton = document.getElementById("play");
playButton.onclick = function() {
playlist.play();
playlist.renderInElement(playlistElement);
}
var nextButton = document.getElementById("next");
nextButton.onclick = function() {
playlist.next();
playlist.renderInElement(playlistElement);
}
var stopButton = document.getElementById("stop");
stopButton.onclick = function() {
playlist.stop();
playlist.renderInElement(playlistElement);
}
6 changes: 4 additions & 2 deletions object_oriented_javascript/playlist/playlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ Playlist.prototype.next= function() {
};

Playlist.prototype.renderIn = function() {

list.innerHTML = "";
for(var i=0; i < this.songs.length; i++) {
list.innnerHTML += this.songs[i].toHTML();
}
}


13 changes: 12 additions & 1 deletion object_oriented_javascript/playlist/song.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,16 @@ Song.prototype.stop = function() {
};

Song.prototype.toHTML = function() {

var htmlString = '<li';
if (this.isPlaying) {
htmlString += ' class="current"';
}
htmlString += '>';
htmlString += this.title;
htmlString += ' - ';
htmlString += this.artist;
htmlString += '<span class="duration">'
htmlString += this.duration;
htmlString += '</span></li>';
retrun htmlString;
};

0 comments on commit c12a558

Please sign in to comment.