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

37 lines
1.2 KiB
JavaScript
Raw Normal View History

2023-03-22 21:53:06 +00:00
class FileView{
path = ""
/**
* @param {string} path
* @param {HTMLElement} fileViewElem
2023-04-12 17:04:25 +00:00
* @param {Function} clickCallback
2023-03-22 21:53:06 +00:00
*/
2023-04-12 17:04:25 +00:00
constructor(path, fileViewElem, clickCallback){
//TODO check all params
2023-03-22 21:53:06 +00:00
this.path = path
this.openFolder(path, fileViewElem)
// let scrollDiv = fileViewElem.children[1]
// console.log(scrollDiv)
// let scrollBar = new WdeScrollBar(fileViewElem.children[1].children[0], fileViewElem.children[0])
fileViewElem.addEventListener('click', (event) => {
2023-04-12 17:04:25 +00:00
clickCallback(event)
2023-03-22 21:53:06 +00:00
})
}
/** Get html of folder by path
* @param {string} path
* @param {HTMLElement} parentElem
*/
openFolder(path, parentElem){
2023-04-12 17:04:25 +00:00
// console.log(`${window.location.origin}/system/wde/widgets/file-tile-view?path=${path}`)
2023-03-22 21:53:06 +00:00
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) => {
parentElem.innerHTML = html
}).catch((error) => {
WebDesktopEnvironment.Alert(error);
})
}
}