From 3702495714a3b9fce3312f4e98a00aa5a767a5c0 Mon Sep 17 00:00:00 2001 From: cyber-dream Date: Thu, 11 May 2023 02:17:59 +0300 Subject: [PATCH] Refactor AboutMe app --- .../personal-properties.js | 44 +++++++++---------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/resources/sys/personal-properties/personal-properties.js b/resources/sys/personal-properties/personal-properties.js index e1a0a2c..2653ed7 100644 --- a/resources/sys/personal-properties/personal-properties.js +++ b/resources/sys/personal-properties/personal-properties.js @@ -8,35 +8,31 @@ class AboutMe{ } /** - * @param {string} path + * @param {string} chroot * @param {[]string} args */ - NewWindow(path, args){ - if (path == ""){ - path = "/home/user/aboutme.props" //FIXME + async NewWindow(chroot, args){ + console.log(chroot) + if (chroot == ""){ + chroot = "/home/user" //FIXME } - const params = new URLSearchParams({isMobile: WebDesktopEnvironment.isMobile, path: path}) - fetch(`/app/${this.appId}/render?`+ params) - .then((response) => response.text()) - .then((html) => { - // console.log(document.body) - // let heigth = Math.max(document.body.clientHeight*0.8, scrollDiv.children[0].scrollHeight) //TODO - let newWindow = WebDesktopEnvironment.CreateNewWindow(this.appId, 360, document.body.clientHeight*0.8 ) + console.log(`${chroot}/AboutMe.app/aboutme.props`) + const params = new URLSearchParams({isMobile: WebDesktopEnvironment.isMobile, path: `${chroot}/AboutMe.app/aboutme.props`}) + const response = await fetch(`/app/${this.appId}/render?`+ params) + console.log(response) + if (response.status != 200){ + WebDesktopEnvironment.Alert("Error TODO") //TODO + return + } + const html = await response.text() + + let newWindow = WebDesktopEnvironment.CreateNewWindow(this.appId, 360, document.body.clientHeight*0.8 ) - newWindow.innerHTML = html - newWindow.style.height = 'auto' + newWindow.innerHTML = html + newWindow.style.height = 'auto' - // console.log(newWindow.querySelector('.ScrollBarScrollElement')) - - // let scrollBar = new WdeScrollBar(newWindow.querySelector('.ScrollbarPlace'), newWindow.querySelector('.PropsView')) - - newWindow.querySelector("#closeWindowButton").addEventListener('click', () => { - // console.log("qewqweqweqweqwe") - WebDesktopEnvironment.CloseWindow(newWindow) - }) + newWindow.querySelector("#closeWindowButton").addEventListener('click', () => { + WebDesktopEnvironment.CloseWindow(newWindow) }) - .catch((error) => { - WebDesktopEnvironment.Alert(error); - }); } } \ No newline at end of file