rejetto forum

Software => HFS ~ HTTP File Server => HTML & templates => Topic started by: NaitLee on June 25, 2020, 11:13:32 AM

Title: no jquery
Post 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?
Title: Re: no jquery
Post by: NaitLee on July 07, 2020, 04:00:29 AM
A question: in a folder, after getting (only) selected filenames, how to archive them without jQuery?

This can be done with:

Code: [Select]
// 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();
Title: Re: no jquery
Post by: rejetto on July 07, 2020, 09:55:39 AM
yeah, my code was just for collecting the filenames.
i still would change this:
Code: [Select]
form.append(document.createElement('input'));
    form.children[i].type = 'hidden';
    form.children[i].name = 'selection';
    form.children[i].value = v;

into this:
Code: [Select]
form.append(Object.assign(document.createElement('input'), { type:'hidden', name:'selection', value:v }));
Title: Re: no jquery
Post by: dj on July 07, 2020, 11:38:23 AM
alternativ this can be done with a download (https://github.com/dj0001/hfs-template/blob/gh-pages/mobil-light_V5.5.tpl#L190-L199)