2023-04-14 15:53:23 +00:00
|
|
|
class BlogViewer{
|
|
|
|
appId = "blog-viewer"
|
|
|
|
constructor(){
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-05-10 23:26:57 +00:00
|
|
|
* @param {string[]} chroot //TODO
|
2023-04-29 13:58:39 +00:00
|
|
|
* @param {string[]} args
|
2023-04-14 15:53:23 +00:00
|
|
|
*/
|
2023-05-10 23:26:57 +00:00
|
|
|
async NewWindow(args){
|
|
|
|
const response = await fetch(`app/${this.appId}/render?` + new URLSearchParams({
|
2023-04-14 15:53:23 +00:00
|
|
|
isMobile: WebDesktopEnvironment.isMobile,
|
2023-04-29 13:58:39 +00:00
|
|
|
path: args[0],
|
2023-04-14 15:53:23 +00:00
|
|
|
}))
|
2023-05-10 23:26:57 +00:00
|
|
|
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)
|
2023-04-14 15:53:23 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {MouseEvent} event
|
|
|
|
* @param {string} path
|
|
|
|
*/
|
|
|
|
static Click(event, path){
|
|
|
|
let fileType = event.target.getAttribute("fileType")
|
|
|
|
switch (fileType) {
|
|
|
|
case "app":
|
|
|
|
//TODO get real id
|
|
|
|
WebDesktopEnvironment.Open("personal-properties", [])
|
|
|
|
break;
|
|
|
|
case "img":
|
|
|
|
WebDesktopEnvironment.Open("img-viewer", ["pizda"])
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
console.log("Unsupported file type")
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|