rejetto forum
Software => HFS ~ HTTP File Server => HTML & templates => Topic started by: NaitLee on June 25, 2020, 11:13:32 AM
-
(Going to make multi-file select to Takeback. Almost done.)
A question: in a folder, after getting (only) selected filenames, how to archive them without jQuery?
-
A question: in a folder, after getting (only) selected filenames, how to archive them without jQuery?
This can be done with:
// Get all selected filenames as array(list) variable "filenames"
if (!confirm('{.!Download these.} '+filenames.length+' {.!files in a .tar archive?.}')) return;
var form = document.createElement('form');
form.style.display = 'none';
form.action = '%folder%?mode=archive&recursive';
form.method = 'POST';
filenames.forEach(function(v, i) {
form.append(document.createElement('input'));
form.children[i].type = 'hidden';
form.children[i].name = 'selection';
form.children[i].value = v;
})
document.body.appendChild(form);
form.submit();
-
yeah, my code was just for collecting the filenames.
i still would change this:
form.append(document.createElement('input'));
form.children[i].type = 'hidden';
form.children[i].name = 'selection';
form.children[i].value = v;
into this:
form.append(Object.assign(document.createElement('input'), { type:'hidden', name:'selection', value:v }));
-
alternativ this can be done with a download (https://github.com/dj0001/hfs-template/blob/gh-pages/mobil-light_V5.5.tpl#L190-L199)