aboutsummaryrefslogtreecommitdiff
path: root/assets/cargohold.js
diff options
context:
space:
mode:
Diffstat (limited to 'assets/cargohold.js')
-rw-r--r--assets/cargohold.js20
1 files changed, 19 insertions, 1 deletions
diff --git a/assets/cargohold.js b/assets/cargohold.js
index 18dbeae..2a4ca76 100644
--- a/assets/cargohold.js
+++ b/assets/cargohold.js
@@ -7,7 +7,6 @@
var running = false;
var queue = [];
-
function queue_work(){
let i = 0;
for(; i < queue.length; i++){
@@ -118,6 +117,7 @@ function interface_update(access){
function listing_add(file, style = "default"){
let link = node("a", "listing-entry", file.name);
link.href = "file/" + encodeURIComponent(file.name);
+ link.setAttribute("data-filename", file.name)
if(style == "gallery"){
let image = node("img", "preview");
@@ -144,9 +144,27 @@ function listing_update(){
req.send();
}
+function download_all(ev){
+ let links = document.getElementsByClassName("listing-entry");
+ var current = 0;
+ var interval = setInterval(function(){
+ if(current < links.length){
+ link = links[current];
+ link.download = link.getAttribute("data-filename");
+ link.click();
+ link.removeAttribute("download");
+ current++;
+ }
+ else{
+ clearInterval(interval);
+ }
+ }, 1000);
+}
+
function init(){
element("file-submit").style.display = "none";
element("files").onchange = upload_start;
+ element("download-all").onclick = download_all;
listing_update();
}