0
1
mirror of https://github.com/radio95-rnt/RadioPlayer.git synced 2026-02-26 21:53:54 +01:00
This commit is contained in:
2025-12-27 22:54:53 +01:00
parent 7c9bd167ef
commit b29ae118c7

View File

@@ -487,15 +487,14 @@
function addSelectedFileToQueue(top) { function addSelectedFileToQueue(top) {
let fullPath = null; let fullPath = null;
if(selectedPlaylistIndex != null) { let success = false;
if (selectedPlaylistIndex != null) {
const selected = playlist[selectedPlaylistIndex]; const selected = playlist[selectedPlaylistIndex];
const path = (selected.official ? "" : "!") + selected.path; const path = (selected.official ? "" : "!") + selected.path;
ws.send(JSON.stringify({action:"add_to_toplay", songs: [path], top: top})) ws.send(JSON.stringify({ action: "add_to_toplay", songs: [path], top: top }));
Array.from(document.getElementById("playlist-ul").children).forEach(c => c.classList.remove("selected")); success = true;
selectedPlaylistIndex = null; } else if (selectedSubFile && selectedDir) {
return true;
}
if (selectedSubFile && selectedDir) {
fullPath = subbasePath.replace(/\/$/, '') + '/' + selectedSubFile; fullPath = subbasePath.replace(/\/$/, '') + '/' + selectedSubFile;
} else { } else {
const dirEls = document.getElementById("dirs-box").children; const dirEls = document.getElementById("dirs-box").children;
@@ -504,11 +503,19 @@
fullPath = basePath.replace(/\/$/, '') + '/' + selectedItem.textContent; fullPath = basePath.replace(/\/$/, '') + '/' + selectedItem.textContent;
} }
} }
if (fullPath) { if (fullPath) {
ws.send(JSON.stringify({ action:"add_to_toplay", songs:[fullPath], top: top})); ws.send(JSON.stringify({ action: "add_to_toplay", songs: [fullPath], top: top }));
return true; success = true;
} }
return false;
Array.from(document.getElementById("playlist-ul").children).forEach(c => c.classList.remove("selected"));
Array.from(document.getElementById("dirs-box").children).forEach(c => c.classList.remove("selected"));
selectedPlaylistIndex = null;
selectedSubFile = null;
return success;
} }
document.getElementById("add-to-queue-btn").addEventListener("click", () => addSelectedFileToQueue(false)); document.getElementById("add-to-queue-btn").addEventListener("click", () => addSelectedFileToQueue(false));
document.getElementById("add-to-queue2-btn").addEventListener("click", () => addSelectedFileToQueue(true)); document.getElementById("add-to-queue2-btn").addEventListener("click", () => addSelectedFileToQueue(true));