42 lines
1.2 KiB
JavaScript
42 lines
1.2 KiB
JavaScript
|
class FileView{
|
||
|
path = ""
|
||
|
/**
|
||
|
* @param {string} path
|
||
|
* @param {HTMLElement} fileViewElem
|
||
|
*/
|
||
|
constructor(path, fileViewElem){
|
||
|
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) => {
|
||
|
this.click(event)
|
||
|
})
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @param {event} event
|
||
|
*/
|
||
|
click(){
|
||
|
console.log(event.target)
|
||
|
}
|
||
|
|
||
|
/** 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);
|
||
|
})
|
||
|
}
|
||
|
}
|