diff --git a/album.html b/album.html index 9340d2c..d880333 100644 --- a/album.html +++ b/album.html @@ -70,6 +70,7 @@

Fallout Boy

+ \ No newline at end of file diff --git a/collection.html b/collection.html index 7faaeae..30444db 100644 --- a/collection.html +++ b/collection.html @@ -21,6 +21,7 @@
+ \ No newline at end of file diff --git a/scripts/album.js b/scripts/album.js index e75989b..e70901a 100644 --- a/scripts/album.js +++ b/scripts/album.js @@ -37,25 +37,26 @@ var createSongRow = function(songNumber, songName, songLength) { + '' ; - return template; + return $(template); }; var setCurrentAlbum = function(album) { - var albumTitle = document.getElementsByClassName('album-view-title')[0]; - var albumArtist = document.getElementsByClassName('album-view-artist')[0]; - var albumReleaseInfo = document.getElementsByClassName('album-view-release-info')[0]; - var albumImage = document.getElementsByClassName('album-cover-art')[0]; - var albumSongList = document.getElementsByClassName('album-view-song-list')[0]; + var $albumTitle = $('.album-view-title'); + var $albumArtist = $('.album-view-artist'); + var $albumReleaseInfo = $('.album-view-release-info'); + var $albumImage = $('.album-cover-art'); + var $albumSongList = $('.album-view-song-list'); - albumTitle.firstChild.nodeValue = album.name; - albumArtist.firstChild.nodeValue = album.artist; - albumReleaseInfo.firstChild.nodeValue = album.year + ' ' + album.label; - albumImage.setAttribute('src', album.albumArtUrl); + $albumTitle.text(album.name); + $albumArtist.text(album.artist); + $albumReleaseInfo.text(album.year + ' ' + album.label); + $albumImage.attr('src', album.albumArtUrl); - albumSongList.innerHTML = ''; + $albumSongList.empty(); for (i = 0; i < album.songs.length; i++) { - albumSongList.innerHTML += createSongRow(i + 1, album.songs[i].name, album.songs[i].length); + var $newRow= createSongRow(i + 1, album.songs[i].name, album.songs[i].length); + $albumSongList.append($newRow); } }; diff --git a/scripts/collection.js b/scripts/collection.js index 9581ff1..c098b90 100644 --- a/scripts/collection.js +++ b/scripts/collection.js @@ -1,4 +1,5 @@ -var collectionItemTemplate = +var buildCollectionItemTemplate = function() { + var template = '
' + ' ' + '
' @@ -13,11 +14,15 @@ var collectionItemTemplate = + '
' + '
' ; + + return $(template); +}; -window.onload = function() { - var collectionContainer = document.getElementsByClassName('album-covers')[0]; - collectionContainer.innerHTML = ''; +$(window).load(function() { + var $collectionContainer = $('.album-covers'); + $collectionContainer.empty(); for (var i = 0; i < 12; i++) { - collectionContainer.innerHTML += collectionItemTemplate; + var $newThumbnail = buildCollectionItemTemplate(); + $collectionContainer.append($newThumbnail); } -}; \ No newline at end of file +}); \ No newline at end of file