-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
75 lines (65 loc) · 1.72 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Spotify</title>
<style>
body {
display: flex;
}
.spotify {
display: flex;
align-items: center;
column-gap: 16px;
/* Font */
font-family: Inter;
font-size: 24px;
color: #fff;
}
.image {
width: 52px;
height: 52px;
border-radius: 8px;
background-color: #e9e9e9;
overflow: hidden;
}
#cover {
width: 100%;
height: 100%;
object-fit: cover;
}
#artist {
opacity: 0.6;
font-size: 16px;
}
</style>
</head>
<body>
<div class="spotify">
<div class="image">
<img id="cover" src="{{ .Track.ArtworkURL }}" />
</div>
<div class="info">
<span id="name">{{ .Track.Name }}</span>
<div id="artist">{{ .Track.Artist }}</div>
</div>
</div>
</body>
<script>
const fetchCurrentTrack = () =>
fetch("http://localhost:{{ .Port }}/track").then((resp) => resp.json());
const artistEl = document.querySelector("#artist");
const coverEl = document.querySelector("#cover");
const nameEl = document.querySelector("#name");
const render = async () => {
const currentTrack = await fetchCurrentTrack();
if (!currentTrack || !currentTrack.name) return;
coverEl.src = currentTrack.artworkUrl;
nameEl.innerHTML = currentTrack.name;
artistEl.innerHTML = currentTrack.artist;
};
setInterval(render, {{ .Refresh }});
</script>
</html>