empede/templates/queue.html
Sijmen 9ccacd92cb
All checks were successful
continuous-integration/drone/push Build is passing
Make queue scrollable
2023-05-07 02:51:34 +02:00

40 lines
1,018 B
HTML

{# Template #}
<!DOCTYPE html>
<ul>
{% for item in queue %}
<li {% if item.playing %}class="playing"{% endif %}>
<div class="albumart">
<img
src="/art?path={{ item.file|urlencode }}"
onerror="this.style.opacity = 0"
alt="Album art"
title="Album art"
>
</div>
<div class="metadata">
<div class="song__name" title="Song name">{{ item.title }}</div>
{% if let Some(artist) = item.artist %}
<div class="song__artist" title="Artist">{{ artist }}</div>
{% endif %}
</div>
</li>
{% endfor %}
</ul>
<script>
htmx.onLoad(() => {
const isReduced = window
.matchMedia("(prefers-reduced-motion: reduce)")
.matches;
new Sortable(document.querySelector(".queue ul"), {
animation: isReduced ? 0 : 100,
onEnd: (event) => fetch("/queue/move", {
method: "POST",
headers: {"content-type": "application/json"},
body: JSON.stringify({from: event.oldIndex, to: event.newIndex}),
}),
});
});
</script>