personal-website/resources/sys/blog-viewer/blog-viewer.js
2023-05-07 22:56:40 +03:00

52 lines
1.7 KiB
JavaScript

class BlogViewer{
appId = "blog-viewer"
constructor(){
}
/**
* @param {string[]} args
*/
NewWindow(args){
fetch(`${window.location.origin}/application/${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);
})
}
/**
* @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;
}
}
}