From bc75b5bfff5db6db0ee1c8e04c7ef8e772b0017d Mon Sep 17 00:00:00 2001 From: Taly Date: Thu, 14 Jan 2021 00:53:54 +0300 Subject: [PATCH] detect right dirname --- index.html | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index cbc4564..0d0583d 100644 --- a/index.html +++ b/index.html @@ -238,6 +238,8 @@ return FileToObject(file); }); + let shortestDirname = false; + filesList = chosenFiles .filter(file => { return (file.type).startsWith('image'); @@ -254,18 +256,28 @@ return 0; }) .map(function (file) { + const dirname = path.dirname(file.path); + + if (!shortestDirname || dirname.length < shortestDirname.length) { + shortestDirname = dirname; + } + return file.path; }); - - const dirname = path.basename(path.dirname(filesList[0])); - selectedDirectoryName.innerText = dirname; + // .filter(filepath => { + // const dirname = path.dirname(filepath); + // + // return dirname === shortestDirname; + // }); images = filesList; selectedDirectoryImages.innerText = `${images.length} images`; - selectedDirectory.classList.remove('hidden'); + const dirname = path.basename(shortestDirname); + selectedDirectoryName.innerText = dirname; + selectedDirectory.classList.remove('hidden'); tlOptions.classList.remove('hidden'); };