-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
55 lines (43 loc) · 2.09 KB
/
script.js
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
49
50
51
52
53
54
55
// bandsintown API - get request when the submit button is clicked -
// output expected is the artist name and img
document.querySelector("#searchForm").addEventListener("submit", function (event){
event.preventDefault();
var searchTerm = document.querySelector("#artist").value;
// console.log(searchTerm);
$.get("https://rest.bandsintown.com/artists/"+searchTerm+"?app_id=lineupapp", function(data){
var name = data.name;
var nameNode = document.createTextNode(name);
var createNameElement = document.createElement('p');
createNameElement.appendChild(nameNode);
createNameElement.setAttribute("style", "color: white;");
var address = document.querySelector('#artistName');
address.appendChild(createNameElement);
var image = data.image_url;
var imageNode = document.createTextNode(image);
console.log(imageNode);
var createImageElement = document.createElement('img');
console.log(createImageElement);
// createImageElement.appendChild(imageNode);
var imageAddress = document.querySelector('#artistName');
createImageElement.src = image;
imageAddress.appendChild(createImageElement);
// End of BandinTown API to get artist name and image
})
// Beginning of BandsinTown API to get event information
$.get("https://rest.bandsintown.com/artists/"+searchTerm+"/events?app_id=lineupapp", function (data){
// var unorderedList = document.createElement('ul');
console.log(data);
for (var i = 0; i <data.length; i++){
var artistEvent = document.createElement('a');
// var artistEventNode = document.createElement('li');
artistEvent.setAttribute('href', data[i].offers[0].url);
artistEvent.setAttribute('class', 'collection-item active');
artistEvent.innerHTML = data[i].venue.name;
// artistEventNode.appendChild(artistEvent);
// unorderedList.appendChild(artistEventNode);
document.getElementById('artistEvents').appendChild(artistEvent);
}
// // End of BandsinTown API to get event infomation
})
// End of eventListener
})