From 1b3f17777ea80c33d3355c38b94c38c0a34a81ef Mon Sep 17 00:00:00 2001 From: cyber-dream Date: Thu, 11 May 2023 04:56:56 +0300 Subject: [PATCH] Fix finder context menu in desktop mode and add error on link giletype --- resources/sys/finder/finder.js | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/resources/sys/finder/finder.js b/resources/sys/finder/finder.js index 2a64bbc..73635f9 100644 --- a/resources/sys/finder/finder.js +++ b/resources/sys/finder/finder.js @@ -153,9 +153,12 @@ class FinderWindow{ const html = await response.text() args[2].innerHTML = html - this.fileView = new FileView(args[2].querySelector(".FileTileView"), (event) =>{ - this.Click(event, true) - }) + this.fileView = new FileView( + args[2].querySelector(".FileTileView"), (event) =>{this.Click(event)}, + (event) => { this.RightClick(event) }, + (event, draggedElem) => { this.DropEvent(event, draggedElem)}, + () => { this.ReRenderDir() } + ) this.RenderDir(args[0]) return } @@ -170,7 +173,6 @@ class FinderWindow{ let newWindow = WebDesktopEnvironment.CreateNewWindow(Finder.appId, 500, 350 ) newWindow.innerHTML = html - // console.log(this.ReRenderDir) this.fileView = new FileView( newWindow.querySelector(".FileTileView"), (event) => { this.Click(event) }, @@ -257,22 +259,24 @@ class FinderWindow{ Click(event){ let fileType = event.target.getAttribute("fileType") let fileName = event.target.getAttribute("name") + const fileExtension = fileName.split(".")[fileName.split(".").length - 1] //FIXME - switch (fileType) { - case "directory": - if (fileExtension == "app"){ - WebDesktopEnvironment.Open(`${this.CurPath}/${fileName}`, []) - } else{ - WebDesktopEnvironment.Open(`/Applications/Finder.app`, [`${this.CurPath}/${fileName}`]) - } + switch (true) { + case fileType == "objectlink": + WebDesktopEnvironment.Alert("Links not supported yet") break - case "blog": + case fileType == "directory": + WebDesktopEnvironment.Open(`/Applications/Finder.app`, [`${this.CurPath}/${fileName}`]) + break + case fileExtension == "blog": WebDesktopEnvironment.Open("/Applications/BlogViewer.app", [`${this.CurPath}/${fileName}`]) break - case "jpeg": - case "png": + case fileExtension == "jpeg" | fileExtension == "png": WebDesktopEnvironment.Open("img-viewer", [this.CurPath + "/" + fileName]) break; + case fileExtension == "app": + WebDesktopEnvironment.Open(`${this.CurPath}/${fileName}`, []) + break default: // console.log("Unsupported file type") WebDesktopEnvironment.Alert("Unsupported file type")