-
Notifications
You must be signed in to change notification settings - Fork 0
/
widget.html
72 lines (65 loc) · 1.83 KB
/
widget.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
<html>
<head>
<style>
body {
background: transparent;
margin: 0;
}
#main {
background: PLACEHOLDER_widgetBackground;
padding: PLACEHOLDER_widgetPadding;
border-radius: PLACEHOLDER_widgetRadius;
display: flex;
align-items: center;
flex-direction: PLACEHOLDER_layout;
}
img {
width: PLACEHOLDER_artWidth;
height: PLACEHOLDER_artHeight;
border-radius: PLACEHOLDER_artRadius;
/* prettier-ignore */
margin-PLACEHOLDER_artMarginDirection: PLACEHOLDER_artMargin;
}
#text {
display: flex;
flex-direction: column;
justify-content: center;
font-family: PLACEHOLDER_font;
text-align: PLACEHOLDER_textAlign;
}
#title {
color: PLACEHOLDER_titleColor;
font-size: PLACEHOLDER_titleSize;
font-weight: PLACEHOLDER_titleWeight;
}
#artist {
color: PLACEHOLDER_artistColor;
font-size: PLACEHOLDER_artistSize;
font-weight: PLACEHOLDER_artistWeight;
}
</style>
</head>
<body>
<div id="main">
<img />
<div id="text">
<span id="title"></span>
<span id="artist"></span>
</div>
</div>
<script>
window.addEventListener("DOMContentLoaded", () => {
const artElement = document.querySelector("img");
const titleElement = document.querySelector("#title");
const artistElement = document.querySelector("#artist");
const websocket = new WebSocket("ws://localhost:4641/");
websocket.onmessage = ({ data }) => {
json = JSON.parse(data);
artElement.src = json.artUrl;
titleElement.innerHTML = json.title;
artistElement.innerHTML = json.artist;
};
});
</script>
</body>
</html>