From 774737c5740459f279ec4f58f4e3282347bcd827 Mon Sep 17 00:00:00 2001 From: itismadness Date: Thu, 11 Sep 2025 23:10:16 +0000 Subject: [PATCH] Fix removing artist fields from upload form --- public/static/functions/upload.js | 25 +++++++++++++------------ templates/upload/music.twig | 2 +- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/public/static/functions/upload.js b/public/static/functions/upload.js index d2229d801..ae77b32ae 100644 --- a/public/static/functions/upload.js +++ b/public/static/functions/upload.js @@ -385,16 +385,20 @@ function AddArtistField() { 7: 6, 8: 7, }; - RoleField.selectedIndex = mapping[$("#importance_" + (ArtistCount - 1)).val()]; + RoleField.selectedIndex = mapping[document.getElementById("importance_" + (ArtistCount - 1)).value]; - let x = $('#artistfields').raw(); - x.appendChild(document.createElement("br")); - x.appendChild(ArtistField); - x.append(' '); - x.appendChild(RoleField); + const x = document.getElementById('artistfields'); + const div = document.createElement("div"); + div.id = "artist_field_" + ArtistCount; + div.style.display = "inline"; + div.appendChild(document.createElement("br")); + div.appendChild(ArtistField); + div.append(' '); + div.appendChild(RoleField); + x.appendChild(div); - if ($("#artist_0").data("gazelle-autocomplete")) { - $(ArtistField).live('focus', function() { + if (document.getElementById('artist_0').dataset.gazelleAutocomplete) { + ArtistField.addEventListener('focus', () => { $(ArtistField).autocomplete({ serviceUrl : 'artist.php?action=autocomplete' }); @@ -406,10 +410,7 @@ function RemoveArtistField() { if (ArtistCount === 0) { return; } - let x = $('#artistfields').raw(); - for (let i = 0; i < 3; i++) { - x.removeChild(x.lastChild); - } + document.getElementById("artist_field_" + ArtistCount).remove(); ArtistCount--; } diff --git a/templates/upload/music.twig b/templates/upload/music.twig index 2379122f6..a4aae7f2a 100644 --- a/templates/upload/music.twig +++ b/templates/upload/music.twig @@ -34,7 +34,7 @@ {% for role, artist_list in torrent.Artists %} {% for artist in artist_list %} -