diff options
author | Marvin Borner | 2019-04-17 22:51:05 +0200 |
---|---|---|
committer | Marvin Borner | 2019-04-17 22:51:05 +0200 |
commit | ff8f11091a530358ef600eedf00c21e90efe62d3 (patch) | |
tree | 5ec11bbcecb0b9c1f3db7fe91e8ff97943357a4d /src/main/resources/js | |
parent | 6051112b2811b197a32940a2aa7ffa48b7501ea0 (diff) |
Fixed and improved frontend
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, 10 insertions, 7 deletions
diff --git a/src/main/resources/js/files.js b/src/main/resources/js/files.js index 1247ed1..024f74f 100644 --- a/src/main/resources/js/files.js +++ b/src/main/resources/js/files.js @@ -38,6 +38,7 @@ drop.addEventListener('drop', e => { setListeners(); + // TODO: Add empty directory upload support const iterateFiles = subItem => { if (subItem.isDirectory) { let directoryReader = subItem.createReader(); @@ -88,13 +89,13 @@ function setListeners() { const filename = element.getAttribute("data-path"); const extension = /(?:\.([^.]+))?$/.exec(filename)[1].toLowerCase(); - if (images.indexOf(extension) > -1) { + if (images.includes(extension)) { element.setAttribute("data-bp", filename); element.setAttribute("data-image", ""); - } else if (videos.indexOf(extension) > -1) { + } else if (videos.includes(extension)) { element.setAttribute("data-src", filename); element.setAttribute("data-video", ""); - } else if (audio.indexOf(extension) > -1) { + } else if (audio.includes(extension)) { element.setAttribute("data-src", filename); element.setAttribute("data-audio", ""); } @@ -125,7 +126,7 @@ function setListeners() { }); }); - //audio // TODO: Fix IOException and scrubbing issues with chromium based browsers + // audio // TODO: Fix IOException and scrubbing issues with chromium based browsers document.querySelectorAll("[data-audio]").forEach(element => { element.addEventListener("click", audio => { BigPicture({ @@ -149,9 +150,11 @@ function setListeners() { const request = new XMLHttpRequest(); const parent = e.target.closest("tr"); const fileName = parent.getAttribute("data-href") || parent.getAttribute("data-path"); - request.open("POST", `/delete/${path}/${fileName}`); - request.send(); - parent.remove(); + if (confirm(`Do you really want to delete: ${fileName}?`)) { + request.open("POST", `/delete/${path}/${fileName}`); + request.send(); + parent.remove(); + } else console.log("File not deleted!") }) }); |