2019-05-21 19:37:11 +05:30
|
|
|
|
2019-05-21 20:31:41 +05:30
|
|
|
let currDir = {'loc':'','contents':null};
|
2019-05-21 19:37:11 +05:30
|
|
|
|
2019-05-22 17:09:45 +05:30
|
|
|
|
|
|
|
function doUpdate(ele){
|
|
|
|
console.log(ele.attr('data-choice'));
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
//$()
|
|
|
|
//$(this).
|
|
|
|
}
|
|
|
|
|
2019-05-21 20:31:41 +05:30
|
|
|
function updateContents(contents){
|
2019-05-22 20:22:59 +05:30
|
|
|
console.log(contents)
|
|
|
|
|
|
|
|
// 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
|
|
|
{
|
|
|
|
$('#files-table').empty();
|
|
|
|
contents.contents.forEach(element => {
|
2019-05-22 20:22:59 +05:30
|
|
|
$('#files-table').append(`<tr class="files-row"><td onclick="doUpdate($(this))" class="file-name ${(element.isDir?'file-isDir':'file-isFile')}" data-choice="${element.path}">${element.name}</td><td class="file-handlers"></td></tr>`)
|
2019-05-22 17:09:45 +05:30
|
|
|
});
|
2019-05-22 20:22:59 +05:30
|
|
|
if(contents.back!=null){
|
|
|
|
$('#files-table').prepend(`<tr class="files-row"><td onclick="doUpdate($(this))" class="file-name file-isDir file-isBack" data-choice="${contents.back}">..</td><td class="file-handlers"></td></tr>`)
|
|
|
|
}
|
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();
|
|
|
|
})
|