personal-website/res/dev-fs/apps/ImgViewer/img-viewer.js

28 lines
863 B
JavaScript

class ImgViewer{
appId = "img-viewer"
/**
* @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, 450,400 )
newWindow.innerHTML = html
if (!WebDesktopEnvironment.isMobile){
newWindow.querySelector("#closeWindowButton").addEventListener('click', function (params) {
WebDesktopEnvironment.CloseWindow(newWindow)
})
}
})
.catch((error) => {
WebDesktopEnvironment.Alert(error);
});
}
}