forked from gSchool/playlist
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaylist.js
More file actions
25 lines (25 loc) · 1019 Bytes
/
playlist.js
File metadata and controls
25 lines (25 loc) · 1019 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
fetch(' https://lit-fortress-6467.herokuapp.com/object')
.then(function(response) {
return response.json();
})
.then(function(stuff) {
var randomArr = []
while(randomArr.length < 3){
var randomnumber = Math.floor(Math.random()*stuff.results.length);
if(randomArr.indexOf(randomnumber) > -1) continue;
randomArr[randomArr.length] = randomnumber;
}
const albums_results = stuff.results.filter(function(currValue, index){
if(randomArr.indexOf(index)>-1){
return true;
}
});
for (let i = 0; i < albums_results.length; i++) {
const album=albums_results[i];
const albumElement =document.createElement("img")
albumElement.setAttribute("src", `./images/${album.cover_art}`)
albumElement.setAttribute("style", " display:block; margin: 0 auto; width:170px; ,margin-left:160px; padding-top:30px;")
var imagebox=document.getElementsByClassName("image")
imagebox[0].appendChild(albumElement)
}
});