2019-05-21 19:37:11 +05:30
|
|
|
|
2019-05-21 20:31:41 +05:30
|
|
|
let currDir = {'loc':'','contents':null};
|
2019-05-23 20:23:32 +05:30
|
|
|
let currSel = {'loc':'','path':''}
|
2019-05-21 19:37:11 +05:30
|
|
|
|
2019-05-23 20:23:32 +05:30
|
|
|
function doUpdate(ele,isDir=false){
|
|
|
|
//console.log(ele.attr('data-choice'));
|
2019-05-22 17:09:45 +05:30
|
|
|
if(ele.hasClass('file-isDir')){
|
2019-05-22 20:22:59 +05:30
|
|
|
currDir.loc = ele.attr('data-choice');
|
2019-05-22 17:09:45 +05:30
|
|
|
populateContents();
|
|
|
|
}
|
2019-05-23 20:23:32 +05:30
|
|
|
if(!isDir){
|
|
|
|
$('.nav-bottom-text').html(ele.html())
|
|
|
|
|
|
|
|
}
|
2019-05-22 17:09:45 +05:30
|
|
|
//$()
|
|
|
|
//$(this).
|
|
|
|
}
|
|
|
|
|
2019-05-21 20:31:41 +05:30
|
|
|
function updateContents(contents){
|
2019-05-23 20:23:32 +05:30
|
|
|
//console.log(contents)
|
2019-05-22 20:22:59 +05:30
|
|
|
|
|
|
|
// Change top header contents
|
2019-05-22 17:09:45 +05:30
|
|
|
$('#files-location').html(currDir.loc)
|
2019-05-22 20:22:59 +05:30
|
|
|
|
|
|
|
// if empty, return null, this shouldnt execute if the server is responding properly but ok
|
|
|
|
if(contents===null) {
|
|
|
|
$('#files-table').append(`<tr><td>null</td><td class="file-handlers"></td></tr>`)
|
|
|
|
}
|
2019-05-21 20:31:41 +05:30
|
|
|
else
|
2019-05-22 17:09:45 +05:30
|
|
|
{
|
2019-05-23 20:23:32 +05:30
|
|
|
$('#files-table').hide().empty();
|
2019-05-22 17:09:45 +05:30
|
|
|
contents.contents.forEach(element => {
|
2019-05-23 20:23:32 +05:30
|
|
|
$('#files-table').append(`<tr class="files-row box-shadow-1-active"><td onclick="doUpdate($(this),${element.isDir})" class="file-name ${(element.isDir?'file-isDir':'file-isFile')}" data-choice="${element.path}">${element.name}</td></tr>`)
|
2019-05-22 17:09:45 +05:30
|
|
|
});
|
2019-05-22 20:22:59 +05:30
|
|
|
if(contents.back!=null){
|
2019-05-23 20:23:32 +05:30
|
|
|
$('#files-table').prepend(`<tr class="files-row box-shadow-1-active"><td onclick="doUpdate($(this))" class="file-name file-isDir file-isBack" data-choice="${contents.back}">..</td></tr>`)
|
2019-05-22 20:22:59 +05:30
|
|
|
}
|
2019-05-23 20:23:32 +05:30
|
|
|
$('#files-table').fadeIn()
|
2019-05-22 17:09:45 +05:30
|
|
|
}
|
2019-05-21 20:31:41 +05:30
|
|
|
}
|
2019-05-21 19:37:11 +05:30
|
|
|
|
|
|
|
//set table details
|
2019-05-21 20:31:41 +05:30
|
|
|
function populateContents(){
|
2019-05-22 17:09:45 +05:30
|
|
|
$.ajax('/files/ls',{
|
2019-05-21 20:31:41 +05:30
|
|
|
method:'post',
|
|
|
|
data: currDir,
|
|
|
|
success:(msg)=>{
|
|
|
|
updateContents(msg)
|
|
|
|
}
|
2019-05-21 19:37:11 +05:30
|
|
|
|
2019-05-21 20:31:41 +05:30
|
|
|
})
|
|
|
|
return null;
|
2019-05-21 19:37:11 +05:30
|
|
|
}
|
2019-05-21 20:31:41 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(document).ready(()=>{
|
|
|
|
populateContents();
|
|
|
|
//updateContents();
|
|
|
|
})
|