Process file type and send it over

This commit is contained in:
2019-05-21 20:31:41 +05:30
parent 4f01ee8cb8
commit 51775c76f2
5 changed files with 47 additions and 11 deletions

View File

@@ -98,6 +98,12 @@ table td{
tbody tr:last-child{
border:0;
}
tbody td.file-isDir{
font-style: italic;
}
tbody td.file-isDir::after{
content: '/';
}
.box-shadow-1{

View File

@@ -1,8 +1,33 @@
let currDir = '/';
let currDir = {'loc':'','contents':null};
function updateContents(contents){
console.log(contents)
$('#files-location').html(contents.loc)
if(contents===null) $('#files-table').append(`<tr><td>null</td><td class="file-handlers"></td></tr>`)
else
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>`)
});
}
//set table details
function setList(){
function populateContents(){
$.ajax('/files/ls'+currDir.loc,{
method:'post',
data: currDir,
success:(msg)=>{
updateContents(msg)
}
})
return null;
}
$(document).ready(()=>{
populateContents();
//updateContents();
})

View File

@@ -10,7 +10,7 @@
<body>
<div class="navbar-container box-shadow-1">
<div class="navbar">
<div class="navbar-text">TEXT</div>
<div class="navbar-text">Location: /<span id="files-location"></span></div>
</div>
</div>
@@ -23,15 +23,15 @@
<td>Actions</td>
</tr>
</thead>
<tbody>
<tr>
<tbody id="files-table">
<!--<tr>
<td>TEST1</td>
<td class="file-handlers">TEST2</td>
</tr>
<tr>
<td>TEST3</td>
<td class="file-handlers">TEST4</td>
</tr>
</tr>-->
</tbody>
</table>
</div>