summaryrefslogtreecommitdiff
path: root/index.js
diff options
context:
space:
mode:
authorMark Powers <mark@marks.kitchen>2022-09-24 21:51:24 -0500
committerMark Powers <mark@marks.kitchen>2022-09-24 21:51:24 -0500
commit09a0be0bd5d119c177ee18b692e84fb4ba49a129 (patch)
treee58e9f86ef452056f21a9a4999f5a6d862a77857 /index.js
parent1e04f311e6f84c19af2cf8795fc892d8f0242f5d (diff)
Add delete function and prettify now playing a bit
Diffstat (limited to 'index.js')
-rw-r--r--index.js52
1 files changed, 29 insertions, 23 deletions
diff --git a/index.js b/index.js
index a3bd2d8..521a28d 100644
--- a/index.js
+++ b/index.js
@@ -166,36 +166,28 @@ server.get('/', async (req, res) => {
margin-left: 2em;
font-style: italic;
}
+ span.time {
+ font-style: italic;
+ }
div.container {
display: flex;
flex-wrap: wrap;
}
- </style>
- <script>
- function enqueue(ids){
- ids.forEach(id => {
- fetch("/"+id)
- })
+ h2 {
+ margin: 0;
+ font-size: 16px;
+ display: inline;
+ margin-right: 1em;
}
- function random(){
- fetch("/random")
+ li {
+ border: 1px solid gray;
+ margin: 0.5em;
}
- function playlist(){
- var intervalId = setInterval(function() {
- fetch("/playlist").then(res => res.json()).then(res => {
- let el = document.getElementById("playlist")
- el.innerHTML = ''
- res.items.forEach(song => {
- var li = document.createElement("li");
- let text = song.title + " (" + (song.duration/60).toFixed(2) + " minutes)"
- li.appendChild(document.createTextNode(text))
- el.appendChild(li)
- })
- })
- }, 5000);
+ li button {
+ float: right;
}
- window.addEventListener('load', event => playlist());
- </script>
+ </style>
+ <script src="/main.js"></script>
<div>
<h1>Now playling</h1>
<ol id="playlist"><ol>
@@ -251,6 +243,20 @@ server.get('/playlist', async (req, res, next) => {
res.send(playlist_items)
})
+server.get('/main.js', async (req, res, next) => {
+ res.sendFile(__dirname + "/main.js")
+})
+
+server.get('/delete/:id', async (req, res, next) => {
+ fetch(`${config.baseURL}/post`, {
+ "credentials": "include",
+ "headers": headers(),
+ "body": `delete_music=${req.params.id}`,
+ "method": "POST",
+ })
+ res.send("ok")
+})
+
server.get('/:id', async (req, res, next) => {
enqueue(req.params.id)
res.send("ok")