Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
Binary file added images/.DS_Store
Binary file not shown.
Binary file added images/bloom.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/bon_iver.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/cleopatra.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/currents.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/daughter.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/flume.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/in_return.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/naked_famous.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/pharmacy.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/purity_ring.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/rise.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/spreading_rumors.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/strfkr.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added images/zaba.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/zhu.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 36 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,44 @@
<html>
<head>
<meta charset="utf-8">
<title></title>
<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
<script type="text/javascript" src="index.js"></script>
<link rel="stylesheet" href="style.css">
<title>Playlist</title>
</head>
<body>


<div class="container">


<div class="header">

</div>

<div class="body">
<div class="left">

<div class="left-container">
<h1>track bin</h1>
<a href="playlist.html"><button type="button">choose tracks</button></a>
</div>

</div>
<div class="right">
<div class="right-overlay"></div>

<div class="right-container">
</div>

</div>
</div>

<div class="footer">
<h6>&copy; 2017 Natalie Despain</h6>
</div>

</div>


</body>
</html>
28 changes: 28 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
$(document).ready(function() {


function randomImgs() {
$.ajax({url: 'https://baroque-chaise-16357.herokuapp.com/api', success: function(result) {

var randomIndexes = []
while(randomIndexes.length < 3){
var randomnumber = Math.ceil(Math.random()*result.results.length) - 1;
if(randomIndexes.indexOf(randomnumber) > -1) continue;
randomIndexes[randomIndexes.length] = randomnumber;
}

for (var index of randomIndexes) {
var div = $("<div></div>").css({'background': `url('images/${result.results[index].cover_art}')`, 'background-size': 'cover'});
$('.right-container').append(div);
}

}});
}

randomImgs();





})
58 changes: 58 additions & 0 deletions playlist.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
<script type="text/javascript" src="playlist.js"></script>
<link rel="stylesheet" href="playliststyle.css">
<title>Playlist</title>
</head>
<body>

<div class="container">


<div class="header">
<h1>click an album to add it's tracks to bin</h1>
</div>

<div class="body">

<div class="slider">
<div class="content">
</div>
</div>

<div class="bin-container">
<div class="box">
<h6>Add tracks from:</h6>
<h6 id="current-album">Click on an album!</h6>
<div class="current-album-image">
</div>
</div>
<div class="album-tracks">

</div>
<div class="arrow">

</div>
<div class="playlist-tracks">

</div>
</div>
<div class="button-container">
<button type="button" id="clear">clear tracks</button>
<button type="button" id="submit">submit bin</button>
</div>

</div>

<div class="footer">
<h6>&copy; 2017 Natalie Despain</h6>
</div>

</div>


</body>
</html>
116 changes: 116 additions & 0 deletions playlist.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
$(document).ready(function() {



$.ajax({url: 'https://baroque-chaise-16357.herokuapp.com/api', success: function(result) {

// APPEND IMGS TO SLIDER
for (var i = 0; i < result.results.length; i++) {
var div = $(`<div id="${result.results[i].id}" class="scrollImg"></div>`).css({'background': `url('images/${result.results[i].cover_art}')`, 'background-size': 'cover'});
$('.content').append(div);
}


// // ADD TEXT ON CLICK
// $('.scrollImg').click(function(e){
// var id = Number(e.target.id);
//
// for (var item of result.results) {
// if (item.id === id) {
// var text = $(`<h6>${item.artist}: ${item.title}</h6>`);
// $('.box').append(text);
// }
// }
//
// })

// CHANGE CURRENT SELECTION
$('.scrollImg').click(function(e){
$('.album-tracks').empty();
var id = Number(e.target.id);

for (var item of result.results) {
if (item.id === id) {
$('#current-album').text(`${item.artist}: ${item.title}`);
$('.current-album-image').css({'background': `url('images/${item.cover_art}')`, 'background-size': 'cover'})
for (var i = 0; i < item.tracks.length; i++) {
var track = $(`<h6>${item.tracks[i].title} - ${item.tracks[i].length}</span></h6>`);
$('.album-tracks').append(track);
}
}
}

})

// ADD SONG TO PLAYLIST
$('.album-tracks').click(function(e){
if (e.target.localName === 'h6') {
var song = $(`<h6>${e.target.innerText}</span></h6>`);
$('.playlist-tracks').append(song);
}
})

}});



// CLEAR PLAYLIST
$('#clear').click(function() {
$('.playlist-tracks').empty();
})


// SUBMIT AND POST
$('#submit').click(function() {

var collection = {};
var htmlCollection = $('.playlist-tracks').children();
for (var i = 0; i < htmlCollection.length; i++) {
var split = htmlCollection[i].innerHTML.split(" - ");
collection[split[0]] = split[1];
}

var jsonData = JSON.stringify(collection)
console.log(jsonData)

$.ajax({
type: "POST",
url: "https://lit-fortress-6467.herokuapp.com/post",
data: jsonData,
success: function(msg) {
console.log(msg);
}
});

})



// $('#submit').click(function() {
//
// var collection = {};
// var htmlCollection = $('.box').children();
// for (var i = 0; i < htmlCollection.length; i++) {
// var split = htmlCollection[i].innerHTML.split(": ");
// collection[split[0]] = split[1];
// }
//
// var jsonData = JSON.stringify(collection)
// console.log(jsonData)
//
// $.ajax({
// type: "POST",
// url: "https://lit-fortress-6467.herokuapp.com/post",
// data: jsonData,
// success: function(msg) {
// console.log(msg);
// }
// });
//
// })





})
Loading