aboutsummaryrefslogtreecommitdiffstats
path: root/view/js
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2020-12-22 13:23:20 +0000
committerMario <mario@mariovavti.com>2020-12-22 13:23:20 +0000
commit3a38292bab234e531e0bda6055325d0e1eed37de (patch)
tree7d5865e4188d7f9d23c9d1e39f3f19c409b91cbc /view/js
parent60cbb65d84cdc2854bdcf1613cf67180878c44dd (diff)
downloadvolse-hubzilla-3a38292bab234e531e0bda6055325d0e1eed37de.tar.gz
volse-hubzilla-3a38292bab234e531e0bda6055325d0e1eed37de.tar.bz2
volse-hubzilla-3a38292bab234e531e0bda6055325d0e1eed37de.zip
files_ng: improve download handlÃing
Diffstat (limited to 'view/js')
-rw-r--r--view/js/mod_cloud.js38
1 files changed, 31 insertions, 7 deletions
diff --git a/view/js/mod_cloud.js b/view/js/mod_cloud.js
index 516284d9b..35a28d3b9 100644
--- a/view/js/mod_cloud.js
+++ b/view/js/mod_cloud.js
@@ -67,12 +67,21 @@ $(document).ready(function () {
close_and_deactivate_all_panels();
- // some trickery to trigger download action via ajax
- let form = $('<form></form>').attr('action', 'attach').attr('method', 'post');
- form.append($("<input></input>").attr('type', 'hidden').attr('name', 'attach_path').attr('value', window.location.pathname));
- form.append($("<input></input>").attr('type', 'hidden').attr('name', 'channel_id').attr('value', channelId));
- form.append($("<input></input>").attr('type', 'hidden').attr('name', 'attach_ids[]').attr('value', id));
- form.appendTo('body').submit().remove();
+ $('body').css('cursor', 'wait');
+
+ let data = [
+ {name: 'attach_path', value: window.location.pathname},
+ {name: 'channel_id', value: channelId},
+ {name: 'attach_ids[]', value: id}
+ ]
+
+ $.post('attach', data, function (data) {
+ if (data.success) {
+ $('body').css('cursor', 'auto');
+ window.location.href = '/attach/download?token=' + data.token;
+ }
+ });
+
});
$('.cloud-tool-delete-btn').on('click', function (e) {
@@ -277,7 +286,7 @@ $(document).ready(function () {
$('#cloud-multi-tool-download-btn').on('click', function (e) {
e.preventDefault();
- let post_data = $('.cloud-multi-tool-checkbox:checked');
+ let post_data = $('.cloud-multi-tool-checkbox:checked').serializeArray();
if(! post_data.length) {
return false;
@@ -285,6 +294,20 @@ $(document).ready(function () {
close_and_deactivate_all_panels();
+ $('body').css('cursor', 'wait');
+
+ post_data.push(
+ {name: 'attach_path', value: window.location.pathname},
+ {name: 'channel_id', value: channelId},
+ );
+
+ $.post('attach', post_data, function (data) {
+ if (data.success) {
+ $('body').css('cursor', 'auto');
+ window.location.href = '/attach/download?token=' + data.token;
+ }
+ });
+/*
// some trickery to trigger download action via ajax
var form = $('<form></form>').attr('action', 'attach').attr('method', 'post');
form.append($("<input></input>").attr('type', 'hidden').attr('name', 'attach_path').attr('value', window.location.pathname));
@@ -293,6 +316,7 @@ $(document).ready(function () {
form.append($("<input></input>").attr('type', 'hidden').attr('name', 'attach_ids[]').attr('value', this.value));
});
form.appendTo('body').submit().remove();
+*/
});
$('#cloud-multi-tool-delete-btn').on('click', function (e) {