rejetto forum

no jquery

0 Members and 1 Guest are viewing this topic.

Offline NaitLee

  • Tireless poster
  • ****
    • Posts: 117
  • 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?
Had some psychiatry problem and resting in home... I may need your help... So play with me? :D
Check out my template ;)


Offline NaitLee

  • Tireless poster
  • ****
    • Posts: 117
  • 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();
Had some psychiatry problem and resting in home... I may need your help... So play with me? :D
Check out my template ;)


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13308
    • 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: 242
  • 👣 🐾
    • View Profile
    • PWAs