Web: drop sidebar playlist list, pin side art, trim help text, redo mixer action buttons
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f624a9866a
commit
84f351021f
4 files changed
+37
-68
No files matched your search
+20
-54
@@ -249,20 +249,16 @@ function presetsHtml(names) {
|
||||
title="Tap again for Full Mix. Long press to ${lock?.id === p.id ? "unlock" : "lock"}.">${lock?.id === p.id ? ICON.lock : ""}${esc(presetLabel(p.name))}</button>`).join("") + `<button class="chip" data-newpreset title="Save this mix as a preset">+</button>`;
|
||||
}
|
||||
function mixFoot(names) {
|
||||
const saved = songMixes[E.entry.key];
|
||||
const lock = S.lockedPreset && allPresets().find(p => p.id === S.lockedPreset);
|
||||
const savedNote = saved ? (sameMix(saved, S.mix, names) ? "Using this song's saved mix." : "Changed from this song's saved mix.") : "";
|
||||
return `<div class="row mixrow">
|
||||
<button class="btn small" data-savemix>${saved ? "Update saved mix" : "Save mix for this song"}</button>
|
||||
${saved ? `<button class="btn small" data-forgetmix>Forget</button>` : ""}
|
||||
<button class="btn small" data-mixtopl>Add to stem playlist…</button>
|
||||
</div>
|
||||
<p class="note">${savedNote} ${S.karaoke ? "Karaoke is on, so saved mixes are ignored until you turn it off." : lock ? `${esc(presetLabel(lock.name))} is locked, so every song starts with it. Long press it to unlock.`
|
||||
: (S.keepMix ? "Songs without a saved mix keep this mix." : "Songs without a saved mix start at full mix.") + " Long press a preset to lock it."}</p>`;
|
||||
const saved = songMixes[E.entry.key], same = saved && sameMix(saved, S.mix, names);
|
||||
return `<div class="mixacts">
|
||||
<button class="mact ${same ? "on" : ""}" data-savemix>${same ? ICON.check : ICON.save}<span>${same ? "Mix saved" : saved ? "Update mix" : "Save mix"}</span></button>
|
||||
<button class="mact" data-mixtopl>${ICON.pladd}<span>Add to playlist</span></button>
|
||||
${saved ? `<button class="mact ic" data-forgetmix title="Forget this song's saved mix">${ICON.x}</button>` : ""}
|
||||
</div>`;
|
||||
}
|
||||
function mixerHtml() {
|
||||
const names = mixNames();
|
||||
if (!names.length) return `<p class="note">${E.loading ? "Loading stems…" : Q.cur() ? "This track has no stems yet. Right-click it and pick Stem Now." : "Play something with stems to mix it."}</p>`;
|
||||
if (!names.length) return `<p class="note">${E.loading ? "Loading stems…" : Q.cur() ? "No stems for this track." : "Nothing playing."}</p>`;
|
||||
return `<div id="mixer" data-names="${esc(names.join(","))}">
|
||||
<div class="presets">${presetsHtml(names)}</div>
|
||||
<div class="strips">${names.map(n => {
|
||||
@@ -829,7 +825,7 @@ const stationsHtml = () => S.stations.length ? `<div class="stationlist">${S.sta
|
||||
return `<div class="stn ${on ? "on" : ""}"><button class="btn icon ${playing ? "primary" : ""}" data-radio="${esc(st.id)}" title="${playing ? "Stop" : "Play"}">${playing ? ICON.pause : ICON.play}</button>
|
||||
<div class="tx"><b>${esc(st.name)}</b><span class="note">${esc(st.url)}</span></div>
|
||||
<button class="btn small" data-rdrename="${esc(st.id)}">Rename</button><button class="btn small" data-rddelete="${esc(st.id)}">Delete</button></div>`;
|
||||
}).join("")}</div>` : `<p class="empty-msg">No stations yet. Add one with its stream URL.</p>`;
|
||||
}).join("")}</div>` : `<p class="empty-msg">No stations yet.</p>`;
|
||||
|
||||
const routes = {
|
||||
async home(my) {
|
||||
@@ -862,8 +858,7 @@ const routes = {
|
||||
<h2>Add a station</h2><div class="form">
|
||||
<label>Name<input type="text" id="rname" placeholder="KEXP"></label>
|
||||
<label>Stream URL<input type="url" id="rurl" placeholder="https://example.com/stream.mp3"></label>
|
||||
<div class="row"><button class="btn primary" data-rdadd>Add station</button></div>
|
||||
<p class="note">Any stream the browser can play, like MP3, AAC or Ogg. Playing a station pauses the queue, and playing the queue stops the station.</p></div>`;
|
||||
<div class="row"><button class="btn primary" data-rdadd>Add station</button></div></div>`;
|
||||
},
|
||||
async albums(my) {
|
||||
const srcs = sources();
|
||||
@@ -881,7 +876,7 @@ const routes = {
|
||||
const srcs = sources();
|
||||
if (!srcs.length) return needPlex();
|
||||
view.innerHTML = bar("Songs", { sort: "songs", extra: `<button class="chip" data-shuffleall>${ICON.shuffle} Shuffle all</button>` })
|
||||
+ `<table class="tracks">${thead()}<tbody></tbody></table><p class="empty-msg only-stems">No songs with stems loaded yet. Scroll for more.</p><p class="empty-msg only-nostems">Every song loaded so far has stems. Scroll for more.</p>`;
|
||||
+ `<table class="tracks">${thead()}<tbody></tbody></table><p class="empty-msg only-stems">No songs with stems yet.</p><p class="empty-msg only-nostems">Every song has stems.</p>`;
|
||||
lists.songs = [];
|
||||
const size = S.stemFilter ? 1000 : 150;
|
||||
await paged(my, $("tbody", view), new Pager(srcs, secPath, { type: 10, sort: sortState("songs").param }, size), size, (ms, off) => {
|
||||
@@ -913,14 +908,14 @@ const routes = {
|
||||
view.innerHTML = bar("Playlists", { sort: "playlists", filter: false })
|
||||
+ `<div class="bar sm"><h2>Stem playlists</h2><button class="chip" data-newpl>+ New</button></div>`
|
||||
+ (playlists.length ? `<div class="grid">${playlists.map(p => card({ href: `#/stemplaylist/${p.id}`, img: artOf(p.items[0]?.track, 300), t: p.title, s: plural(p.items.length, "track") })).join("")}</div>`
|
||||
: `<p class="note">Stem playlists remember a mix for each song. Right-click any song to add it.</p>`)
|
||||
: `<p class="empty-msg">No stem playlists.</p>`)
|
||||
+ `<h2>Plex playlists</h2><div id="plexpl"><p class="note">${liveServers().length ? "Loading…" : "No Plex server set up."}</p></div>`;
|
||||
if (!liveServers().length) return;
|
||||
let pls = await everything(liveServers().map(srv => ({ srv })), "/playlists", { playlistType: "audio" });
|
||||
if (my !== seq) return;
|
||||
pls = st.random ? pls.sort(() => Math.random() - 0.5) : pls.sort(comparator(st.param));
|
||||
count(pls.length + playlists.length, "playlist");
|
||||
navPls = [...pls].sort((a, b) => (a.title || "").localeCompare(b.title || "")); navState = "ok"; navPlaylists();
|
||||
|
||||
$("#plexpl").innerHTML = pls.length ? `<div class="grid">${pls.map(p => card({ href: `#/playlist/${p._srv}:${p.ratingKey}`, img: img(p._srv, p.thumb || p.composite), fb: p.composite && rawImg(p._srv, p.composite), t: p.title, s: plural(p.leafCount || 0, "track"), kind: "playlist", srv: p._srv, key: p.ratingKey })).join("")}</div>`
|
||||
: `<p class="empty-msg">No music playlists.</p>`;
|
||||
},
|
||||
@@ -986,7 +981,7 @@ const routes = {
|
||||
view.innerHTML = bar("Downloads", { filter: false, extra: recs.length ? `<button class="chip" data-dlclear>Remove all</button>` : "" })
|
||||
+ `<p class="note">${plural(recs.length, "track")}, ${fmtBytes(total)} stored in this browser${est?.quota ? ` (${fmtBytes(est.usage)} of ${fmtBytes(est.quota)} used)` : ""}.
|
||||
Downloads play without the network. ${isSecureContext ? "" : "This page isn't on HTTPS, so the browser may clear them when space runs low."}</p>`
|
||||
+ (recs.length ? dlGroups(recs) : `<p class="empty-msg">Nothing downloaded. Right-click a song or album and pick Download for offline.</p>`);
|
||||
+ (recs.length ? dlGroups(recs) : `<p class="empty-msg">Nothing downloaded.</p>`);
|
||||
count(recs.length, "track");
|
||||
},
|
||||
async stems(my) {
|
||||
@@ -998,7 +993,7 @@ const routes = {
|
||||
const f = $("#sf").value.toLowerCase();
|
||||
const hits = f ? all.filter(t => t.stem.key.toLowerCase().includes(f)) : all;
|
||||
$("#sl").innerHTML = (hits.length ? trackTable("stems", hits.slice(0, 400)) : `<p class="empty-msg">${Stems.ok ? "No matches." : "Can't reach stemserve. Check Settings."}</p>`)
|
||||
+ (hits.length > 400 ? `<p class="note">Showing 400 of ${hits.length}. Filter to narrow it down.</p>` : "");
|
||||
+ (hits.length > 400 ? `<p class="note">400 of ${hits.length}</p>` : "");
|
||||
};
|
||||
$("#sf").oninput = render;
|
||||
render();
|
||||
@@ -1006,33 +1001,11 @@ const routes = {
|
||||
settings: renderSettings,
|
||||
};
|
||||
|
||||
// Sidebar playlist list: stem playlists, then Plex ones (fetched at start and on the Playlists page).
|
||||
let navPls = [], navHtml = "";
|
||||
let navState = "loading";
|
||||
const STEMDOT = '<svg viewBox="0 0 24 24"><path d="M5 10h2v10H5zm4-6h2v16H9zm4 8h2v8h-2zm4-4h2v12h-2z"/></svg>';
|
||||
function navPlaylists() {
|
||||
const box = $("#nav-pl"), html = playlists.map(p => `<a href="#/stemplaylist/${p.id}" title="${esc(p.title)} · stem playlist"><span>${esc(p.title)}</span>${STEMDOT}</a>`).join("")
|
||||
+ navPls.map(p => `<a href="#/playlist/${p._srv}:${p.ratingKey}" title="${esc(p.title)}"><span>${esc(p.title)}</span></a>`).join("")
|
||||
|| `<p class="nav-empty">${navState === "loading" ? "Loading…" : navState === "none" ? "No Plex server set up." : "No playlists yet."}</p>`;
|
||||
if (html !== navHtml) { navHtml = html; box.innerHTML = html; }
|
||||
for (const a of box.children) a.classList.toggle("on", a.getAttribute("href") === location.hash);
|
||||
}
|
||||
async function loadNavPlaylists() {
|
||||
await connecting;
|
||||
if (!liveServers().length) navState = "none";
|
||||
else {
|
||||
try { navPls = (await everything(liveServers().map(srv => ({ srv })), "/playlists", { playlistType: "audio" })).sort((a, b) => (a.title || "").localeCompare(b.title || "")); } catch {}
|
||||
navState = "ok";
|
||||
}
|
||||
navPlaylists();
|
||||
}
|
||||
|
||||
async function route() {
|
||||
const my = ++seq;
|
||||
const [, name = "home", ...rest] = (location.hash || "#/home").split("/");
|
||||
const arg = decodeURIComponent(rest.join("/"));
|
||||
$$("#nav a").forEach(a => a.classList.toggle("on", a.dataset.nav === name || (a.dataset.nav === "genres" && name === "genre") || (a.dataset.nav === "playlists" && /playlist$/.test(name))));
|
||||
navPlaylists();
|
||||
lists = {}; listItems = {}; kick = null;
|
||||
delete view.dataset.genre;
|
||||
view.scrollTop = 0;
|
||||
@@ -1136,7 +1109,6 @@ function presetEditor() {
|
||||
const ps = presets(), lock = S.lockedPreset && allPresets().find(p => p.id === S.lockedPreset);
|
||||
return `<h3>Locked</h3>
|
||||
${lock ? `<div class="prow"><span class="pn">${ICON.lock}${esc(presetLabel(lock.name))}</span><span class="grow"></span><button class="btn small" data-plock="${esc(lock.id)}">Unlock</button></div>` : `<p class="note">Nothing locked.</p>`}
|
||||
<p class="note">Every song starts with this mix, whether or not Keep Stem Mix Between Songs is on. Long press a preset in the mixer to lock or unlock it.</p>
|
||||
<h3>Mixer Bar</h3><div class="plist">${ps.map((p, i) => `<div class="prow"><span class="pn">${esc(presetLabel(p.name))}${p.custom ? ' <span class="tag">CUSTOM</span>' : ""}</span><span class="grow"></span>
|
||||
<button class="btn small ${lock?.id === p.id ? "on" : ""}" data-plock="${esc(p.id)}" title="${lock?.id === p.id ? "Unlock" : "Lock"}">${ICON.lock}</button>
|
||||
<button class="btn small" data-pmove="${esc(p.id)}" data-pdir="-1" ${i ? "" : "disabled"} title="Move up">↑</button>
|
||||
@@ -1165,7 +1137,6 @@ function renderSettings() {
|
||||
const theme = THEMES[S.theme] || THEMES.graphite;
|
||||
view.innerHTML = `<div class="settings"><nav class="toc">${SECTIONS.map(([id, l]) => `<a href="#/settings" data-jump="${id}">${l}</a>`).join("")}</nav><div class="panes">
|
||||
<section id="set-plex"><h2>Plex</h2>
|
||||
<p class="note">Turn on the music libraries you want. Everything that's on is browsed as one library.</p>
|
||||
<div id="srvs">${S.servers.map(serverHtml).join("") || `<p class="note">No servers yet.</p>`}</div>
|
||||
<div class="row"><button class="btn primary" id="signin">Sign in with Plex</button><span class="note" id="sstatus"></span></div>
|
||||
<details><summary class="note">Add a server by URL and token</summary><div class="form">
|
||||
@@ -1181,19 +1152,15 @@ function renderSettings() {
|
||||
</section>
|
||||
<section id="set-stemopts"><h2>Stems</h2><div class="form">
|
||||
<label>Stem format<select id="fmt">${FORMATS.map(([v, l]) => `<option value="${v}" ${S.fmt === v ? "selected" : ""}>${l}</option>`).join("")}</select></label>
|
||||
<p class="note">Stems are downloaded whole before a song starts. Opus 160 is about 1 MB per stem-minute; FLAC is around eight times that.</p>
|
||||
<label>Cache Ahead<div class="row"><input type="range" id="precache" min="0" max="50" step="1" value="${S.precache}"><input type="number" id="precachen" min="0" max="50" value="${S.precache}"> songs</div></label>
|
||||
<p class="note">How many upcoming songs load their stems in the background. Each one is held in memory, so keep it low on phones. FLAC loads one at most.</p>
|
||||
<label class="check"><input type="checkbox" id="keepmix" ${S.keepMix ? "checked" : ""}>Keep Stem Mix Between Songs</label>
|
||||
<p class="note">Songs without a saved mix keep the current mix. When it's off they start at full mix, and karaoke turns off.</p>
|
||||
<div class="row"><span class="note">${plural(Object.keys(songMixes).length, "saved song mix")}</span>${Object.keys(songMixes).length ? `<button class="btn small" id="forgetall">Forget all</button>` : ""}</div></div>
|
||||
</section>
|
||||
<section id="set-presets"><h2>Stem Editor</h2><div id="pedit">${presetEditor()}</div></section>
|
||||
<section id="set-karaoke"><h2>Karaoke</h2><div class="form">
|
||||
<label class="check"><input type="checkbox" id="kon" ${S.karaoke ? "checked" : ""}>Karaoke on (K)</label>
|
||||
<label>Vocals in karaoke<select id="kmode">${[["off", "Off"], ["soft", "Soft"], ["on", "Left on (lyrics only)"]].map(([v, l]) => `<option value="${v}" ${S.karaokeMode === v ? "selected" : ""}>${l}</option>`).join("")}</select></label>
|
||||
<label>Soft vocal level: <span id="kdbv">${S.softDb} dB</span><input type="range" id="kdb" min="-30" max="-3" step="1" value="${S.softDb}"></label>
|
||||
<p class="note">Synced lyrics come from LRCLIB, shown in the Lyrics drawer (L).</p></div>
|
||||
<label>Soft vocal level: <span id="kdbv">${S.softDb} dB</span><input type="range" id="kdb" min="-30" max="-3" step="1" value="${S.softDb}"></label></div>
|
||||
</section>
|
||||
<section id="set-look"><h2>Appearance</h2><div class="form">
|
||||
<div class="themes">${Object.entries(THEMES).map(([k, t]) => `<button class="swatch ${S.theme === k ? "on" : ""}" data-theme="${k}" style="background:${t.bg};color:${t.text};border-color:${t.line}"><i style="background:${t.accent}"></i>${k[0].toUpperCase() + k.slice(1)}</button>`).join("")}</div>
|
||||
@@ -1201,14 +1168,14 @@ function renderSettings() {
|
||||
<label class="check"><input type="checkbox" id="acapella" ${S.acapella ? "checked" : ""}>Spell the vocals-only preset “Acapella”</label>
|
||||
<div class="row"><span class="note">Player bar</span>${BAR.map(([k, l]) => `<label class="check"><input type="checkbox" data-bar="${k}" ${S.bar[k] ? "checked" : ""}>${l}</label>`).join("")}</div>
|
||||
<label>Custom CSS<textarea id="css" rows="8" spellcheck="false" placeholder=":root { --accent: #7cf; --radius: 4px; }\n.card img { border-radius: 0; }">${esc(S.css)}</textarea></label>
|
||||
<p class="note">Applied live, after the theme. Variables: --bg --panel --raised --line --text --muted --accent --accent-ink --radius --wave --wave-ghost.</p></div>
|
||||
<p class="note">--bg --panel --raised --line --text --muted --accent --accent-ink --radius --wave --wave-ghost</p></div>
|
||||
</section>
|
||||
<section id="set-offline"><h2>Offline</h2>
|
||||
<p class="note" id="storage-info">${plural(Offline.ids.size, "track")} downloaded. <a class="link" href="#/downloads">Manage downloads</a></p>
|
||||
${isSecureContext && navigator.storage?.persist ? `<div class="row"><button class="btn small" id="persist">Ask the browser to keep downloads</button></div>` : `<p class="note">Over plain HTTP the browser may clear downloads when it's short on space.</p>`}
|
||||
${isSecureContext && navigator.storage?.persist ? `<div class="row"><button class="btn small" id="persist">Ask the browser to keep downloads</button></div>` : ""}
|
||||
</section>
|
||||
<section id="set-backup"><h2>Backup</h2>
|
||||
<p class="note">Settings, saved mixes and stem playlists. The file includes your Plex tokens.</p>
|
||||
<p class="note">Includes your Plex tokens.</p>
|
||||
<div class="row"><button class="btn" id="export">Export</button><label class="btn">Import<input type="file" id="import" accept="application/json" hidden></label></div>
|
||||
</section>
|
||||
<section id="set-keys"><h2>Keys</h2><p class="note">Space play/pause · ←/→ seek 5s (shift 30s) · S shuffle · R repeat · [ ] speed · M mixer · L lyrics · Q queue · K karaoke · P next preset · hold Next to skip the album · right-click a song or album for more</p></section>
|
||||
@@ -1237,7 +1204,7 @@ function renderSettings() {
|
||||
navigator.storage?.estimate?.().then(e => { const el = $("#storage-info"); if (el && e?.quota) el.insertAdjacentText("afterbegin", `${fmtBytes(e.usage)} of ${fmtBytes(e.quota)} used. `); }).catch(() => {});
|
||||
|
||||
const again = () => { if (location.hash.startsWith("#/settings")) renderSettings(); };
|
||||
const plexChanged = () => { genreCache = null; save(); loadNavPlaylists(); };
|
||||
const plexChanged = () => { genreCache = null; save(); };
|
||||
$("#signin").onclick = async () => {
|
||||
const st = $("#sstatus");
|
||||
try { const ok = await signIn(m => { st.textContent = m; }); plexChanged(); toast(`Added ${plural(ok.length, "server")}`); again(); }
|
||||
@@ -1346,7 +1313,6 @@ let connecting = null;
|
||||
Q.restore();
|
||||
UI.all();
|
||||
route();
|
||||
loadNavPlaylists();
|
||||
Live.poll();
|
||||
setInterval(() => { if (!document.hidden) { Stems.refresh(); loadNavPlaylists(); } }, 5 * 60 * 1000);
|
||||
setInterval(() => { if (!document.hidden) { Stems.refresh(); } }, 5 * 60 * 1000);
|
||||
})();
|
||||
Reference in new issue
Block a user