add to ui and add remove api

This commit is contained in:
2026-04-18 21:54:39 +02:00
parent bca9adc9aa
commit 260399c901
3 changed files with 26 additions and 4 deletions
+2 -4
View File
@@ -173,12 +173,10 @@ class Module(ActiveModifier):
self.skip_next = max(self.skip_next, 0)
return {"status": "ok", "data": self.skip_next}
elif data.get("action") == "skipi":
idx = data.get("target")
if not idx or not isinstance(idx, int): return {"status": "data", "data": list(self.skip_indexes)}
self.skip_indexes.add(idx)
if (add := data.get("add")) and isinstance(add, int): self.skip_indexes.add(add)
if (remove := data.get("remove")) is not None and isinstance(remove, int) and remove in self.skip_indexes: self.skip_indexes.remove(remove)
return {"status": "ok", "data": list(self.skip_indexes)}
activemod = Module()
# This is free and unencumbered software released into the public domain.
+1
View File
@@ -199,6 +199,7 @@
<button id="skpn-inc" class="btn" style="padding:4px 10px;border:none">+</button>
</div>
<button id="jingle-btn" class="btn">🕭 Jingle</button>
<button id="skipidx-btn" class="btn">⏭+ Skip in playlist</button>
</div>
</div>
+23
View File
@@ -257,6 +257,14 @@ document.getElementById("jingle-btn").addEventListener("contextmenu", (e) => {
});
document.getElementById("clear-btn").addEventListener("click", () => ws.send(JSON.stringify({action:"clear_toplay"})));
document.getElementById("skipidx-btn").addEventListener("click", () => {
if (selectedPlaylistIndex == null) return;
const action = skipped_idx.includes(selectedPlaylistIndex)
? { action: "skipi", remove: selectedPlaylistIndex }
: { action: "skipi", add: selectedPlaylistIndex };
ws.send(JSON.stringify(action));
});
function addSelectedFileToQueue(top) {
let fullPath = null;
let success = false;
@@ -284,6 +292,21 @@ document.getElementById("add-to-queue2-btn").addEventListener("click", () => add
function updateControls() {
document.getElementById("clear-btn").disabled = Queue.length === 0;
const btn = document.getElementById("skipidx-btn");
if (selectedPlaylistIndex == null) {
btn.textContent = "⏭+ Skip idx";
btn.disabled = true;
btn.classList.remove("activated");
} else if (skipped_idx.includes(selectedPlaylistIndex)) {
btn.textContent = "✓ Unskip idx";
btn.disabled = false;
btn.classList.add("activated");
} else {
btn.textContent = "⏭+ Skip idx";
btn.disabled = false;
btn.classList.remove("activated");
}
}
document.addEventListener("keydown", e => {