mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-25 04:24:45 -04:00
Adds workaround to use direct POST-request downloads.
This commit is contained in:
parent
adce6f19c4
commit
ab45b3072c
3 changed files with 12 additions and 116 deletions
|
@ -27,34 +27,6 @@ modulejs.define('ext/download', ['_', '$', 'core/settings', 'core/resource', 'co
|
|||
}, 1000);
|
||||
},
|
||||
|
||||
handleResponse = function (json) {
|
||||
|
||||
$download.removeClass('current');
|
||||
$img.attr('src', resource.image('download'));
|
||||
|
||||
if (json && json.code === 0) {
|
||||
setTimeout(function () { // wait here so the img above can be updated in time
|
||||
|
||||
window.location = '?action=getArchive&id=' + json.id + '&as=' + (settings.packageName || location.getItem().label) + '.' + settings.format;
|
||||
}, 200);
|
||||
} else {
|
||||
failed();
|
||||
}
|
||||
},
|
||||
|
||||
requestArchive = function (hrefsStr) {
|
||||
|
||||
$download.addClass('current');
|
||||
$img.attr('src', resource.image('loading.gif', true));
|
||||
|
||||
server.request({
|
||||
action: 'createArchive',
|
||||
type: settings.type,
|
||||
format: settings.format,
|
||||
hrefs: hrefsStr
|
||||
}, handleResponse);
|
||||
},
|
||||
|
||||
onSelection = function (items) {
|
||||
|
||||
selectedHrefsStr = '';
|
||||
|
@ -72,15 +44,19 @@ modulejs.define('ext/download', ['_', '$', 'core/settings', 'core/resource', 'co
|
|||
onClick = function (event) {
|
||||
|
||||
var type = settings.type,
|
||||
extension = type === 'shell-zip' ? 'zip' : 'tar',
|
||||
query = '?action=passArchive' +
|
||||
'&as=' + encodeURIComponent((settings.packageName || location.getItem().label) + '.' + extension) +
|
||||
'&type=' + type +
|
||||
'&hrefs=' + encodeURIComponent(selectedHrefsStr),
|
||||
$iframe = $('<iframe src="' + query + '" style="display: none;" />');
|
||||
extension = (type === 'shell-zip') ? 'zip' : 'tar',
|
||||
query = {
|
||||
action: 'passArchive',
|
||||
as: (settings.packageName || location.getItem().label) + '.' + extension,
|
||||
type: type,
|
||||
hrefs: selectedHrefsStr
|
||||
},
|
||||
$form = $('<form action="#" method="post" style="display:none;" />');
|
||||
|
||||
$iframe.appendTo('body');
|
||||
setTimeout(function () { $iframe.remove(); }, 1000);
|
||||
for (var key in query) {
|
||||
$form.append('<input type="hidden" name="' + key + '" value="' + query[key] + '" />')
|
||||
}
|
||||
$form.appendTo('body').submit().remove();
|
||||
},
|
||||
|
||||
init = function () {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue