aboutsummaryrefslogtreecommitdiffstats
path: root/youtube
diff options
context:
space:
mode:
authorJames Taylor <user234683@users.noreply.github.com>2019-10-21 21:14:13 -0700
committerJames Taylor <user234683@users.noreply.github.com>2019-10-21 21:14:13 -0700
commitb614fcdb8579ba29fccfa47eab1e2965cfb0beaa (patch)
tree1fd8981ea4e87468a8a77331960d91688a1492af /youtube
parentfd327ae6533d0e9d6119fd8951017775211bd29f (diff)
downloadyt-local-b614fcdb8579ba29fccfa47eab1e2965cfb0beaa.tar.lz
yt-local-b614fcdb8579ba29fccfa47eab1e2965cfb0beaa.tar.xz
yt-local-b614fcdb8579ba29fccfa47eab1e2965cfb0beaa.zip
Fix regression: Can't remove videos from local playlists
Diffstat (limited to 'youtube')
-rw-r--r--youtube/templates/base.html17
1 files changed, 12 insertions, 5 deletions
diff --git a/youtube/templates/base.html b/youtube/templates/base.html
index ac5c1ce..554e116 100644
--- a/youtube/templates/base.html
+++ b/youtube/templates/base.html
@@ -142,9 +142,19 @@
window.setTimeout(removeMessage, removalDelay+300, messageBox);
}
// https://developer.mozilla.org/en-US/docs/Learn/HTML/Forms/Sending_forms_through_JavaScript
- function sendData(){
+ function sendData(event){
+ var clicked_button = document.activeElement;
+ if(clicked_button === null || clicked_button.getAttribute('type') !== 'submit' || clicked_button.parentElement != event.target){
+ console.log('ERROR: clicked_button not valid');
+ return;
+ }
+ if(clicked_button.getAttribute('value') !== 'add'){
+ return; // video(s) are being removed from playlist, just let it refresh the page
+ }
+ event.preventDefault();
var XHR = new XMLHttpRequest();
var FD = new FormData(playlistAddForm);
+
// https://stackoverflow.com/questions/48322876/formdata-doesnt-include-value-of-buttons
FD.append('action', 'add');
@@ -168,10 +178,7 @@
XHR.send(FD);
}
- playlistAddForm.addEventListener('submit', function(event){
- event.preventDefault();
- sendData();
- });
+ playlistAddForm.addEventListener('submit', sendData);
</script>
{% endif %}
</header>