Song server: search and download songs, mobile web UI
- Sources: "free" (Creative Commons songs with media from github.com/UltraStar-Deluxe/songs) and "usdb" (usdb.animux.de with an account; audio/video via yt-dlp from the song's #VIDEO hints or YouTube links in the comments, covers from fanart.tv/YouTube) - Aggregated search (all sources in parallel, in-library flag), download queue into <library>/Downloads/<source>/<Artist - Title>, then rescan - Web UI in wwwroot (plain JS, no build): search, downloads with progress, library; phone first, dark mode, installable - Docker image with yt-dlp, ffmpeg and deno; library mounted writable - Tests for matching, USDB parsing and song rewriting Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
efcc63a640
commit
1e65864c8f
19 files changed
+1862
-12
No files matched your search
@@ -0,0 +1,306 @@
|
||||
:root {
|
||||
--bg: #f6f5fb;
|
||||
--card: #ffffff;
|
||||
--text: #1c1830;
|
||||
--muted: #6b6785;
|
||||
--line: #e4e1ef;
|
||||
--accent: #7c3aed;
|
||||
--accent-text: #ffffff;
|
||||
--accent-soft: #ede7fd;
|
||||
--ok: #15803d;
|
||||
--ok-soft: #dcfce7;
|
||||
--err: #b91c1c;
|
||||
--err-soft: #fee2e2;
|
||||
--radius: 14px;
|
||||
--nav-h: 64px;
|
||||
color-scheme: light dark;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
--bg: #12101c;
|
||||
--card: #1d1a2b;
|
||||
--text: #eceaf6;
|
||||
--muted: #a29dbd;
|
||||
--line: #2e2a42;
|
||||
--accent: #a78bfa;
|
||||
--accent-text: #160f2c;
|
||||
--accent-soft: #2c2350;
|
||||
--ok: #4ade80;
|
||||
--ok-soft: #14301f;
|
||||
--err: #f87171;
|
||||
--err-soft: #3a1717;
|
||||
}
|
||||
}
|
||||
|
||||
* { box-sizing: border-box; }
|
||||
|
||||
html, body { margin: 0; }
|
||||
|
||||
body {
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
|
||||
}
|
||||
|
||||
.top {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 5;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
|
||||
background: color-mix(in srgb, var(--bg) 88%, transparent);
|
||||
backdrop-filter: blur(10px);
|
||||
}
|
||||
|
||||
.top h1 {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin: 0;
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
|
||||
main {
|
||||
max-width: 720px;
|
||||
margin: 0 auto;
|
||||
padding: 0 16px 16px;
|
||||
}
|
||||
|
||||
.tab { display: none; }
|
||||
.tab.active { display: block; }
|
||||
|
||||
.muted { color: var(--muted); font-size: .9rem; }
|
||||
|
||||
.searchbar { margin: 4px 0 10px; }
|
||||
|
||||
.searchbar input, dialog input {
|
||||
width: 100%;
|
||||
min-height: 48px;
|
||||
padding: 0 16px;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 999px;
|
||||
background: var(--card);
|
||||
color: var(--text);
|
||||
font-size: 1.05rem; /* >= 16px: no zoom on iOS */
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.searchbar input:focus, dialog input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
|
||||
|
||||
.chips {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 4px 10px;
|
||||
border-radius: 999px;
|
||||
background: var(--accent-soft);
|
||||
color: var(--text);
|
||||
font-size: .8rem;
|
||||
}
|
||||
|
||||
.chip.off { background: transparent; border: 1px dashed var(--line); color: var(--muted); }
|
||||
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
|
||||
.chip.off .dot { background: var(--muted); }
|
||||
|
||||
.status { padding: 12px 4px; color: var(--muted); }
|
||||
.status.error { color: var(--err); }
|
||||
|
||||
.list {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.item {
|
||||
display: grid;
|
||||
grid-template-columns: 56px 1fr auto;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 10px;
|
||||
border-radius: var(--radius);
|
||||
background: var(--card);
|
||||
border: 1px solid var(--line);
|
||||
}
|
||||
|
||||
.item .cover {
|
||||
width: 56px;
|
||||
height: 56px;
|
||||
border-radius: 10px;
|
||||
object-fit: cover;
|
||||
background: var(--accent-soft);
|
||||
display: grid;
|
||||
place-items: center;
|
||||
color: var(--accent);
|
||||
font-weight: 700;
|
||||
font-size: 1.2rem;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.item .text { min-width: 0; }
|
||||
|
||||
.item .title {
|
||||
font-weight: 600;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.item .artist, .item .details {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.item .artist { font-size: .92rem; }
|
||||
.item .details { color: var(--muted); font-size: .8rem; }
|
||||
|
||||
.source {
|
||||
display: inline-block;
|
||||
margin-right: 4px;
|
||||
padding: 0 6px;
|
||||
border-radius: 6px;
|
||||
background: var(--accent-soft);
|
||||
color: var(--text);
|
||||
font-size: .72rem;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: .02em;
|
||||
}
|
||||
|
||||
button {
|
||||
font: inherit;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.action {
|
||||
min-width: 44px;
|
||||
min-height: 44px;
|
||||
padding: 0 14px;
|
||||
border: 0;
|
||||
border-radius: 999px;
|
||||
background: var(--accent);
|
||||
color: var(--accent-text);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.action:disabled { cursor: default; }
|
||||
.action.done { background: var(--ok-soft); color: var(--ok); }
|
||||
.action.pending { background: var(--accent-soft); color: var(--text); }
|
||||
|
||||
.progress {
|
||||
grid-column: 1 / -1;
|
||||
height: 6px;
|
||||
border-radius: 999px;
|
||||
background: var(--line);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.progress span {
|
||||
display: block;
|
||||
height: 100%;
|
||||
background: var(--accent);
|
||||
transition: width .4s;
|
||||
}
|
||||
|
||||
.state { font-size: .8rem; font-weight: 600; }
|
||||
.state.done { color: var(--ok); }
|
||||
.state.failed { color: var(--err); }
|
||||
.message { grid-column: 1 / -1; color: var(--err); font-size: .85rem; overflow-wrap: anywhere; }
|
||||
|
||||
.compact .item { grid-template-columns: 1fr; padding: 10px 14px; }
|
||||
|
||||
.tabs {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
z-index: 5;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
height: calc(var(--nav-h) + env(safe-area-inset-bottom));
|
||||
padding-bottom: env(safe-area-inset-bottom);
|
||||
background: var(--card);
|
||||
border-top: 1px solid var(--line);
|
||||
}
|
||||
|
||||
.tabs button {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 2px;
|
||||
border: 0;
|
||||
background: none;
|
||||
color: var(--muted);
|
||||
font-size: .78rem;
|
||||
}
|
||||
|
||||
.tabs button.active { color: var(--accent); font-weight: 600; }
|
||||
|
||||
.tabs svg {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
fill: none;
|
||||
stroke: currentColor;
|
||||
stroke-width: 2;
|
||||
stroke-linecap: round;
|
||||
stroke-linejoin: round;
|
||||
}
|
||||
|
||||
.badge {
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
left: calc(50% + 6px);
|
||||
min-width: 18px;
|
||||
height: 18px;
|
||||
padding: 0 5px;
|
||||
border-radius: 999px;
|
||||
background: var(--accent);
|
||||
color: var(--accent-text);
|
||||
font-size: .7rem;
|
||||
line-height: 18px;
|
||||
}
|
||||
|
||||
dialog {
|
||||
width: min(92vw, 400px);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius);
|
||||
background: var(--card);
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
dialog h2 { margin: 0 0 4px; font-size: 1.1rem; }
|
||||
dialog menu { display: flex; justify-content: flex-end; margin: 12px 0 0; padding: 0; }
|
||||
dialog::backdrop { background: rgb(0 0 0 / .4); }
|
||||
|
||||
@media (min-width: 720px) {
|
||||
.tabs {
|
||||
left: 50%;
|
||||
right: auto;
|
||||
width: 720px;
|
||||
transform: translateX(-50%);
|
||||
border: 1px solid var(--line);
|
||||
border-bottom: 0;
|
||||
border-radius: var(--radius) var(--radius) 0 0;
|
||||
}
|
||||
|
||||
.tabs button { flex-direction: row; gap: 8px; font-size: .95rem; }
|
||||
.badge { position: static; }
|
||||
.top { max-width: 752px; margin: 0 auto; }
|
||||
}
|
||||
@@ -0,0 +1,309 @@
|
||||
"use strict";
|
||||
// Web UI of the Vocaluxe song server: search sources, queue downloads, browse the library.
|
||||
// Plain JavaScript, no build step. API: /api/v1 (see README.md).
|
||||
|
||||
const $ = (sel) => document.querySelector(sel);
|
||||
const state = {
|
||||
tab: "search",
|
||||
library: null, // LibraryDto
|
||||
libraryVersion: "",
|
||||
jobs: [], // DownloadJobDto[]
|
||||
results: [],
|
||||
searchSeq: 0,
|
||||
};
|
||||
|
||||
function storageGet(key) {
|
||||
try { return localStorage.getItem(key) || ""; } catch { return ""; }
|
||||
}
|
||||
|
||||
function storageSet(key, value) {
|
||||
try { localStorage.setItem(key, value); } catch { /* private mode */ }
|
||||
}
|
||||
|
||||
// ---- API ------------------------------------------------------------------
|
||||
|
||||
async function api(path, options = {}) {
|
||||
const headers = { ...(options.headers || {}) };
|
||||
const key = storageGet("apiKey");
|
||||
if (key) headers["X-Api-Key"] = key;
|
||||
if (options.body) headers["Content-Type"] = "application/json";
|
||||
const response = await fetch("api/v1/" + path, { ...options, headers });
|
||||
if (response.status === 401) {
|
||||
await askForKey();
|
||||
return api(path, options);
|
||||
}
|
||||
if (!response.ok) {
|
||||
let title = response.statusText;
|
||||
try { title = (await response.json()).title || title; } catch { /* not JSON */ }
|
||||
throw new Error(title);
|
||||
}
|
||||
return response.status === 204 ? null : response.json();
|
||||
}
|
||||
|
||||
function askForKey() {
|
||||
return new Promise((resolve) => {
|
||||
const dialog = $("#keyDialog");
|
||||
dialog.addEventListener("close", () => {
|
||||
storageSet("apiKey", $("#keyInput").value.trim());
|
||||
resolve();
|
||||
}, { once: true });
|
||||
dialog.showModal();
|
||||
});
|
||||
}
|
||||
|
||||
// ---- Rendering helpers ----------------------------------------------------
|
||||
|
||||
function el(tag, attrs = {}, ...children) {
|
||||
const node = document.createElement(tag);
|
||||
for (const [k, v] of Object.entries(attrs)) {
|
||||
if (k === "class") node.className = v;
|
||||
else if (k.startsWith("on")) node.addEventListener(k.slice(2), v);
|
||||
else if (v !== false && v != null) node.setAttribute(k, v === true ? "" : v);
|
||||
}
|
||||
for (const child of children.flat()) {
|
||||
if (child != null && child !== false) node.append(child);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
function cover(url, title) {
|
||||
const fallback = el("div", { class: "cover", "aria-hidden": "true" }, (title || "?").trim().charAt(0).toUpperCase());
|
||||
if (!url) return fallback;
|
||||
const img = el("img", { class: "cover", src: url, alt: "", loading: "lazy", referrerpolicy: "no-referrer" });
|
||||
img.addEventListener("error", () => img.replaceWith(fallback), { once: true });
|
||||
return img;
|
||||
}
|
||||
|
||||
function songKey(artist, title) {
|
||||
const norm = (s) => (s || "").normalize("NFD").replace(/[̀-ͯ]/g, "").toLowerCase().replace(/[^\p{L}\p{N}]+/gu, " ").trim();
|
||||
return norm(artist) + "|" + norm(title);
|
||||
}
|
||||
|
||||
// ---- Tabs -----------------------------------------------------------------
|
||||
|
||||
function showTab(tab) {
|
||||
state.tab = tab;
|
||||
document.querySelectorAll(".tab").forEach((t) => t.classList.toggle("active", t.id === "tab-" + tab));
|
||||
document.querySelectorAll(".tabs button").forEach((b) => b.classList.toggle("active", b.dataset.tab === tab));
|
||||
storageSet("tab", tab);
|
||||
if (tab === "library") loadLibrary();
|
||||
if (tab === "downloads") renderJobs();
|
||||
if (tab === "search") $("#query").focus({ preventScroll: true });
|
||||
}
|
||||
|
||||
document.querySelectorAll(".tabs button").forEach((b) => b.addEventListener("click", () => showTab(b.dataset.tab)));
|
||||
|
||||
// ---- Sources --------------------------------------------------------------
|
||||
|
||||
async function loadSources() {
|
||||
try {
|
||||
const sources = await api("sources");
|
||||
$("#sources").replaceChildren(...sources.map((s) =>
|
||||
el("span", { class: "chip" + (s.enabled && !s.hint ? "" : " off"), title: s.hint || s.description },
|
||||
el("span", { class: "dot" }), s.name, s.hint && s.enabled ? " (limited)" : "", !s.enabled ? " (off)" : "")));
|
||||
} catch (e) {
|
||||
$("#sources").replaceChildren();
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Search ---------------------------------------------------------------
|
||||
|
||||
let searchTimer = 0;
|
||||
|
||||
$("#query").addEventListener("input", () => {
|
||||
clearTimeout(searchTimer);
|
||||
searchTimer = setTimeout(search, 450);
|
||||
});
|
||||
|
||||
$("#searchForm").addEventListener("submit", (e) => {
|
||||
e.preventDefault();
|
||||
clearTimeout(searchTimer);
|
||||
$("#query").blur(); // hide the keyboard on phones
|
||||
search();
|
||||
});
|
||||
|
||||
async function search() {
|
||||
const q = $("#query").value.trim();
|
||||
const seq = ++state.searchSeq;
|
||||
const status = $("#searchStatus");
|
||||
status.className = "status";
|
||||
if (q.length < 2) {
|
||||
state.results = [];
|
||||
status.textContent = "Type at least two letters. All song sources are searched at once.";
|
||||
renderResults();
|
||||
return;
|
||||
}
|
||||
|
||||
status.textContent = "Searching…";
|
||||
try {
|
||||
const response = await api("search?q=" + encodeURIComponent(q));
|
||||
if (seq !== state.searchSeq) return; // a newer search is running
|
||||
state.results = response.results;
|
||||
const errors = Object.entries(response.errors || {}).map(([source, msg]) => `${source}: ${msg}`);
|
||||
status.textContent = (response.results.length ? `${response.results.length} songs found` : "Nothing found") +
|
||||
(errors.length ? ` · not searched: ${errors.join("; ")}` : "");
|
||||
status.classList.toggle("error", errors.length > 0 && response.results.length === 0);
|
||||
renderResults();
|
||||
} catch (e) {
|
||||
if (seq !== state.searchSeq) return;
|
||||
status.textContent = "Search failed: " + e.message;
|
||||
status.classList.add("error");
|
||||
}
|
||||
}
|
||||
|
||||
function jobFor(result) {
|
||||
return state.jobs.find((j) => j.source === result.source && j.sourceId === result.sourceId);
|
||||
}
|
||||
|
||||
function resultButton(result) {
|
||||
const job = jobFor(result);
|
||||
if (result.inLibrary || (job && job.state === "done")) {
|
||||
return el("button", { class: "action done", disabled: true, "aria-label": "In the library" }, "✓");
|
||||
}
|
||||
if (job && (job.state === "queued" || job.state === "running")) {
|
||||
return el("button", { class: "action pending", disabled: true }, Math.round(job.progress * 100) + "%");
|
||||
}
|
||||
return el("button", {
|
||||
class: "action",
|
||||
"aria-label": `Download ${result.artist} – ${result.title}`,
|
||||
onclick: (e) => download(result, e.currentTarget),
|
||||
}, job && job.state === "failed" ? "Retry" : "Get");
|
||||
}
|
||||
|
||||
function renderResults() {
|
||||
$("#results").replaceChildren(...state.results.map((r) =>
|
||||
el("li", { class: "item", "data-key": r.source + "/" + r.sourceId },
|
||||
cover(r.coverUrl, r.title),
|
||||
el("div", { class: "text" },
|
||||
el("div", { class: "title" }, r.title),
|
||||
el("div", { class: "artist" }, r.artist),
|
||||
el("div", { class: "details" }, el("span", { class: "source" }, r.source), r.details)),
|
||||
resultButton(r))));
|
||||
}
|
||||
|
||||
async function download(result, button) {
|
||||
button.disabled = true;
|
||||
button.textContent = "…";
|
||||
try {
|
||||
const job = await api("downloads", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ source: result.source, sourceId: result.sourceId, artist: result.artist, title: result.title }),
|
||||
});
|
||||
state.jobs = [job, ...state.jobs.filter((j) => j.id !== job.id)];
|
||||
renderResults();
|
||||
renderBadge();
|
||||
pollJobs(true);
|
||||
} catch (e) {
|
||||
button.disabled = false;
|
||||
button.textContent = "Get";
|
||||
alert("Download failed: " + e.message);
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Downloads ------------------------------------------------------------
|
||||
|
||||
let pollTimer = 0;
|
||||
|
||||
async function pollJobs(soon) {
|
||||
clearTimeout(pollTimer);
|
||||
if (soon) {
|
||||
pollTimer = setTimeout(() => pollJobs(false), 800);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const before = state.jobs.filter((j) => j.state === "done").length;
|
||||
state.jobs = await api("downloads");
|
||||
renderJobs();
|
||||
renderBadge();
|
||||
if (state.results.length) renderResults();
|
||||
if (state.jobs.filter((j) => j.state === "done").length !== before) {
|
||||
state.libraryVersion = ""; // a song was added: reload the library when it's shown
|
||||
setTimeout(loadLibraryCount, 3000);
|
||||
}
|
||||
} catch { /* try again later */ }
|
||||
const active = state.jobs.some((j) => j.state === "queued" || j.state === "running");
|
||||
pollTimer = setTimeout(() => pollJobs(false), active ? 1500 : 10000);
|
||||
}
|
||||
|
||||
function renderBadge() {
|
||||
const active = state.jobs.filter((j) => j.state === "queued" || j.state === "running").length;
|
||||
const badge = $("#activeBadge");
|
||||
badge.hidden = active === 0;
|
||||
badge.textContent = active;
|
||||
}
|
||||
|
||||
const stateText = { queued: "Waiting", running: "Downloading", done: "Done", failed: "Failed" };
|
||||
|
||||
function renderJobs() {
|
||||
$("#downloadsEmpty").hidden = state.jobs.length > 0;
|
||||
$("#downloads").replaceChildren(...state.jobs.map((j) =>
|
||||
el("li", { class: "item" },
|
||||
cover("", j.title),
|
||||
el("div", { class: "text" },
|
||||
el("div", { class: "title" }, j.title),
|
||||
el("div", { class: "artist" }, j.artist),
|
||||
el("div", { class: "details" }, el("span", { class: "source" }, j.source),
|
||||
j.message && j.state === "done" ? j.message : "")),
|
||||
el("span", { class: "state " + j.state }, stateText[j.state] || j.state),
|
||||
j.state === "running" || j.state === "queued"
|
||||
? el("div", { class: "progress", role: "progressbar", "aria-valuenow": Math.round(j.progress * 100), "aria-valuemin": 0, "aria-valuemax": 100 },
|
||||
el("span", { style: `width:${Math.round(j.progress * 100)}%` }))
|
||||
: null,
|
||||
j.state === "failed" ? el("div", { class: "message" }, j.message) : null)));
|
||||
}
|
||||
|
||||
// ---- Library --------------------------------------------------------------
|
||||
|
||||
async function loadLibraryCount() {
|
||||
try {
|
||||
const health = await fetch("health").then((r) => r.json());
|
||||
if (health.songs != null) $("#libraryCount").textContent = health.songs + " songs";
|
||||
} catch { /* offline */ }
|
||||
}
|
||||
|
||||
async function loadLibrary() {
|
||||
const status = $("#libraryStatus");
|
||||
if (state.library && state.libraryVersion) {
|
||||
renderLibrary();
|
||||
return;
|
||||
}
|
||||
status.textContent = "Loading…";
|
||||
try {
|
||||
state.library = await api("library");
|
||||
state.libraryVersion = state.library.version;
|
||||
$("#libraryCount").textContent = state.library.songs.length + " songs";
|
||||
renderLibrary();
|
||||
} catch (e) {
|
||||
status.textContent = "Library not available: " + e.message;
|
||||
}
|
||||
}
|
||||
|
||||
$("#libraryFilter").addEventListener("input", () => renderLibrary());
|
||||
|
||||
function renderLibrary() {
|
||||
if (!state.library) return;
|
||||
const words = songKey($("#libraryFilter").value, "").replace("|", "").split(" ").filter(Boolean);
|
||||
const songs = state.library.songs
|
||||
.filter((s) => { const k = songKey(s.artist, s.title).replace("|", " "); return words.every((w) => k.includes(w)); })
|
||||
.sort((a, b) => a.artist.localeCompare(b.artist) || a.title.localeCompare(b.title));
|
||||
const shown = songs.slice(0, 300);
|
||||
$("#libraryStatus").textContent = songs.length === 0
|
||||
? (state.library.songs.length ? "No matching songs." : "The library is empty. Download songs under Search.")
|
||||
: songs.length > shown.length ? `${songs.length} songs, showing the first ${shown.length}. Filter to narrow down.` : `${songs.length} songs`;
|
||||
$("#library").replaceChildren(...shown.map((s) =>
|
||||
el("li", { class: "item" },
|
||||
el("div", { class: "text" }, el("div", { class: "title" }, s.title), el("div", { class: "artist" }, s.artist)))));
|
||||
}
|
||||
|
||||
// ---- Start ----------------------------------------------------------------
|
||||
|
||||
// A link like "?q=queen" opens a search, "?tab=library" a tab.
|
||||
const params = new URLSearchParams(location.search);
|
||||
if (params.get("q")) $("#query").value = params.get("q");
|
||||
const startTab = params.get("q") ? "search" : params.get("tab") || storageGet("tab");
|
||||
|
||||
loadSources();
|
||||
loadLibraryCount();
|
||||
pollJobs(false);
|
||||
search();
|
||||
showTab(["search", "downloads", "library"].includes(startTab) ? startTab : "search");
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><rect width="64" height="64" rx="14" fill="#7c3aed"/><g fill="none" stroke="#fff" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"><rect x="24" y="10" width="16" height="26" rx="8"/><path d="M17 30a15 15 0 0 0 30 0M32 45v9M24 54h16"/></g></svg>
|
||||
|
After Width: | Height: | Size: 320 B |
@@ -0,0 +1,69 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
||||
<meta name="theme-color" content="#7c3aed">
|
||||
<title>Karaoke Songs</title>
|
||||
<link rel="manifest" href="manifest.webmanifest">
|
||||
<link rel="icon" href="icon.svg" type="image/svg+xml">
|
||||
<link rel="apple-touch-icon" href="icon.svg">
|
||||
<link rel="stylesheet" href="app.css">
|
||||
</head>
|
||||
<body>
|
||||
<header class="top">
|
||||
<h1><img src="icon.svg" alt="" width="28" height="28"> Karaoke Songs</h1>
|
||||
<span id="libraryCount" class="muted"></span>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<section id="tab-search" class="tab active" aria-label="Search">
|
||||
<form id="searchForm" class="searchbar" role="search">
|
||||
<input id="query" type="search" placeholder="Artist or title" autocomplete="off" enterkeyhint="search" aria-label="Search songs">
|
||||
</form>
|
||||
<div id="sources" class="chips"></div>
|
||||
<div id="searchStatus" class="status"></div>
|
||||
<ul id="results" class="list"></ul>
|
||||
</section>
|
||||
|
||||
<section id="tab-downloads" class="tab" aria-label="Downloads">
|
||||
<div id="downloadsEmpty" class="status">No downloads yet. Find songs under Search.</div>
|
||||
<ul id="downloads" class="list"></ul>
|
||||
</section>
|
||||
|
||||
<section id="tab-library" class="tab" aria-label="Library">
|
||||
<form class="searchbar" onsubmit="return false">
|
||||
<input id="libraryFilter" type="search" placeholder="Filter the library" autocomplete="off" aria-label="Filter the library">
|
||||
</form>
|
||||
<div id="libraryStatus" class="status"></div>
|
||||
<ul id="library" class="list compact"></ul>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<nav class="tabs" aria-label="Sections">
|
||||
<button data-tab="search" class="active">
|
||||
<svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-4-4"/></svg>
|
||||
Search
|
||||
</button>
|
||||
<button data-tab="downloads">
|
||||
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 4v11m0 0-4-4m4 4 4-4M5 20h14"/></svg>
|
||||
Downloads <span id="activeBadge" class="badge" hidden></span>
|
||||
</button>
|
||||
<button data-tab="library">
|
||||
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M9 18V6l11-2v12"/><circle cx="6" cy="18" r="3"/><circle cx="17" cy="16" r="3"/></svg>
|
||||
Library
|
||||
</button>
|
||||
</nav>
|
||||
|
||||
<dialog id="keyDialog">
|
||||
<form method="dialog">
|
||||
<h2>Access key</h2>
|
||||
<p class="muted">This song server needs an access key.</p>
|
||||
<input id="keyInput" type="password" autocomplete="current-password" aria-label="Access key">
|
||||
<menu><button value="ok" class="primary">Save</button></menu>
|
||||
</form>
|
||||
</dialog>
|
||||
|
||||
<script src="app.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "Karaoke Songs",
|
||||
"short_name": "Karaoke",
|
||||
"start_url": "./",
|
||||
"display": "standalone",
|
||||
"background_color": "#12101c",
|
||||
"theme_color": "#7c3aed",
|
||||
"icons": [{ "src": "icon.svg", "sizes": "any", "type": "image/svg+xml", "purpose": "any" }]
|
||||
}
|
||||
Reference in new issue
Block a user