aboutsummaryrefslogtreecommitdiff
path: root/src/main/resources/js/files.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/resources/js/files.js')
-rw-r--r--src/main/resources/js/files.js18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/main/resources/js/files.js b/src/main/resources/js/files.js
index 69cdf32..3346a31 100644
--- a/src/main/resources/js/files.js
+++ b/src/main/resources/js/files.js
@@ -51,12 +51,16 @@ drop.addEventListener('drop', e => {
} else {
subItem.file(subFile => {
// TODO: Add support for nested directory upload with more than 1 layer - via webkitRelativePath on firefox?
- console.log(uploadedFiles);
- console.log(`${path}/${file.name}/${subFile.name}`);
if (!uploadedFiles.includes(`${path}/${file.name}/${subFile.name}`)) {
const formData = new FormData();
const request = new XMLHttpRequest();
+ request.upload.onprogress = e => {
+ if (e.lengthComputable) {
+ console.log(`${subFile.name}: ${e.loaded / e.total * 100}%`)
+ }
+ };
+
uploadedFiles.push(`${path}/${file.name}/${subFile.name}`);
formData.append("file", subFile);
if (subFile.webkitRelativePath === "") request.open("POST", `/upload/${path}/${file.name}`);
@@ -74,6 +78,12 @@ drop.addEventListener('drop', e => {
const formData = new FormData();
const request = new XMLHttpRequest();
+ request.upload.onprogress = e => {
+ if (e.lengthComputable) {
+ console.log(`${file.name}: ${e.loaded / e.total * 100}%`)
+ }
+ };
+
formData.append("file", file);
request.open("POST", `/upload/${path}`);
request.send(formData);
@@ -114,7 +124,7 @@ function setListeners() {
element.addEventListener("click", () => {
if (images.indexOf(extension) === -1 && videos.indexOf(extension) === -1 && audio.indexOf(extension) === -1)
- window.location = filename; // download binary files
+ window.location = `/files/${path}/${filename}`; // download binary files
});
});
@@ -151,7 +161,7 @@ function setListeners() {
// normal files
document.querySelectorAll("[data-href]").forEach(element => {
element.addEventListener("click", () => {
- window.location = element.getAttribute("data-href");
+ window.location = `/files${path}/${element.getAttribute("data-href")}`;
})
});