diff options
author | Marvin Borner | 2019-04-21 18:34:48 +0200 |
---|---|---|
committer | Marvin Borner | 2019-04-21 18:34:48 +0200 |
commit | a5f26def08e100bf74e90d09298ad81e9224e249 (patch) | |
tree | 3dd897b3962c25204a7826d9de2c81e17a76ee5f /src/main/resources/js | |
parent | 191e1976d93aaf0143f84fda86a4805d3b7cede8 (diff) |
Added download button
Co-authored-by: LarsVomMars <lars@kroenner.eu>
Diffstat (limited to 'src/main/resources/js')
-rw-r--r-- | src/main/resources/js/files.js | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/main/resources/js/files.js b/src/main/resources/js/files.js index 4ef5bcc..c3fa1b1 100644 --- a/src/main/resources/js/files.js +++ b/src/main/resources/js/files.js @@ -35,7 +35,8 @@ drop.addEventListener('drop', e => { row.insertCell(2).innerHTML = bytesToSize(file.size); row.insertCell(3).innerHTML = `${date.getMonth() + 1}/${date.getDate()}/${date.getFullYear()} ${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`; row.insertCell(4).innerHTML = "<td><button class='share'><i class='icon ion-md-share'></i></button></td>"; - row.insertCell(5).innerHTML = "<td><button class='delete'><i class='icon ion-md-trash'></i></button></td>"; + row.insertCell(5).innerHTML = "<button class='downloadButton'><a class='download' href='" + file.name + "' download='" + file.name + "'><i class='icon ion-md-download'></i></a></button>"; + row.insertCell(6).innerHTML = "<td><button class='delete'><i class='icon ion-md-trash'></i></button></td>"; setListeners(); @@ -180,6 +181,20 @@ function setListeners() { }) }); + // download button + document.querySelectorAll(".download").forEach(element => { + element.addEventListener("click", e => { + e.stopPropagation(); + }) + }); + document.querySelectorAll(".downloadButton").forEach(element => { + element.addEventListener("click", e => { + console.log(e); + e.stopPropagation(); + e.target.children[0].click() + }) + }); + // share button document.querySelectorAll(".share").forEach(element => { element.addEventListener("click", e => { |