-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
338 lines (318 loc) · 10.6 KB
/
index.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
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
<!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>Home</title>
</head>
<body>
<div class="container-fluid">
<div class="row">
<!--SIDEBAR VERTICAL-->
<div class="col-2">
<nav
class="navbar 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>
<div id="rock">
<h2>Rock Classics</h2>
<div class="row imgLinks py-3" id="rockSection"></div>
</div>
<div id="pop">
<h2>Pop Culture</h2>
<div class="row imgLinks py-3" id="popSection"></div>
</div>
<div id="hiphop">
<h2>#HipHop</h2>
<div class="row imgLinks py-3" id="hipHopSection"></div>
</div>
</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>
var rockArtists = [
"queen",
"u2",
"thepolice",
"eagles",
"thedoors",
"oasis",
"thewho",
"bonjovi"
];
var popArtists = [
"maroon5",
"coldplay",
"onerepublic",
"jamesblunt",
"katyperry",
"arianagrande"
];
var hipHopArtists = [
"eminem",
"snoopdogg",
"lilwayne",
"drake",
"kanyewest"
];
function albumCard(songInfo) {
//songInfo represents the info for the current song
console.log(songInfo);
//206: creating the wrapper div
//207: creating the anchor (link) in the image
//209: setting the image source
//213: creating the link for the album page
//220: creating the link for the artist page
return `
<div class="col-sm-auto col-md-auto text-center" id=${songInfo.id}>
<a href="/album_page?id=${songInfo.album.id}">
<img class="img-fluid" src=${
songInfo.album.cover_medium
} alt="1" />
</a>
<p>
<a href="/album_page?id=${songInfo.album.id}">
Album: "${
songInfo.album.title.length < 16
? `${songInfo.album.title}`
: `${songInfo.album.title.substring(0, 16)}...`
}"<br>
</a>
<a href="/artist_page?id=${songInfo.artist.id}">
Artist: ${songInfo.artist.name}
</a>
</p>
</div>`;
}
window.onload = function() {
var rockRandomArtists = [];
var popRandomArtists = [];
var hipHopRandomArtists = [];
while (rockRandomArtists.length < 4) {
//pushes elements inside the array until it has 4 strings
var artist =
rockArtists[Math.floor(Math.random() * rockArtists.length)]; //select an element from the array with an index between 0 and 7
if (!rockRandomArtists.includes(artist)) {
//checks if the artist is not already present in the array
rockRandomArtists.push(artist); //pushes the artist in the array
}
}
while (popRandomArtists.length < 4) {
var artist =
popArtists[Math.floor(Math.random() * popArtists.length)];
if (!popRandomArtists.includes(artist)) {
popRandomArtists.push(artist);
}
}
while (hipHopRandomArtists.length < 4) {
var artist =
hipHopArtists[Math.floor(Math.random() * hipHopArtists.length)];
if (!hipHopRandomArtists.includes(artist)) {
hipHopRandomArtists.push(artist);
}
}
var headers = new Headers({
"X-RapidAPI-Host": "deezerdevs-deezer.p.rapidapi.com",
"X-RapidAPI-Key": "9d408f0366mshab3b0fd8e5ecdf7p1b09f2jsne682a1797fa0"
});
for (var j = 0; j < rockRandomArtists.length; j++) {
fetch(
"https://deezerdevs-deezer.p.rapidapi.com/search?q=" +
rockRandomArtists[j],
{
method: "GET",
headers
}
)
.then(function(response) {
if (response.ok) {
return response.json();
}
})
.then(function(artists) {
// console.log("ARTISTS", artists);
var songInfo = artists.data;
var div = document.querySelector("#rockSection");
div.innerHTML += albumCard(songInfo[0]);
})
.catch(function(error) {
console.log(error);
});
}
for (var j = 0; j < popRandomArtists.length; j++) {
fetch(
"https://deezerdevs-deezer.p.rapidapi.com/search?q=" +
popRandomArtists[j],
{
method: "GET",
headers: headers
}
)
.then(function(response) {
if (response.ok) {
return response.json();
}
})
.then(function(artists) {
var songInfo = artists.data;
var div = document.querySelector("#popSection");
div.innerHTML += albumCard(songInfo[0]);
})
.catch(function(error) {
console.log(error);
});
}
for (var j = 0; j < hipHopRandomArtists.length; j++) {
fetch(
"https://deezerdevs-deezer.p.rapidapi.com/search?q=" +
hipHopRandomArtists[j],
{
method: "GET",
headers: headers
}
)
.then(function(response) {
if (response.ok) {
return response.json();
}
})
.then(function(artists) {
var songInfo = artists.data;
var div = document.querySelector("#hipHopSection");
div.innerHTML += albumCard(songInfo[0]);
})
.catch(function(error) {
console.log(error);
});
}
};
</script>
</body>
</html>