personal-website/resources/sys/wde/file-view.js

39 lines
1.2 KiB
JavaScript

class FileView{
parentElem = undefined
/**
* @param {HTMLElement} fileViewElem
* @param {Function} clickCallback
*/
constructor(fileViewElem, clickCallback){
//TODO check all params
this.parentElem = fileViewElem
// this.OpenFolder(path)
// let scrollDiv = fileViewElem.children[1]
// console.log(scrollDiv)
// let scrollBar = new WdeScrollBar(fileViewElem.children[1].children[0], fileViewElem.children[0])
fileViewElem.addEventListener('click', (event) => {
clickCallback(event)
})
}
/** Get html of folder by path
* @param {string} path
*/
OpenFolder(path){
fetch(`${window.location.origin}/system/wde/widgets/file-tile-view?path=${path}`) //TODO Move to wde func. Or Not?
.then((response) => response.text())
.then((html) => {
//TODO
// console.log(responseStatus)
// if (responseStatus != 200) {
// WebDesktopEnvironment.Alert("Error")
// }
this.parentElem.innerHTML = html
}).catch((error) => {
WebDesktopEnvironment.Alert(error);
})
}
}