Refactor AboutMe app

This commit is contained in:
cyber-dream 2023-05-11 02:17:59 +03:00
parent 50d7924728
commit 3702495714

View File

@ -8,35 +8,31 @@ class AboutMe{
} }
/** /**
* @param {string} path * @param {string} chroot
* @param {[]string} args * @param {[]string} args
*/ */
NewWindow(path, args){ async NewWindow(chroot, args){
if (path == ""){ console.log(chroot)
path = "/home/user/aboutme.props" //FIXME if (chroot == ""){
chroot = "/home/user" //FIXME
} }
const params = new URLSearchParams({isMobile: WebDesktopEnvironment.isMobile, path: path}) console.log(`${chroot}/AboutMe.app/aboutme.props`)
fetch(`/app/${this.appId}/render?`+ params) const params = new URLSearchParams({isMobile: WebDesktopEnvironment.isMobile, path: `${chroot}/AboutMe.app/aboutme.props`})
.then((response) => response.text()) const response = await fetch(`/app/${this.appId}/render?`+ params)
.then((html) => { console.log(response)
// console.log(document.body) if (response.status != 200){
// let heigth = Math.max(document.body.clientHeight*0.8, scrollDiv.children[0].scrollHeight) //TODO WebDesktopEnvironment.Alert("Error TODO") //TODO
let newWindow = WebDesktopEnvironment.CreateNewWindow(this.appId, 360, document.body.clientHeight*0.8 ) return
}
const html = await response.text()
let newWindow = WebDesktopEnvironment.CreateNewWindow(this.appId, 360, document.body.clientHeight*0.8 )
newWindow.innerHTML = html newWindow.innerHTML = html
newWindow.style.height = 'auto' newWindow.style.height = 'auto'
// console.log(newWindow.querySelector('.ScrollBarScrollElement')) newWindow.querySelector("#closeWindowButton").addEventListener('click', () => {
WebDesktopEnvironment.CloseWindow(newWindow)
// let scrollBar = new WdeScrollBar(newWindow.querySelector('.ScrollbarPlace'), newWindow.querySelector('.PropsView'))
newWindow.querySelector("#closeWindowButton").addEventListener('click', () => {
// console.log("qewqweqweqweqwe")
WebDesktopEnvironment.CloseWindow(newWindow)
})
}) })
.catch((error) => {
WebDesktopEnvironment.Alert(error);
});
} }
} }