-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
47 lines (38 loc) · 1.29 KB
/
script.js
File metadata and controls
47 lines (38 loc) · 1.29 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
var url = "https://itunes.apple.com/search?term=kanye+west&limit=10";
function requestAPI(){
artistName = $("#artistName").val();
limit = $("#resultLimit").val();
url = "https://itunes.apple.com/search?term=" + artistName + "&limit=" + limit;
$.ajax({
url: url,
type: 'GET',
crossDomain: true,
dataType: 'jsonp',
success: function(result) {
execute(result) },
error: function() {
alert('Failed!');
}
});
}
function execute(result){
$("#fillItIn").html("");
console.log(result);
for(var i = 0; i < limit; i++){
var imageURL = result["results"][i]["artworkUrl100"];
var trackName = result["results"][i]["trackName"];
var song = result["results"][i]["previewUrl"];
$("#fillItIn").append('<tr class="tr"> ' +
'<th>' + (i + 1) + '</th>' +
'<th><img onclick="playSong(' + song + ')" src=' + imageURL + '></th> ' +
'<th><audio controls src="' + song + '" type="audio/m4a"></audio></th>' +
'<th>' + trackName + '</th>' +
'</tr>');
}
}
$(document).ready(function(){
$(".th").on("mouseenter", function(){
$(this).animate({"background-color": "red"}, "400ms");
console.log(this);
})
});