rejetto forum

no jquery

0 Members and 1 Guest are viewing this topic.

Offline NaitLee

  • Occasional poster
  • *
    • Posts: 96
  • Computer brained boy
    • View Profile
(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?
Busy in school until late June, 2021.
My HFS template will not be frequently updated during this period.


Offline NaitLee

  • Occasional poster
  • *
    • Posts: 96
  • Computer brained boy
    • View Profile
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();
Busy in school until late June, 2021.
My HFS template will not be frequently updated during this period.


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13304
    • View Profile
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 }));


Offline dj

  • Tireless poster
  • ****
    • Posts: 232
  • 👣 🐾
    • View Profile
    • PWAs