added file count to fs browser...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2015-12-10 06:18:55 +03:00
parent 6831bfcddb
commit 11cef78715
2 changed files with 25 additions and 2 deletions

View File

@ -187,6 +187,16 @@
overflow: hidden;
}
.browse-widget .list>div:after {
display: inline-block;
content: attr(count);
float: right;
margin-right: 10px;
opacity: 0.4;
}
.browse-widget .list>div.strike-out .text {
text-decoration: line-through;
opacity: 0.3;

View File

@ -100,6 +100,7 @@ function(path, make){
// list dirs...
} else {
return new promise(function(resolve, reject){
// XXX should this be a promise???
fs.readdir(path, function(err, files){
// XXX
if(err){
@ -116,9 +117,21 @@ function(path, make){
: file, null, true)
})
.then(function(res){
res && make(fullpath
var dir = res.isDirectory()
var elem = res && make(fullpath
? path +'/'+ file
: file + (res.isDirectory() ? '/' : ''))
: file + (dir ? '/' : ''))
// count the number of files...
// NOTE: we do not care how long it will take
// so we'll not wait...
if(res && dir){
fs.readdir(path +'/'+ file, function(err, files){
if(!err){
elem.attr('count', '('+ files.length +')')
}
})
}
})
// NOTE: we are not using promise.all(..) here because it
// triggers BEFORE the first make(..) is called...