forked from meankit2610/CW-1-Spotify-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdashboard.js
More file actions
48 lines (38 loc) · 1.31 KB
/
dashboard.js
File metadata and controls
48 lines (38 loc) · 1.31 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
var songs=[
{url:"img/1.jpg",name:"Bollywood Butter"},
{url:"img/2.jpg",name:"Punjabi 101"},
{url:"img/3.jpg",name:"Kollywood Cream"},
{url:"img/4.jpg",name:"Indie India"},
{url:"img/5.jpg",name:"Tollywood Pearls"},
{url:"img/6.jpg",name:"India Top 50"},
{url:"img/7.jpg",name:"Sleep"},
{url:"img/8.jpg",name:"New Music Hindi"},
{url:"img/9.jpg",name:"Dinner"}
]
var input = document.getElementById("searchbar");
input.addEventListener("keypress", function() {
// var myDiv = document.getElementsByClassName("songItemContainer");
// myDiv.innerHTML = "";
var arr=[];
var inputValue = document.getElementById("searchbar").value;
arr = songs.filter(function(eles){
return eles.name.includes(inputValue);
})
console.log(arr);
display(arr);
})
function display(arr){
document.querySelector(".songItemContainer").innerHTML="";
for(var i=0;i<arr.length;i++){
var anchor=document.createElement("a");
anchor.setAttribute("href","play.html");
var divi=document.createElement("div");
var im=document.createElement("img");
im.setAttribute("src",arr[i].url);
var name=document.createElement("p");
name.innerText=arr[i].name;
anchor.append(divi);
divi.append(im,name);
document.querySelector(".songItemContainer").append(anchor);
}
}