37 lines
1.2 KiB
JavaScript
37 lines
1.2 KiB
JavaScript
class FileView{
|
|
path = ""
|
|
/**
|
|
* @param {string} path
|
|
* @param {HTMLElement} fileViewElem
|
|
* @param {Function} clickCallback
|
|
*/
|
|
constructor(path, fileViewElem, clickCallback){
|
|
//TODO check all params
|
|
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) => {
|
|
clickCallback(event)
|
|
})
|
|
}
|
|
|
|
/** Get html of folder by path
|
|
* @param {string} path
|
|
* @param {HTMLElement} parentElem
|
|
*/
|
|
openFolder(path, parentElem){
|
|
// console.log(`${window.location.origin}/system/wde/widgets/file-tile-view?path=${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) => {
|
|
parentElem.innerHTML = html
|
|
}).catch((error) => {
|
|
WebDesktopEnvironment.Alert(error);
|
|
})
|
|
}
|
|
} |