From 6dc162f3ff8b2ae0dd44ff7a5a7c27d77fd50c6d Mon Sep 17 00:00:00 2001 From: cyber-dream Date: Thu, 11 May 2023 02:26:57 +0300 Subject: [PATCH] Fix blog after refactoring --- resources/sys/blog-viewer/blog-viewer.js | 32 +++++++++++------------- resources/sys/finder/finder.js | 2 +- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/resources/sys/blog-viewer/blog-viewer.js b/resources/sys/blog-viewer/blog-viewer.js index 70f2dc4..a90a968 100644 --- a/resources/sys/blog-viewer/blog-viewer.js +++ b/resources/sys/blog-viewer/blog-viewer.js @@ -4,28 +4,26 @@ class BlogViewer{ } /** + * @param {string[]} chroot //TODO * @param {string[]} args */ - NewWindow(args){ - fetch(`${window.location.origin}/application/${this.appId}/render?` + new URLSearchParams({ + async NewWindow(args){ + const response = await fetch(`app/${this.appId}/render?` + new URLSearchParams({ isMobile: WebDesktopEnvironment.isMobile, path: args[0], })) - .then((response) => response.text()) - .then((html) => { - let newWindow = WebDesktopEnvironment.CreateNewWindow(this.appId, 500, 350 ) - newWindow.innerHTML = html - - // let fileView = new FileView("/kek", newWindow.querySelector(".FileTileView"), Finder.Click) - if (!WebDesktopEnvironment.isMobile){ - let scrollBar = new WdeScrollBar(newWindow.querySelector(".ScrollbarPlace"), newWindow.querySelector(".ScrollContent")) - newWindow.querySelector("#closeWindowButton").addEventListener('click', function (params) { - WebDesktopEnvironment.CloseWindow(newWindow) - }) - } - }) - .catch((error) => { - WebDesktopEnvironment.Alert(error); + if (response.status != 200){ + WebDesktopEnvironment.Alert("Error render TODO") //TODO + return + } + const html = await response.text() + + let newWindow = WebDesktopEnvironment.CreateNewWindow(this.appId, 500, 350 ) + newWindow.innerHTML = html + + let scrollBar = new WdeScrollBar(newWindow.querySelector(".ScrollbarPlace"), newWindow.querySelector(".ScrollContent")) + newWindow.querySelector("#closeWindowButton").addEventListener('click', function (params) { + WebDesktopEnvironment.CloseWindow(newWindow) }) } diff --git a/resources/sys/finder/finder.js b/resources/sys/finder/finder.js index f386ab0..99b485d 100644 --- a/resources/sys/finder/finder.js +++ b/resources/sys/finder/finder.js @@ -249,7 +249,7 @@ class FinderWindow{ } break case "blog": - WebDesktopEnvironment.Open("blog-viewer", [`${this.CurPath}/${fileName}`]) + WebDesktopEnvironment.Open("/Applications/BlogViewer.app", [`${this.CurPath}/${fileName}`]) break case "personal-properties": WebDesktopEnvironment.Open("personal-properties", [`${this.CurPath}/${fileName}`])