personal-website/resources/sys/finder/finder.js

54 lines
1.8 KiB
JavaScript
Raw Normal View History

2023-03-20 11:20:37 +00:00
class Finder{
appId = "finder"
2023-04-12 17:04:25 +00:00
constructor(){
// this.appElem = appElem
2023-03-17 01:16:51 +00:00
}
2023-03-22 21:53:06 +00:00
/**
* @param {string} path
*/
NewWindow(path){
2023-04-13 01:09:07 +00:00
fetch(`${window.location.origin}/application/${this.appId}/render?` + new URLSearchParams({
isMobile: WebDesktopEnvironment.isMobile,
// bar: true,
})) //TODO Move to wde func. Or Not?
2023-03-17 01:16:51 +00:00
.then((response) => response.text())
.then((html) => {
2023-04-13 01:09:07 +00:00
let newWindow = WebDesktopEnvironment.CreateNewWindow(this.appId, 500, 350 )
2023-03-22 21:53:06 +00:00
newWindow.innerHTML = html
2023-04-13 01:09:07 +00:00
let fileView = new FileView("/kek", newWindow.querySelector(".FileTileView"), Finder.Click)
if (!WebDesktopEnvironment.isMobile){
let scrollBar = new WdeScrollBar(newWindow.children[1].children[1], newWindow.children[1].children[0])// TODO to querry selector
let closeButton = newWindow.children[0].children[0] //TODO to query selector
closeButton.addEventListener('click', function (params) {
WebDesktopEnvironment.CloseWindow(newWindow)
})
}
2023-03-17 01:16:51 +00:00
})
.catch((error) => {
WebDesktopEnvironment.Alert(error);
2023-03-22 21:53:06 +00:00
})
2023-04-12 17:04:25 +00:00
}
2023-04-13 01:09:07 +00:00
2023-04-12 17:04:25 +00:00
/**
* @param {MouseEvent} event
* @param {string} path
*/
2023-04-13 01:09:07 +00:00
static Click(event, path){
let fileType = event.target.getAttribute("fileType")
switch (fileType) {
case "app":
//TODO get real id
WebDesktopEnvironment.Open("personal-properties", [])
2023-04-12 17:04:25 +00:00
break;
2023-04-12 21:05:23 +00:00
case "img":
WebDesktopEnvironment.Open("img-viewer", ["pizda"])
break;
default:
2023-04-12 17:04:25 +00:00
console.log("Unsupported file type")
break;
}
2023-03-17 01:16:51 +00:00
}
}