-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreative2.html
150 lines (135 loc) · 3.13 KB
/
creative2.html
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<!DOCTYPE html>
<html>
<head>
<title>Creative Lab #2</title>
<script type = "text/javascript" src= "http://code.jquery.com/jquery-1.12.0.min.js"></script>
<meta charset="UTF=8">
<style>
body{
font-family:Arial,sans-serif;
max-width:700px;
margin:auto;
line-height:1.5;
}
h1{
margin-top:1em
}
h2{
margin-top:2em
}
header{
text-align:center;
background-color:#b2cecf;
margin-bottom:20px
}
header h1{
margin-bottom:.75em
}
header h3{
margin-top:1px
}
button{
font-family:inherit;
font-size:100%;
padding:.5em 1em;
color:#444;
color:rgba(0,0,0,.8);
border:1px solid #999;
border:transparent;
background-color:#e6e6e6;
text-decoration:none;
border-radius:2px;
cursor:pointer
}
button:focus,button:hover{
filter: alpha(opacity=90);
background-image:-webkit-linear-gradient(transparent,rgba(0,0,0,.05) 40%,rgba(0,0,0,.1));
background-image:linear-gradient(transparent,rgba(0,0,0,.05) 40%,rgba(0,0,0,.1))
}
.card{
margin:.5rem 0 1rem 0;
padding:24px;
background-color:#fff;
transition:box-shadow .25s;
border-radius:2px
}
.card{
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12), 0 3px 1px -2px rgba(0, 0, 0, 0.2)
}
html,body{
height:100%;
margin:0;
background-image:url(http://www.emoticonswallpapers.com/background/music/music-pattern-012.png)
}
#centerEverything{
width: 70%;
margin: 0 auto;
}
body {
padding: 20px;
background-image:url();
}
html{
background-color: #d7ecf4;
}
#search-form, .form-control {
margin-bottom: 20px;
}
.cover {
width: 300px;
height: 300px;
display: inline-block;
background-size: cover;
}
.cover:hover {
cursor: pointer;
}
.cover.playing {
border: 5px solid #e45343;
}
div#results{
display: none;
}
div#art_name{
display: none;
}
div#cover_one{
width: 30%;
}
h1{
font-size: 25px;
}
</style>
</head>
<body>
<div id="centerEverything">
<div class='card'>
<h1>Search for an Artist</h1>
<form>
Enter the artist's name below, and then CLICK the button.<br>
<input type= "text" id = "user_in" >
</form>
<button onclick = "run_button()">Submit</button>
</div>
<div class='card'>
<h1>The artist's popularity!<div id = "popularity"></div></h1>
<h1>How many followers the artist has! <div id = "followers"></div></h1>
<div id="results"></div>
</div>
<div id = "art_name" ></div>
<div id = "cover_one" ></div>
</div>
<script>
function run_button(){
var user_query = document.getElementById("user_in").value;
$.getJSON('https://api.spotify.com/v1/search?q="'+ user_query +'"&type=artist', function(data){
var artist_url = $('#results').text(data.artists.items[0].id);
$.getJSON("https://api.spotify.com/v1/artists/"+artist_url.text(),function(sed){
var pic_url = $('#art_name').text(sed.images[0].url);
document.getElementById("cover_one").innerHTML = '<img src = "' + pic_url.text()+'">';
$('#popularity').text(sed.popularity);
$('#followers').text(sed.followers.total);
})})};
</script>
</body>
</html>