aboutsummaryrefslogtreecommitdiffhomepage
path: root/assets/common/js/shaare-batch.js
diff options
context:
space:
mode:
Diffstat (limited to 'assets/common/js/shaare-batch.js')
-rw-r--r--assets/common/js/shaare-batch.js12
1 files changed, 8 insertions, 4 deletions
diff --git a/assets/common/js/shaare-batch.js b/assets/common/js/shaare-batch.js
index 557325ee..6fc16faf 100644
--- a/assets/common/js/shaare-batch.js
+++ b/assets/common/js/shaare-batch.js
@@ -4,7 +4,11 @@ const sendBookmarkForm = (basePath, formElement) => {
4 4
5 const formData = new FormData(); 5 const formData = new FormData();
6 [...inputs].forEach((input) => { 6 [...inputs].forEach((input) => {
7 formData.append(input.getAttribute('name'), input.value); 7 if (input.getAttribute('type') === 'checkbox') {
8 formData.append(input.getAttribute('name'), input.checked);
9 } else {
10 formData.append(input.getAttribute('name'), input.value);
11 }
8 }); 12 });
9 13
10 return new Promise((resolve, reject) => { 14 return new Promise((resolve, reject) => {
@@ -26,9 +30,9 @@ const sendBookmarkForm = (basePath, formElement) => {
26const sendBookmarkDelete = (buttonElement, formElement) => ( 30const sendBookmarkDelete = (buttonElement, formElement) => (
27 new Promise((resolve, reject) => { 31 new Promise((resolve, reject) => {
28 const xhr = new XMLHttpRequest(); 32 const xhr = new XMLHttpRequest();
29 xhr.open('GET', buttonElement.href); 33 xhr.open('GET', `${buttonElement.href}&source=batch`);
30 xhr.onload = () => { 34 xhr.onload = () => {
31 if (xhr.status !== 200) { 35 if (xhr.status !== 204) {
32 alert(`An error occurred. Return code: ${xhr.status}`); 36 alert(`An error occurred. Return code: ${xhr.status}`);
33 reject(); 37 reject();
34 } else { 38 } else {
@@ -100,7 +104,7 @@ const redirectIfEmptyBatch = (basePath, formElements, path) => {
100 }); 104 });
101 105
102 Promise.all(promises).then(() => { 106 Promise.all(promises).then(() => {
103 window.location.href = basePath || '/'; 107 window.location.href = `${basePath}/`;
104 }); 108 });
105 }); 109 });
106 }); 110 });