forked from jplip/self-care-front
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kpop.html
163 lines (146 loc) · 5.04 KB
/
kpop.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
---
permalink: /kpop
---
{% include sidebar.html %}
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background-color: black;
color: white;
background-image: url('e285661a023fb83c8d7f975980422c22.gif');
background-size: cover;
}
.container {
display: flex;
flex-direction: row;
align-items: flex-start;
}
.key-box {
width: 400px;
background-color: #8FBC8F; /* Soothing green color */
border-radius: 10px;
padding: 20px;
margin-right: 20px;
color: #333; /* Dark text color for readability */
overflow-wrap: break-word; /* Ensures long words break */
word-break: break-word; /* Ensures words break at the boundary */
}
.card {
width: 400px;
height: 500px;
background-color: #8FBC8F; /* Soothing green color */
border-radius: 20px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
padding: 20px;
display: flex;
flex-direction: column;
align-items: center; /* Center align content horizontally */
justify-content: center; /* Center align content vertically */
}
.card-title {
background-color: #4F7942; /* Darker green color */
color: white;
border-radius: 10px;
padding: 10px;
font-size: 18px;
}
.card img {
max-width: 256px;
max-height: 256px;
margin-top: 20px; /* Add some space above the image */
}
.generate-button {
background-color: #383c3e;
color: rgb(255, 255, 255);
border: none;
border-radius: 5px;
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
margin-top: 20px;
transition: background-color 0.3s;
}
.generate-button:hover {
background-color: #262829; /* hover */
}
#genre {
color: black; /* Changes the text color of the select box */
}
h3 {
color: black;
text-shadow:
-1px -1px 0 white,
1px -1px 0 white,
-1px 1px 0 white,
1px 1px 0 white;
}
</style>
<div class="dropdown">
<div class="dropbtn"> Profile /div>
<div class="dropdown-content">
<a href="profile">Profile</a>
<a onclick="logout()">Log Out</a>
</div>
</div>
<h3>Pick a genre</h3>
<select name="genre" id="genre" required style="color: black;">
<option value="">Select...</option> <!-- Changed placeholder text -->
<option value="pop">Pop</option>
<option value="rnb">R&B</option>
<option value="rock">Rock</option>
<option value="jazz_pop">Jazz/Pop</option>
<option value="rnb_pop">R&B/Pop</option>
</select>
<div class="container">
<div class="key-box">
<!-- Left container holding all info data about song -->
<h2>Song: <span id="card-song"></span></h2>
<h2>Artist: <span id="card-artist"></span></h2>
<h2>Album: <span id="card-album"></span></h2>
<h2>Genre: <span id="card-genre"></span></h2>
<h2>Time: <span id="card-time"></span></h2>
<h2>Audio: <span id="card-audio"></span></h2>
</div>
<div class="card">
<!-- Where the image is displayed with button to search -->
<div class="card-title">Song Pile</div>
<button class="generate-button" onclick="generateCard()">Generate Song</button>
<div id="table-container"></div>
<img id="random-image" src="">
</div>
</div>
<script>
function generateCard() {
const selectedGenre = document.getElementById('genre').value;
const apiUrl = `http://127.0.0.1:8432/api/kpop/random?genre=${selectedGenre}`;
fetch(apiUrl)
.then(response => response.json())
.then(data => {
// Grabs data from backend
const cardSong = data.song;
const cardArtist = data.artist;
const cardAlbum = data.album;
const cardGenre = data.genre;
const cardTime = data.time;
const imgURL = data.icon;
const cardAudio = data.audio;
// Define data to be used in container
document.getElementById('card-song').textContent = cardSong;
document.getElementById('card-artist').textContent = cardArtist;
document.getElementById('card-album').textContent = cardAlbum;
document.getElementById('card-genre').textContent = cardGenre;
document.getElementById('card-time').textContent = cardTime;
document.getElementById('random-image').src = imgURL;
document.getElementById('card-audio').textContent = cardAudio;
})
.catch(error => {
const errorMessage = document.createElement('div');
console.error('Error:', error);
document.getElementById('table-container').appendChild(errorMessage);
});
}
</script>