diff --git a/web/app.js b/web/app.js
index 1aaa621..734902a 100644
--- a/web/app.js
+++ b/web/app.js
@@ -519,7 +519,7 @@ $("#b-mixer").innerHTML = ICON.mixer;
$("#b-lyrics").innerHTML = ICON.lyrics;
$("#b-queue").innerHTML = ICON.queue;
$("#speed").innerHTML = SPEEDS.map(v => ``).join("");
-$("#volume").value = S.volume;
+$("#volume").value = S.volume; $("#volume").style.setProperty("--v", S.volume * 100 + "%");
const togglePlay = () => { if (Radio.station) return Radio.toggle(); if (!Q.cur()) return; E.playing ? E.pause() : E.play(); saveQueue(); };
$("#b-play").onclick = togglePlay;
@@ -539,7 +539,7 @@ $("#b-mixer").onclick = () => toggleDrawer("mixer");
$("#b-lyrics").onclick = () => toggleDrawer("lyrics");
$("#b-queue").onclick = () => toggleDrawer("queue");
$("#speed").onchange = ev => setSpeed(+ev.target.value);
-$("#volume").oninput = ev => { S.volume = +ev.target.value; E.applyGains(); save(); };
+$("#volume").oninput = ev => { S.volume = +ev.target.value; ev.target.style.setProperty("--v", S.volume * 100 + "%"); E.applyGains(); save(); };
function applyBar() {
$("#speed").style.display = S.bar.speed ? "" : "none";
for (const k of ["mixer", "lyrics", "queue"]) $(`#b-${k}`).style.display = S.bar[k] ? "" : "none";
@@ -823,15 +823,16 @@ function playFrom(listId, i) {
// A broken image tries its fallback (data-fb) once, then shows the placeholder.
const FB = `onerror="if(this.dataset.fb){this.src=this.dataset.fb;this.dataset.fb=''}else{this.onerror=null;this.src='data:image/gif;base64,R0lGODlhAQABAAAAACw='}"`;
-function card({ href, img: src, fb, t, s = "", round, kind, srv, key }) {
+function card({ href, img: src, fb, t, s = "", round, kind, srv, key, dl }) {
const nk = kind === "album" || kind === "artist" ? nameKey(t) : "";
const hide = nk && !stemSets()[kind].has(nk);
- return `
- ` : ``}${kind ? `` : ""}
` : ``}${kind || dl != null ? `` : ""}
${plural(recs.length, "track")}, ${fmtBytes(total)} stored in this browser${est?.quota ? ` (${fmtBytes(est.usage)} of ${fmtBytes(est.quota)} used)` : ""}. + + `
${plural(recs.length, "song")} · ${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."}
` - + (recs.length ? dlGroups(recs) : `Nothing downloaded.
`); + + (recs.length ? actions("dl:all") + dlGroups(recs) : `Nothing downloaded. Right-click any playlist, album or artist and choose Download for offline.
`); count(recs.length, "track"); }, async stems(my) { @@ -1217,11 +1226,7 @@ view.addEventListener("click", async ev => { S.stations = S.stations.filter(x => x.id !== ds.rddelete); save(); return route(); } - if (ds.dlgroup) { - const ts = lists["dl:" + ds.dlgroup] || []; - if (confirm(`Remove ${plural(ts.length, "download")}?`)) { for (const t of ts) await Offline.remove(t.id); emit("offline"); route(); } - return; - } + if (ds.dlgroup) return removeDl(ds.dlgroup, "these songs"); if ("shuffleall" in ds) { const ts = (await new Pager(sources(), secPath, { type: 10, sort: "random" }, 200).next(200)).map(m => track(m._srv, m)); return Q.playList(visible(ts), -1, true); @@ -1237,9 +1242,27 @@ view.addEventListener("click", async ev => { if (ds.pldelete) { if (confirm("Delete this stem playlist?")) { playlists.splice(playlists.findIndex(x => x.id === ds.pldelete), 1); savePlaylists(); location.hash = "#/playlists"; } return; } if ("dlclear" in ds) { if (confirm("Remove every download?")) { for (const id of [...Offline.ids]) await Offline.remove(id); emit("offline"); route(); } } }); +async function removeDl(n, what) { + const ts = lists["dl:" + n] || []; + if (!confirm(`Remove ${what} (${plural(ts.length, "download")})? They will no longer play offline.`)) return; + for (const t of ts) await Offline.remove(t.id); + emit("offline"); route(); +} +function dlMenu(x, y, n, title) { + const ts = () => lists["dl:" + n] || []; + Menu.open(x, y, [ + { label: "Play", run: () => Q.playList(ts(), 0, false) }, + { label: "Shuffle", run: () => Q.playList(ts(), -1, true) }, + { label: "Play next", run: () => Q.add(ts(), true) }, + { label: "Add to queue", run: () => Q.add(ts()) }, + "-", + { label: "Remove download", run: () => removeDl(n, `“${title}”`) }, + ]); +} view.addEventListener("contextmenu", ev => { - const row = ev.target.closest("tr[data-list]"), c = ev.target.closest(".card[data-kind]"); - if (row) { ev.preventDefault(); trackMenu(ev.clientX, ev.clientY, row.dataset.list, +row.dataset.i); } + const row = ev.target.closest("tr[data-list]"), c = ev.target.closest(".card[data-kind]"), d = ev.target.closest(".card[data-dl]"); + if (d) { ev.preventDefault(); dlMenu(ev.clientX, ev.clientY, d.dataset.dl, $(".t", d).textContent); } + else if (row) { ev.preventDefault(); trackMenu(ev.clientX, ev.clientY, row.dataset.list, +row.dataset.i); } else if (c) { ev.preventDefault(); listMenu(ev.clientX, ev.clientY, () => cardTracks(c), { title: $(".t", c).textContent, href: c.getAttribute("href") }); } }); diff --git a/web/style.css b/web/style.css index 25947bb..39151f7 100644 --- a/web/style.css +++ b/web/style.css @@ -504,8 +504,8 @@ input[type=number]#precachen { width: 64px; background: var(--raised); border: 1 .actions + .bar.sm > * { pointer-events: auto; } } #volume { -webkit-appearance: none; appearance: none; height: 16px; background: none; cursor: pointer; } -#volume::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: #3c3f43; } -#volume::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; margin-top: -4px; border-radius: 50%; background: #e7e7e7; border: 0; } -#volume::-moz-range-track { height: 4px; border-radius: 2px; background: #3c3f43; } -#volume::-moz-range-progress { height: 4px; border-radius: 2px; background: #cccccc; } -#volume::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: #e7e7e7; border: 0; } +#volume::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(90deg, var(--accent) var(--v, 85%), color-mix(in srgb, var(--text) 22%, transparent) var(--v, 85%)); } +#volume::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; margin-top: -4px; border-radius: 50%; background: var(--text); border: 0; } +#volume::-moz-range-track { height: 4px; border-radius: 2px; background: color-mix(in srgb, var(--text) 22%, transparent); } +#volume::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); } +#volume::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--text); border: 0; }