From ff8f11091a530358ef600eedf00c21e90efe62d3 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Wed, 17 Apr 2019 22:51:05 +0200 Subject: Fixed and improved frontend Co-authored-by: LarsVomMars --- src/main/resources/js/files.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/main/resources/js/files.js') 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!") }) }); -- cgit v1.2.3