Broken and basic traversal only
This commit is contained in:
@@ -1,16 +1,18 @@
|
||||
const paths = require('path')
|
||||
module.exports.mergedir = (dirname,settings)=>{
|
||||
return paths.join(settings.dirname,dirname);
|
||||
return paths.normalize(paths.join(settings.dirname,dirname));
|
||||
}
|
||||
|
||||
module.exports.dirprocess = (dirstream,settings)=>{
|
||||
dirstream.forEach(element => {
|
||||
element.type = element.isDirectory()
|
||||
});
|
||||
dirstream.push({'name':'..','type':true})
|
||||
//dirstream.contents.push({'name':'..','type':true})
|
||||
if(!settings.showHidden){
|
||||
let fdirstream = dirstream.filter((ele)=>{
|
||||
//ele.type=ele.isDirectory
|
||||
return ele.name[0]!='.'
|
||||
return ele.name[0]!='.'||ele.name=='..'
|
||||
})
|
||||
return fdirstream
|
||||
}
|
||||
|
@@ -1,19 +1,33 @@
|
||||
|
||||
let currDir = {'loc':'','contents':null};
|
||||
|
||||
|
||||
function doUpdate(ele){
|
||||
console.log(ele.attr('data-choice'));
|
||||
if(ele.hasClass('file-isDir')){
|
||||
currDir.loc = currDir.loc+ "/"+ ele.attr('data-choice');
|
||||
populateContents();
|
||||
}
|
||||
//$()
|
||||
//$(this).
|
||||
}
|
||||
|
||||
function updateContents(contents){
|
||||
console.log(contents)
|
||||
$('#files-location').html(contents.loc)
|
||||
//console.log(contents)
|
||||
$('#files-location').html(currDir.loc)
|
||||
if(contents===null) $('#files-table').append(`<tr><td>null</td><td class="file-handlers"></td></tr>`)
|
||||
else
|
||||
{
|
||||
$('#files-table').empty();
|
||||
contents.contents.forEach(element => {
|
||||
$('#files-table').append(`<tr><td class="file-name ${(element.type?'file-isDir':'file-isFile')}">${element.name}</td><td class="file-handlers"></td></tr>`)
|
||||
$('#files-table').append(`<tr class="files-row"><td onclick="doUpdate($(this))" class="file-name ${(element.type?'file-isDir':'file-isFile')}" data-choice="${element.name}">${element.name}</td><td class="file-handlers"></td></tr>`)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//set table details
|
||||
function populateContents(){
|
||||
$.ajax('/files/ls'+currDir.loc,{
|
||||
$.ajax('/files/ls',{
|
||||
method:'post',
|
||||
data: currDir,
|
||||
success:(msg)=>{
|
||||
|
Reference in New Issue
Block a user