aboutsummaryrefslogtreecommitdiff
path: root/assets/cargohold.js
diff options
context:
space:
mode:
authorcbdev <cb@cbcdn.com>2023-08-13 21:15:24 +0200
committercbdev <cb@cbcdn.com>2023-08-13 21:15:24 +0200
commit0c3ab4200dbb58038ac2ec4a4cdd78729a7e21b3 (patch)
treed98beb75b064f0cd22d08597ba2c37d1fd48a997 /assets/cargohold.js
parentbe37d4f7d7a09959f56f735d080b1cf7d4cf0f18 (diff)
downloadcargohold-0c3ab4200dbb58038ac2ec4a4cdd78729a7e21b3.tar.gz
cargohold-0c3ab4200dbb58038ac2ec4a4cdd78729a7e21b3.tar.bz2
cargohold-0c3ab4200dbb58038ac2ec4a4cdd78729a7e21b3.zip
Implement download all button
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();
}