Add ability to edit the playlist name and visibility #5

This commit is contained in:
2026-07-19 13:22:28 +02:00
parent a04d58c60f
commit f35d1a119e
9 changed files with 290 additions and 85 deletions
+44 -13
View File
@@ -1,14 +1,10 @@
if (document.getElementById("playlist-add")) {
function createPlaylist() {
console.log('Adding to Playlist: ' + document.querySelector("#playlist").value)
function addToPlaylist() {
window.axios.post('/hentai/add-to-playlist', {
playlist: document.getElementById('playlist').value,
episode_id: document.getElementById('e_id').value
}).then(function (response) {
if (response.status == 200) {
document.getElementById("playlist-cancel").click();
if (response.data.message == 'already-added') {
Swal.fire({
title: "Already added!",
@@ -18,6 +14,8 @@ if (document.getElementById("playlist-add")) {
}
if (response.data.message == 'success') {
document.getElementById("playlist-cancel").click();
Swal.fire({
title: "Success!",
text: "Added episode to the playlist!",
@@ -27,33 +25,66 @@ if (document.getElementById("playlist-add")) {
}
}).catch(function (error) {
console.log(error);
Swal.fire({
title: "Error!",
text: "Could not add episode to playlist.",
icon: "error"
});
});
}
document.querySelector("#playlist-add").addEventListener("click", createPlaylist);
document.querySelector("#playlist-add").addEventListener("click", addToPlaylist);
}
if (document.getElementById("playlist-create-and-add")) {
function createAndAddPlaylist() {
const nameField = document.getElementById('playlist-name');
const visibilityField = document.getElementById('playlist-visibility');
if (!nameField.value.trim()) {
Swal.fire({
title: "Name required!",
text: "Please enter a playlist name.",
icon: "warning"
});
return;
}
window.axios.post('/hentai/create-playlist', {
name: document.getElementById('name').value,
visiblity: document.getElementById('visiblity').value
name: nameField.value,
visiblity: visibilityField.value
}).then(function (response) {
window.axios.post('/hentai/add-to-playlist', {
playlist: response.data.playlist_id,
episode_id: document.getElementById('e_id').value
}).then(function (response) {
if (response.status == 200) {
document.getElementById("playlist-cancel").click();
}).then(function (addResponse) {
if (addResponse.status == 200) {
const cancelBtn = document.getElementById("playlist-cancel");
if (cancelBtn) cancelBtn.click();
Swal.fire({
title: "Success!",
text: "Playlist created and episode added!",
icon: "success"
});
}
}).catch(function (error) {
console.log(error);
Swal.fire({
title: "Error!",
text: "Could not add episode to the new playlist.",
icon: "error"
});
});
}).catch(function (error) {
console.log(error);
Swal.fire({
title: "Error!",
text: "Could not create playlist.",
icon: "error"
});
});
}
document.querySelector("#playlist-create-and-add").addEventListener("click", createAndAddPlaylist);
}
}