-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmgic.html
246 lines (241 loc) · 18.6 KB
/
mgic.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
<!DOCTYPE html>
<html lang="en">
<head>
<title>My Girlfriend is Curious</title>
<meta charset="UTF-8">
<meta name="description" content="My Girlfriend is Curious">
<meta name="keywords" content="website, art, computer science, coding, design, video games, music, spotify">
<meta name="author" content="Nick Escobar">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body style="overflow-x: hidden; margin: 0">
<spotify style="position: fixed;">
<a href="#" class ="expand" style="position:absolute; bottom: 0; right: max(1vw,15px); min-width: 50px; max-width:80px; width: 10vmin;" onclick="document.getElementsByClassName('spotifyPlayer')[0].style.display='flex'"><img src="https://raw.githubusercontent.com/nickesc/My-Girlfriend-is-Curious/main/img/expand.png" alt="Expand Spotify" style="color: #B3B3B3; max-height: 80px"></a>
<div class="spotifyPlayer"
style="position: relative; display: none; flex-direction: row; width: 100vw; max-width: 700px; min-width: 320px; font-family: 'Helvetica Neue', sans-serif; background-color: #191414;text-overflow: ellipsis;white-space: nowrap;overflow: hidden; ">
<a href="https://open.spotify.com/user/goofyshnoofy"
style="color: white; font-weight: bold; text-decoration: none">
<div class="spotifyStatusIndicator"
style="position: absolute; right: min(1.5vmin,10px); top: min(1.5vmin,10px); background-color: #191414;text-align: center; padding: min(.7vmin,7px) min(1vmin,7px); font-size: clamp(10px, 1.5vw, 12px); min-width: 40px;max-width: 80px; border-radius: 10000px;"
onMouseOver="this.style.backgroundColor='#191414'"
onMouseOut="this.style.backgroundColor='#191414'">
</div>
</a>
<a href="#" class ="collapse" style="filter: drop-shadow(0 0 2px #232323);position:absolute; top: .5vmin; left: .7vmin; min-width: 15px; max-width:20px; width: 5vmin;" onclick="document.getElementsByClassName('spotifyPlayer')[0].style.display='none'"><img src="https://raw.githubusercontent.com/nickesc/My-Girlfriend-is-Curious/main/img/collapse.png" alt="Collapse Spotify" style="color: #B3B3B3; width: 100%"></a>
<div class="playerImgContainer" style="height: 130px;">
<img class="trackImg"
src="https://raw.githubusercontent.com/nickesc/My-Girlfriend-is-Curious/main/img/missingAlbum.png"
alt="albumArt" style="height:130px;object-fit: cover">
</div>
<div class='playerControlsContainer' style=" display: flex; flex-direction: column; width: 100%">
<div class="trackInfoContainer"
style="display: flex; flex-direction: column; height:65%; max-width: 100%; justify-content:center; padding-left: 2.5%;padding-right: 2.5%">
<div class="device"
style="color: #535353; font-size: clamp(8px,1.5vw,15px);display: flex;align-items: center;">
<div class="deviceName"> </div>
<img class="deviceImg"
src="https://raw.githubusercontent.com/nickesc/My-Girlfriend-is-Curious/main/img/blank.png"
alt="deviceImage" style="padding-left:3px;height:2ex;color: #535353">
</div>
<div class="playerMiddle"
style="display: flex; flex-direction: row; align-items: baseline; justify-content: left; width: 100%; margin: .3vh 0">
<a href="" class="trackName"
style="text-decoration:none;font-size:clamp(9px,2vw,17px);text-overflow: clip;white-space: nowrap;overflow: hidden;width: fit-content;max-width:23ch;color: white; font-weight: bold;">...</a>
<div class="trackBreak"
style="font-size: clamp(8px,2vw,20px); color: #B3B3B3; padding: 0 min(3px,1vw)">
</div>
<a href="" class="trackContext"
style="font-size: clamp(7px,1.5vw,15px);text-decoration:none; text-overflow: clip;white-space: nowrap;overflow: hidden;width: fit-content;max-width:25ch;color: #B3B3B3; font-weight: normal;"> </a>
</div>
<div style="display: flex; justify-content: space-between">
<a class="trackArtist"
style="font-size:clamp(8px,1.5vw,15px);color: #B3B3B3; font-weight: normal; text-decoration: none; text-overflow: clip;white-space: nowrap;overflow: hidden;width: fit-content;max-width:50ch;"
href=""> </a>
<div style="display: flex; flex-direction: row; justify-content: center; font-size: 15px">
<img class="shuffleImg"
src="https://raw.githubusercontent.com/nickesc/My-Girlfriend-is-Curious/main/img/blank.png"
alt="shuffleImage" style="padding-left:1vw;height:2ex;">
<img class="repeatImg"
src="https://raw.githubusercontent.com/nickesc/My-Girlfriend-is-Curious/main/img/blank.png"
alt="repeatImage" style="padding-left:1vw;padding-right:1vw;height:2ex;">
<div class="volumeLevel"
style="margin:auto 3px;min-width:3ex; width:6vw; max-width: 7ex; background-color: #191414; height: .5vw; max-height: 4px; min-height: 2px;">
<div class="volumeFill" style="background-color: #B3B3B3; width:0%; height: 100%"></div>
</div>
</div>
</div>
</div>
<div class="playerProgressContainer" style="height:10%; display: flex; flex-direction: row">
<div style="width: 95%; height:30%; background-color: #535353; margin-left: auto; margin-right: auto">
<div class="innerProgress"
style="width: 1%; height: 100%; background-color: #B3B3B3;"></div>
</div>
</div>
<a class="onSpotifyContainer"
style="font-size: 17px;text-decoration:none;height: 25%; background-color: #191414;text-align: center; color: white; font-weight: bold; display: flex;justify-content: center;align-items: center;"
onMouseOver="this.style.backgroundColor='#191414'"
onMouseOut="this.style.backgroundColor='#191414'">
<img src="https://raw.githubusercontent.com/nickesc/My-Girlfriend-is-Curious/main/img/Spotify_Icon_RGB_White.png"
style="min-height: 21px; height: 1em; margin: 10px" alt="Spotify Logo">
<div class="listenOnText" style="font-weight: bold"> </div>
</a>
</div>
<script>
const timer = 5
const mediaQuery = window.matchMedia('(min-width: 760px)');
let spotify = document.getElementsByTagName("spotify")[0];
let trackImg = document.getElementsByClassName("trackImg")[0];
let trackImgContainer = document.getElementsByClassName("playerImgContainer")[0];
let listenOnContainer = document.getElementsByClassName("onSpotifyContainer")[0];
let expand = document.getElementsByClassName("expand")[0];
function handleChange(e) {
if (mediaQuery.matches) {
spotify.style.right = "5%";
spotify.style.bottom = "5%";
trackImg.style.height = "130px";
trackImgContainer.style.maxHeight = "130px";
listenOnContainer.style.fontSize = "17px";
} else {
spotify.style.right = "0px";
spotify.style.bottom = "0px";
trackImg.style.height = "93px";
trackImgContainer.style.maxHeight = "93px";
listenOnContainer.style.fontSize = "13px";
}
}
mediaQuery.addListener(handleChange);
handleChange(mediaQuery);
const currentSongUrl = "https://mgic.onrender.com/current";
function setSong() {
fetch(currentSongUrl)
.then(data => {
return data.json();
})
.then(res => {
console.log(res);
let onlineStatus = document.getElementsByClassName("spotifyStatusIndicator")[0];
let listenOn = document.getElementsByClassName("onSpotifyContainer")[0];
let listenOnText = document.getElementsByClassName("listenOnText")[0];
let trackName = document.getElementsByClassName("trackName")[0];
let volBack = document.getElementsByClassName("volumeLevel")[0];
let trackContext = document.getElementsByClassName("trackContext")[0];
let trackBreak = document.getElementsByClassName("trackBreak")[0];
let deviceImg = document.getElementsByClassName("deviceImg")[0];
let deviceName = document.getElementsByClassName("deviceName")[0];
let artistName = document.getElementsByClassName("trackArtist")[0];
let progress = document.getElementsByClassName("innerProgress")[0];
let vol = document.getElementsByClassName("volumeFill")[0];
let shuffle = document.getElementsByClassName("shuffleImg")[0];
let repeat = document.getElementsByClassName("repeatImg")[0];
if (!res.playing) {
onlineStatus.innerHTML = "Offline";
onlineStatus.style.backgroundColor = "#d01616";
onlineStatus.onmouseover = function () {
this.style.backgroundColor = "#a21111";
}
onlineStatus.onmouseout = function () {
this.style.backgroundColor = "#d01616";
}
listenOnText.innerHTML = "UNABLE TO CONNECT";
listenOnContainer.removeAttribute("href");
trackName.innerHTML = "no track available";
trackName.removeAttribute("href");
trackContext.style.display = "none";
trackBreak.style.display = "none";
artistName.style.display = "none";
deviceName.style.display = "none";
deviceImg.style.display = "none";
shuffle.style.display = "none";
volBack.style.display = "none";
repeat.style.display = "none";
progress.style.width = "1%";
listenOnContainer.style.backgroundColor = "#191414";
listenOnContainer.onmouseover = function () {
this.style.backgroundColor = "#191414";
}
listenOnContainer.onmouseout = function () {
this.style.backgroundColor = "#191414";
}
trackImg.src = "https://raw.githubusercontent.com/nickesc/My-Girlfriend-is-Curious/main/img/missingAlbum.png";
} else {
artistName.style.display = "inline";
deviceName.style.display = "inline";
deviceImg.style.display = "inline";
shuffle.style.display = "inline";
volBack.style.display = "inline";
repeat.style.display = "inline";
volBack.style.backgroundColor = "#535353";
onlineStatus.innerHTML = "Online";
onlineStatus.style.backgroundColor = "#2E77D0";
onlineStatus.onmouseover = function () {
this.style.backgroundColor = "#235fa9";
}
onlineStatus.onmouseout = function () {
this.style.backgroundColor = "#2E77D0";
}
listenOn.style.backgroundColor = "#1DB954";
listenOnContainer.href = res.track.url;
listenOnText.innerHTML = "LISTEN ON SPOTIFY";
listenOnContainer.onmouseover = function () {
this.style.backgroundColor = "#169d46";
}
listenOnContainer.onmouseout = function () {
this.style.backgroundColor = "#1DB954";
}
trackName.innerHTML = res.track.name;
trackName.href = res.track.url;
if (res.track.context) {
trackBreak.innerHTML = "-";
trackContext.style.display = "inline";
trackBreak.style.display = "inline";
trackContext.innerHTML = res.track.context.name;
trackContext.href = res.track.context.url;
} else {
trackName.style.maxWidth = "80%";
trackContext.innerHTML = "";
trackBreak.style.display = "none";
trackBreak.style.display = "none";
}
if (res.device.type === "Smartphone" || res.device.type === "Tablet") {
deviceImg.style.display = "inline";
deviceImg.src = "https://raw.githubusercontent.com/nickesc/My-Girlfriend-is-Curious/main/img/phoneIcon.png";
} else if (res.device.type === "Computer") {
deviceImg.style.display = "inline";
deviceImg.src = "https://raw.githubusercontent.com/nickesc/My-Girlfriend-is-Curious/main/img/compIcon.png";
} else{
deviceImg.style.display = "none";
}
deviceName.textContent = res.device.name;
let artists = "";
for (let i = 0; i < res.track.artists.names.length; i++) {
if (i === 0) {
artists = res.track.artists.names[i];
} else {
artists = artists + ", " + res.track.artists.names[i];
}
}
artistName.innerHTML = artists;
artistName.href = res.track.artists.url;
progress.style.width = String(res.player.progress * 100) + "%";
trackImg.src = res.track.image;
vol.style.width = String(res.player.vol) + "%";
if (res.player.shuffle === true) {
shuffle.src = "https://raw.githubusercontent.com/nickesc/My-Girlfriend-is-Curious/main/img/shuffleOn.png";
} else {
shuffle.src = "https://raw.githubusercontent.com/nickesc/My-Girlfriend-is-Curious/main/img/shuffleOff.png";
}
if (res.player.repeat === "off") {
repeat.src = "https://raw.githubusercontent.com/nickesc/My-Girlfriend-is-Curious/main/img/repeatOff.png";
} else {
repeat.src = "https://raw.githubusercontent.com/nickesc/My-Girlfriend-is-Curious/main/img/repeatOn.png";
}
}
setTimeout(setSong, timer * 1000);
});
}
setSong()
</script>
</div>
</spotify>
</body>
</html>