mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
added ability to get directory size, when space button is pressed and current file is directory.
This commit is contained in:
parent
d91c8dc97c
commit
c918e0fbce
6 changed files with 57 additions and 12 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -1,5 +1,8 @@
|
|||
#files, the will be ignored by git
|
||||
|
||||
#file with changes
|
||||
json/changes.json
|
||||
|
||||
#c9 files
|
||||
.c9revisions
|
||||
*tmp
|
||||
|
|
|
|||
|
|
@ -56,6 +56,9 @@ from storage folder.
|
|||
|
||||
* Added ability to recursivly get current folder size.
|
||||
|
||||
* Added ability to get directory size, when space button
|
||||
is pressed and current file is directory.
|
||||
|
||||
|
||||
2012.03.01, Version 0.1.9
|
||||
|
||||
|
|
|
|||
|
|
@ -1001,13 +1001,14 @@ var CloudCommander, Util, DOM = {}, CloudFunc;
|
|||
* get size
|
||||
* @pCurrentFile
|
||||
*/
|
||||
DOM.loadCurrentSize = function(pCurrentFile){
|
||||
DOM.loadCurrentSize = function(pCallBack, pCurrentFile){
|
||||
var lRet,
|
||||
lLink = DOM.getCurrentPath(pCurrentFile);
|
||||
/* если это папка - возвращаем слово dir вместо размера*/
|
||||
|
||||
DOM.RESTfull.read(lLink, function(pSize){
|
||||
Util.log(pSize);
|
||||
DOM.setCurrentSize(pSize);
|
||||
Util.exec(pCallBack);
|
||||
}, '?size');
|
||||
|
||||
return lRet;
|
||||
|
|
@ -1232,14 +1233,28 @@ var CloudCommander, Util, DOM = {}, CloudFunc;
|
|||
return lIsCurrent;
|
||||
};
|
||||
|
||||
/**
|
||||
* selected file check
|
||||
*
|
||||
* @param pCurrentFile
|
||||
*/
|
||||
DOM.isSelected = function(pSelected){
|
||||
var lClass = pSelected && pSelected.className,
|
||||
lIsSelected = lClass && lClass.indexOf(SELECTED_FILE) >= 0;
|
||||
|
||||
return lIsSelected;
|
||||
};
|
||||
|
||||
/**
|
||||
* check is current file is a directory
|
||||
*
|
||||
* @param pCurrentFile
|
||||
*/
|
||||
DOM.isCurrentIsDir = function(pCurrentFile){
|
||||
var lSize = DOM.getCurrentSize(pCurrentFile),
|
||||
lRet = lSize === 'dir';
|
||||
DOM.isCurrentIsDir = function(pCurrent){
|
||||
var lCurrent = pCurrent || DOM.getCurrentFile(),
|
||||
lFileType = DOM.getByClass('mini-icon', lCurrent)[0],
|
||||
lClass = lFileType && lFileType.className,
|
||||
lRet = lClass && lClass.indexOf('directory') >= 0;
|
||||
|
||||
return lRet;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -186,7 +186,19 @@ var CloudCommander, Util, DOM;
|
|||
break;
|
||||
|
||||
case KEY.SPACE:
|
||||
DOM.selectFile(lCurrentFile);
|
||||
var lSelected = DOM.isSelected(lCurrentFile),
|
||||
lDir = DOM.isCurrentIsDir(lCurrentFile);
|
||||
|
||||
|
||||
if(lDir)
|
||||
Util.ifExec(lSelected, function(){
|
||||
DOM.selectFile(lCurrentFile);
|
||||
}, function(pCallBack){
|
||||
DOM.loadCurrentSize(pCallBack, lCurrentFile);
|
||||
});
|
||||
else
|
||||
DOM.selectFile(lCurrentFile);
|
||||
|
||||
DOM.preventDefault(pEvent);
|
||||
break;
|
||||
|
||||
|
|
|
|||
|
|
@ -41,23 +41,34 @@
|
|||
fs.readdir(pDir, function(pError, pFiles) {
|
||||
lAsyncRunning--;
|
||||
|
||||
var lDirPath, n;
|
||||
|
||||
if (!pError){
|
||||
lFileCounter += pFiles.length;
|
||||
n = pFiles.length;
|
||||
lFileCounter += n;
|
||||
|
||||
var lDirPath;
|
||||
for (var i = 0, n = pFiles.length; i < n; i++) {
|
||||
for (var i = 0; i < n; i++) {
|
||||
lDirPath = path.join(pDir, pFiles[i]);
|
||||
getDirSize(lDirPath);
|
||||
}
|
||||
}
|
||||
|
||||
if(!n)
|
||||
execCallBack();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (!lFileCounter && !lAsyncRunning)
|
||||
pCallBack(null, lTotal);
|
||||
});
|
||||
execCallBack();
|
||||
});
|
||||
}
|
||||
|
||||
function execCallBack(){
|
||||
if (!lFileCounter && !lAsyncRunning){
|
||||
console.log(lTotal);
|
||||
pCallBack(null, lTotal);
|
||||
}
|
||||
}
|
||||
|
||||
return getDirSize(pDir);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -103,6 +103,7 @@
|
|||
dir.getSize(p.name, function(pErr, pSize){
|
||||
if(!pErr){
|
||||
var lSize = CloudFunc.getShortSize(pSize);
|
||||
console.log(lSize);
|
||||
main.sendResponse(pParams, lSize);
|
||||
}
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue