diff options
Diffstat (limited to 'assets/cargohold.js')
-rw-r--r-- | assets/cargohold.js | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/assets/cargohold.js b/assets/cargohold.js index 18dbeae..ea882fa 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"); @@ -139,14 +139,34 @@ function listing_update(){ for(let i = 0; i < data.files.length; i++){ listing_add(data.files[i], data.display); } + + element("download-all").innerText = "Download all (" + data.files.length + " Files, " + (data.total / 1024 /1024) + "MB)"; }; req.open("GET", "listing"); 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(); } |