-
Notifications
You must be signed in to change notification settings - Fork 0
/
artist_page.html
287 lines (268 loc) · 9.48 KB
/
artist_page.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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<script src="https://kit.fontawesome.com/1205482781.js"></script>
<!-- Bootstrap CSS -->
<link
rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T"
crossorigin="anonymous"
/>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"
/>
<link rel="stylesheet" type="text/css" href="style.css" />
<title>Artist</title>
</head>
<body>
<div class="container-fluid">
<div class="row">
<!--SIDEBAR VERTICAL-->
<div class="col-2">
<nav
class="navbar navbar-expand-lg navbar-expand-md navbar-white bg-navbar fixed-left justify-content-between"
>
<div class="nav-container">
<a class="navbar-brand" href="index.html">
<img
src="logo/Spotify_Logo.png"
alt="Spotify_Logo"
width="131"
height="40"
/>
</a>
<button
class="navbar-toggler"
type="button"
data-toggle="collapse"
data-target="#navbarNavAltMarkup"
aria-controls="navbarNavAltMarkup"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavAltMarkup">
<div class="navbar-nav">
<ul>
<li>
<a class="nav-item nav-link" href="index.html"
><i class="fas fa-home fa-lg"></i> Home
</a>
</li>
<li>
<a class="nav-item nav-link" href="#"
><i class="fas fa-search fa-lg"></i> Search</a
>
</li>
<li>
<a class="nav-item nav-link" href="#"
><i class="fas fa-book-open fa-lg"></i> Your
Library</a
>
</li>
</ul>
</div>
</div>
</div>
<div class=" nav-btn">
<button class="btn signup-btn" type="button">Sign Up</button>
<button class="btn login-btn" type="button">Login</button>
<a href="#">Cookie Policy</a> |
<a href="#"> Privacy</a>
</div>
</nav>
</div>
<!--END SIDEBAR VERTICAL-->
<!--MAIN-->
<div class="col-10 mainPage">
<div class="mainLinks">
<a href="#">TRENDING</a>
<a href="#">PODCAST</a>
<a href="#">MOODS AND GENRES</a>
<a href="#">NEW RELEASES</a>
<a href="#">DISCOVER</a>
</div>
<section>
<div class="mt-5" id="artist-title">
<h2 class="titleMain"></h2>
<div id="followers"></div>
<div class="d-flex justify-content-center" id="button-container">
<button
class="btn btn-success mr-2 mainButton d-none"
id="playButton"
>
PLAY
</button>
<button
class="btn btn-outline-light mainButton d-none"
id="followButton"
>
FOLLOW
</button>
</div>
</div>
<div id="artist-tracks">
<div
class="container title-container mt-4 d-flex justify-content-start"
>
<h2 class="title text-white font-weight-bold">Tracks</h2>
</div>
<div class="container pt-5 mb-5">
<div class="row" id="apiLoaded"></div>
</div>
</div>
</section>
</div>
</div>
</div>
<!--END MAIN-->
<!--NAVBAR FLEX-BOTTOM-->
<div class="container-fluid fixed-bottom bg-container">
<div class="row">
<div class="col-12 playerControls text-center">
<a href="#">
<img src="playerbuttons/Shuffle.png" alt="shuffle" />
</a>
<a href="#">
<img src="playerbuttons/Previous.png" alt="shuffle" />
</a>
<a href="#">
<img src="playerbuttons/Play.png" alt="shuffle" />
</a>
<a href="#">
<img src="playerbuttons/Next.png" alt="shuffle" />
</a>
<a href="#">
<img src="playerbuttons/Repeat.png" alt="shuffle" />
</a>
</div>
</div>
<div class="row justify-content-center playBar py-3">
<div class="progress">
<div
class="progress-bar"
role="progressbar"
aria-valuenow="0"
aria-valuemin="0"
aria-valuemax="100"
></div>
</div>
</div>
</div>
<!--END NAVBAR BOTTOM-->
<script
src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin="anonymous"
></script>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"
integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1"
crossorigin="anonymous"
></script>
<script
src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"
integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM"
crossorigin="anonymous"
></script>
<script>
function albumCard(songInfo) {
//195: creating the album image anchor
//202: setting the track title, if it's longer than 16 chars cuts the rest
//209: setting the album title, if it's longer than 16 chars cuts the rest
return `
<div class="col-sm-auto col-md-auto text-center mb-5">
<a href="/album_page?id=${songInfo.album.id}">
<img class="img-fluid" src=${
songInfo.album.cover_medium
} alt="1" />
</a>
<p>
<a href="#">
Track: "${
songInfo.title.length < 16
? `${songInfo.title}`
: `${songInfo.title.substring(0, 16)}...`
}"
</a><br>
<a href="/album_page?id=${songInfo.album.id}">
Album: "${
songInfo.album.title.length < 16
? `${songInfo.album.title}`
: `${songInfo.album.title.substring(0, 16)}...`
}"
</a>
</p>
</div>`;
}
window.onload = function() {
var artistId = new URLSearchParams(document.location.search).get("id");
var headers = new Headers({
"X-RapidAPI-Host": "deezerdevs-deezer.p.rapidapi.com",
"X-RapidAPI-Key": "222902beabmshb95a65b737cead6p1f3ac9jsn23ced94c0d20"
});
fetch("https://deezerdevs-deezer.p.rapidapi.com/artist/" + artistId, {
method: "GET",
headers
})
.then(function(response) {
if (response.ok) {
return response.json();
}
})
.then(function(artist) {
console.log("ARTIST", artist);
//displaying the playButton
var playButton = document.querySelector("#playButton");
playButton.classList.remove("d-none");
playButton.classList.add("d-inline");
//displaying the followButton
var followButton = document.querySelector("#followButton");
followButton.classList.remove("d-none");
followButton.classList.add("d-inline");
//setting the artist name
var titleMain = document.querySelector(".titleMain");
titleMain.innerHTML = artist.name;
//setting the followers section
var followers = document.querySelector("#followers");
followers.innerText = artist.nb_fan + " followers";
var tracks = fetch(
"https://deezerdevs-deezer.p.rapidapi.com/search?q=" +
artist.name,
{
method: "GET",
headers
}
)
.then(function(response) {
if (response.ok) {
return response.json();
}
})
.then(function(tracklist) {
console.log("TRACKLIST", tracklist);
for (var i = 0; i < tracklist.data.length; i++) {
var apiLoaded = document.querySelector("#apiLoaded");
apiLoaded.innerHTML += albumCard(tracklist.data[i]);
}
})
.catch(function(error) {
console.log(error);
});
})
.catch(function(error) {
console.log(error);
});
};
</script>
</body>
</html>